Skip to content

Commit 1c8bc60

Browse files
committed
Merge branch 'master' into fix-defaultValue
2 parents 0ba166a + bf67367 commit 1c8bc60

438 files changed

Lines changed: 28644 additions & 30425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ Here is a list of template creators:
11391139
* Kotlin (Spring Boot): @dr4ke616
11401140
* Kotlin (Vertx): @Wooyme
11411141
* Kotlin (JAX-RS): @anttileppa
1142-
* Kotlin Misk: @andrewwilsonnew
1142+
* Kotlin Misk: @andrewwilsonnew @guiarn
11431143
* Kotlin WireMock: @stefankoppier
11441144
* NodeJS Express: @YishTish
11451145
* PHP Flight: @daniel-sc
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
generatorName: rust-axum
2+
outputDir: samples/server/petstore/rust-axum/output/rust-axum-array-params-test
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-axum-array-params-test.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/rust-axum
5+
generateAliasAsModel: true
6+
additionalProperties:
7+
hideGenerationTimestamp: "true"
8+
packageName: rust-axum-array-params-test
9+
globalProperties:
10+
skipFormModel: false
11+
enablePostProcessFile: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
generatorName: typescript
2+
outputDir: samples/client/echo_api/typescript/build
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/typescript
5+
additionalProperties:
6+
artifactId: echo-api-typescript
7+
hideGenerationTimestamp: "true"
8+
platform: node
9+
npmVersion: 1.0.0
10+
npmName: '@openapitools/typescript-echo-api'

docs/generators/scala-sttp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2020
| ------ | ----------- | ------ | ------- |
2121
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
2222
|apiPackage|package for generated api classes| |null|
23+
|circeVersion|The version of circe library| |0.14.1|
2324
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for JDK 1.8+)</dd></dl>|java8|
2425
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
2526
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -454,29 +454,6 @@ public String escapeQuotationMark(String input) {
454454
return input.replace("\"", "\\\"");
455455
}
456456

457-
protected String escapeRegex(String pattern) {
458-
pattern = pattern.replaceAll("\\\\\\\\", "\\\\");
459-
pattern = pattern.replaceAll("^/", "");
460-
pattern = pattern.replaceAll("/$", "");
461-
return pattern;
462-
}
463-
464-
/**
465-
* Convert OpenAPI Parameter object to Codegen Parameter object
466-
*
467-
* @param imports set of imports for library/package/module
468-
* @param param OpenAPI parameter object
469-
* @return Codegen Parameter object
470-
*/
471-
@Override
472-
public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
473-
CodegenParameter parameter = super.fromParameter(param, imports);
474-
if (parameter.pattern != null) {
475-
parameter.pattern = escapeRegex(parameter.pattern);
476-
}
477-
return parameter;
478-
}
479-
480457
/**
481458
* Convert OAS Property schema to Codegen Property object.
482459
* <p>
@@ -498,9 +475,6 @@ public CodegenProperty fromProperty(String name, Schema schema, boolean required
498475
if (needsVarEscape(property.name)) {
499476
property.name = "var\"" + property.name + "\"";
500477
}
501-
if (property.pattern != null) {
502-
property.pattern = escapeRegex(property.pattern);
503-
}
504478
return property;
505479
}
506480

@@ -531,6 +505,19 @@ private void changeParamNames(List<CodegenParameter> paramsList, HashSet<String>
531505
}
532506
}
533507

508+
@Override
509+
public String toRegularExpression(String pattern) {
510+
if (pattern == null) {
511+
return pattern;
512+
}
513+
514+
pattern = escapeText(pattern);
515+
// escapeText unnecessarily escapes `\` such that `\.` in the regex ends up as `\\.` for example.
516+
// we need to restore it back by converting `\\` to `\`
517+
pattern = pattern.replaceAll("\\\\\\\\", "\\\\");
518+
return pattern;
519+
}
520+
534521
/**
535522
* Convert OAS Operation object to Codegen Operation object
536523
*

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public String toDefaultValue(Schema p) {
214214
String defaultValue = String.valueOf(p.getDefault());
215215
if (defaultValue != null) {
216216
defaultValue = defaultValue.replace("\\", "\\\\")
217-
.replace("'", "\'");
217+
.replace("'", "\\'");
218218
if (Pattern.compile("\r\n|\r|\n").matcher(defaultValue).find()) {
219219
return "'''" + defaultValue + "'''";
220220
} else {

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,9 @@ public void processOpts() {
413413
setParamNaming((String) additionalProperties.get(CodegenConstants.PARAM_NAMING));
414414
}
415415

416-
setSupportsES6(convertPropertyToBooleanAndWriteBack(CodegenConstants.SUPPORTS_ES6));
416+
if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ES6)) {
417+
setSupportsES6(convertPropertyToBooleanAndWriteBack(CodegenConstants.SUPPORTS_ES6));
418+
}
417419

418420
if (additionalProperties.containsKey(NULL_SAFE_ADDITIONAL_PROPS)) {
419421
setNullSafeAdditionalProps(Boolean.valueOf(additionalProperties.get(NULL_SAFE_ADDITIONAL_PROPS).toString()));

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,7 @@ public void processOpts() {
924924
addSupportingFiles(clientPackageDir, packageFolder, excludeTests, testPackageFolder, testPackageName, modelPackageDir, authPackageDir);
925925
supportingFiles.add(new SupportingFile("ConnectionException.mustache", clientPackageDir, "ConnectionException.cs"));
926926
supportingFiles.add(new SupportingFile("UnexpectedResponseException.mustache", clientPackageDir, "UnexpectedResponseException.cs"));
927+
supportingFiles.add(new SupportingFile("UnityWebRequestAwaiterExtension.mustache", clientPackageDir, "UnityWebRequestAwaiterExtension.cs"));
927928
break;
928929
default: // generichost
929930
addGenericHostSupportingFiles(clientPackageDir, packageFolder, excludeTests, testPackageFolder, testPackageName, modelPackageDir);

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ public class ElixirClientCodegen extends DefaultCodegen {
5757
// This is the name of elixir project name;
5858
protected static final String defaultPackageName = "openapi_client";
5959

60-
String supportedElixirVersion = "1.10";
60+
String supportedElixirVersion = "1.18";
6161
List<String> extraApplications = Arrays.asList(":logger");
6262
List<String> deps = Arrays.asList(
6363
"{:tesla, \"~> 1.7\"}",
64-
"{:jason, \"~> 1.4\"}",
6564
"{:ex_doc, \"~> 0.30\", only: :dev, runtime: false}",
6665
"{:dialyxir, \"~> 1.3\", only: [:dev, :test], runtime: false}");
6766

@@ -694,7 +693,7 @@ public String codeMappingKey() {
694693
}
695694

696695
public String decodedStruct() {
697-
// Let Jason decode the entire response into a generic blob
696+
// Decode the entire response into a generic blob
698697
if (isMap) {
699698
return "%{}";
700699
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinMiskServerCodegen.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public class KotlinMiskServerCodegen extends AbstractKotlinCodegen implements Be
5757
protected String rootPackage = "org.openapitools.server.api";
5858
protected String apiVersion = "1.0.0-SNAPSHOT";
5959

60-
@Setter
61-
protected String moduleClassName = "OpenApiModule";
60+
@Setter protected String moduleClassName = "OpenApiModule";
6261

6362
@Override
6463
public CodegenType getTag() {
@@ -122,7 +121,7 @@ public KotlinMiskServerCodegen() {
122121
supportingFiles.clear();
123122

124123
apiTemplateFiles.clear();
125-
apiTemplateFiles.put("apiController.mustache", "Controller.kt");
124+
apiTemplateFiles.put("apiAction.mustache", "Action.kt");
126125
apiTemplateFiles.put("apiImpl.mustache", "Impl.kt");
127126
apiTemplateFiles.put("apiInterface.mustache", ".kt");
128127
modelTemplateFiles.put("model.mustache", ".kt");
@@ -199,30 +198,38 @@ public boolean getUseBeanValidation() {
199198
}
200199

201200
private String mapMediaType(String mediaType) {
202-
return MEDIA_MAPPING.getOrDefault(mediaType, "MediaTypes.APPLICATION_OCTETSTREAM /* unknown -> " + mediaType + " */ ");
201+
return MEDIA_MAPPING.getOrDefault(mediaType, "MediaTypes.APPLICATION_OCTETSTREAM /* @todo(unknown) -> " + mediaType + " */ ");
203202
}
204203

205204
private final static Map<String, String> MEDIA_MAPPING = getMappings();
206205

207206
private static Map<String, String> getMappings() {
207+
// add new values in order
208208
Map<String, String> result = new HashMap<>();
209-
result.put("application/json", "MediaTypes.APPLICATION_JSON");
210-
result.put("application/xml", "MediaTypes.APPLICATION_XML");
211-
result.put("application/javascript", "MediaTypes.APPLICATION_JAVASCRIPT");
212209
result.put("*/*", "MediaTypes.ALL");
213-
result.put("application/x-www-form-urlencoded", "MediaTypes.APPLICATION_FORM_URLENCODED");
210+
211+
result.put("application/grpc", "MediaTypes.APPLICATION_GRPC");
212+
result.put("application/javascript", "MediaTypes.APPLICATION_JAVASCRIPT");
213+
result.put("application/json", "MediaTypes.APPLICATION_JSON");
214214
result.put("application/octetstream", "MediaTypes.APPLICATION_OCTETSTREAM");
215215
result.put("application/pdf", "MediaTypes.APPLICATION_OCTETSTREAM");
216216
result.put("application/x-protobuf", "MediaTypes.APPLICATION_PROTOBUF");
217-
result.put("application/grpc", "MediaTypes.APPLICATION_GRPC");
218-
result.put("text/css", "MediaTypes.TEXT_CSS");
219-
result.put("text/html", "MediaTypes.TEXT_HTML");
220-
result.put("text/plain", "MediaTypes.TEXT_PLAIN_UTF8");
217+
result.put("application/x-www-form-urlencoded", "MediaTypes.APPLICATION_FORM_URLENCODED");
218+
result.put("application/xml", "MediaTypes.APPLICATION_XML");
219+
result.put("application/zip", "MediaTypes.APPLICATION_ZIP");
220+
221+
result.put("image/gif", "MediaTypes.IMAGE_GIF");
222+
result.put("image/jpeg", "MediaTypes.IMAGE_JPEG");
221223
result.put("image/png", "MediaTypes.IMAGE_PNG");
222224
result.put("image/svg+xml", "MediaTypes.IMAGE_SVG");
223-
result.put("image/jpeg", "MediaTypes.IMAGE_JPEG");
224-
result.put("image/gif", "MediaTypes.IMAGE_GIF");
225225
result.put("image/x-icon", "MediaTypes.IMAGE_ICO");
226+
227+
result.put("multipart/form-data", "MediaTypes.FORM_DATA");
228+
229+
result.put("text/css", "MediaTypes.TEXT_CSS");
230+
result.put("text/html", "MediaTypes.TEXT_HTML");
231+
result.put("text/plain", "MediaTypes.TEXT_PLAIN_UTF8");
232+
226233
return result;
227234
}
228235
}

0 commit comments

Comments
 (0)