Skip to content

Commit d761b7d

Browse files
authored
Merge branch 'OpenAPITools:master' into fix-form-request-param-validation
2 parents e847cbe + 2513d82 commit d761b7d

39 files changed

Lines changed: 177 additions & 48 deletions

File tree

.github/workflows/linux.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
restore-keys: |
4545
${{ runner.os }}-gradle-
4646
47-
- uses: gradle/actions/setup-gradle@v3
47+
- uses: gradle/actions/setup-gradle@v4
4848
with:
4949
gradle-version: '8.14.3'
5050

.github/workflows/windows.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
java -jar ./openapi-generator-cli.jar author template --verbose -g jaxrs-spec --library quarkus
5555
- name: Setup Gradle
5656
uses: gradle/gradle-build-action@v3
57+
with:
58+
gradle-version: '8.14.3'
5759
- name: Gradle tests
5860
run: |
5961
gradle -b modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle buildGoSdk --stacktrace

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,11 @@ protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
436436
.put("indented", new IndentedLambda())
437437
.put("indented_8", new IndentedLambda(8, " ", false, false))
438438
.put("indented_12", new IndentedLambda(12, " ", false, false))
439-
.put("indented_16", new IndentedLambda(16, " ", false, false));
440-
439+
.put("indented_16", new IndentedLambda(16, " ", false, false))
440+
.put("trimLineBreaks", new TrimLineBreaksLambda())
441+
.put("trimWhitespace", new TrimWhitespaceLambda())
442+
.put("trimTrailingWithNewLine", new TrimTrailingWhiteSpaceLambda(true))
443+
.put("trimTrailing", new TrimTrailingWhiteSpaceLambda(false));
441444
}
442445

443446
private void registerMustacheLambdas() {
@@ -6025,10 +6028,8 @@ protected Map<String, Schema> unaliasPropertySchema(Map<String, Schema> properti
60256028
if (properties != null) {
60266029
for (String key : properties.keySet()) {
60276030
properties.put(key, unaliasSchema(properties.get(key)));
6028-
60296031
}
60306032
}
6031-
60326033
return properties;
60336034
}
60346035

@@ -7094,7 +7095,7 @@ public boolean convertPropertyToBoolean(String propertyKey) {
70947095
} else if (booleanValue instanceof String) {
70957096
result = Boolean.parseBoolean((String) booleanValue);
70967097
} else {
7097-
LOGGER.warn("The value (generator's option) must be either boolean or string. Default to `false`.");
7098+
LOGGER.warn("The generator's option \"{}\" must be either boolean or string. Default to `false`.", propertyKey);
70987099
}
70997100
return result;
71007101
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,6 @@ protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
439439
.put("joinWithAmpersand", new JoinWithCommaLambda(true, " ", " && "))
440440
.put("joinLinesWithComma", new JoinWithCommaLambda(false, "\n", ",\n"))
441441
.put("joinConditions", new JoinWithCommaLambda(true, " ", " && "))
442-
.put("trimLineBreaks", new TrimLineBreaksLambda())
443-
.put("trimTrailingWithNewLine", new TrimTrailingWhiteSpaceLambda(true))
444-
.put("trimTrailing", new TrimTrailingWhiteSpaceLambda(false))
445442
.put("first", new FirstLambda(" "))
446443
.put("firstDot", new FirstLambda("\\."))
447444
.put("indent1", new IndentedLambda(4, " ", false, true))

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public class TypeScriptClientCodegen extends AbstractTypeScriptClientCodegen imp
8383

8484
private final Map<String, String> frameworkToHttpLibMap;
8585

86+
@Setter
87+
private boolean useRxJS;
88+
@Setter
89+
private boolean useInversify;
90+
8691
// NPM Options
8792
private static final String NPM_REPOSITORY = "npmRepository";
8893

@@ -461,12 +466,12 @@ public void processOpts() {
461466
additionalProperties.put(IMPORT_FILE_EXTENSION_SWITCH, ".ts");
462467
}
463468

464-
final boolean useRxJS = convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH);
469+
convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH, this::setUseRxJS);
465470
if (!useRxJS) {
466471
supportingFiles.add(new SupportingFile("rxjsStub.mustache", "rxjsStub.ts"));
467472
}
468473

469-
final boolean useInversify = convertPropertyToBooleanAndWriteBack(USE_INVERSIFY_SWITCH);
474+
convertPropertyToBooleanAndWriteBack(USE_INVERSIFY_SWITCH, this::setUseInversify);
470475
if (useInversify) {
471476
supportingFiles.add(new SupportingFile("services" + File.separator + "index.mustache", "services", "index.ts"));
472477
supportingFiles.add(new SupportingFile("services" + File.separator + "configuration.mustache", "services", "configuration.ts"));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void processOpts() {
313313
}
314314
}
315315

316-
setGenerateValidationAttributes(convertPropertyToBooleanAndWriteBack(VALIDATION_ATTRIBUTES));
316+
convertPropertyToBooleanAndWriteBack(VALIDATION_ATTRIBUTES, this::setGenerateValidationAttributes);
317317
}
318318

319319
@Override

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
134134
{{/isNumber}}
135135
{{^isNumber}}
136136
{{^isPrimitiveType}}
137+
{{#isUuid}}
138+
UUID.fromString(jsonElement.getAsString());
139+
{{/isUuid}}
140+
{{^isUuid}}
137141
{{{dataType}}}.validateJsonElement(jsonElement);
142+
{{/isUuid}}
138143
actualAdapter = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}};
139144
{{/isPrimitiveType}}
140145
{{/isNumber}}
@@ -328,7 +333,12 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
328333
{{/isNumber}}
329334
{{^isNumber}}
330335
{{^isPrimitiveType}}
336+
{{#isUuid}}
337+
UUID.fromString(jsonElement.getAsString());
338+
{{/isUuid}}
339+
{{^isUuid}}
331340
{{{dataType}}}.validateJsonElement(jsonElement);
341+
{{/isUuid}}
332342
{{/isPrimitiveType}}
333343
{{/isNumber}}
334344
{{/isArray}}

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
175175
{{/isNumber}}
176176
{{^isNumber}}
177177
{{^isPrimitiveType}}
178+
{{#isUuid}}
179+
UUID.fromString(jsonElement.getAsString());
180+
{{/isUuid}}
181+
{{^isUuid}}
178182
{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}.validateJsonElement(jsonElement);
183+
{{/isUuid}}
179184
actualAdapter = adapter{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}};
180185
{{/isPrimitiveType}}
181186
{{/isNumber}}
@@ -408,7 +413,12 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
408413
{{/isNumber}}
409414
{{^isNumber}}
410415
{{^isPrimitiveType}}
416+
{{#isUuid}}
417+
UUID.fromString(jsonElement.getAsString());
418+
{{/isUuid}}
419+
{{^isUuid}}
411420
{{#sanitizeDataType}}{{{dataType}}}{{/sanitizeDataType}}.validateJsonElement(jsonElement);
421+
{{/isUuid}}
412422
{{/isPrimitiveType}}
413423
{{/isNumber}}
414424
{{/isArray}}

modules/openapi-generator/src/main/resources/Java/pojo.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
6767
{{#gson}}
6868
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
6969
{{/gson}}
70+
{{^isDiscriminator}}
7071
{{>nullable_var_annotations}}{{! prevent indent}}
72+
{{/isDiscriminator}}
73+
{{#isDiscriminator}}
74+
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
75+
{{/isDiscriminator}}
7176
{{#vendorExtensions.x-field-extra-annotation}}
7277
{{{vendorExtensions.x-field-extra-annotation}}}
7378
{{/vendorExtensions.x-field-extra-annotation}}

0 commit comments

Comments
 (0)