Skip to content

Commit 2de7d60

Browse files
author
David Gamero
committed
Merge branch 'master' into use-built-in-abortsignal
2 parents c0f5c57 + 490de02 commit 2de7d60

94 files changed

Lines changed: 2089 additions & 79 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.

.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/samples-kotlin-client.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
branches:
66
- 'samples/client/petstore/kotlin*/**'
77
- 'samples/client/others/kotlin-jvm-okhttp-parameter-tests/**'
8+
- samples/client/others/kotlin-integer-enum/**
89
pull_request:
910
paths:
1011
- 'samples/client/petstore/kotlin*/**'
1112
- 'samples/client/others/kotlin-jvm-okhttp-parameter-tests/**'
13+
- samples/client/others/kotlin-integer-enum/**
1214

1315
jobs:
1416
build:
@@ -66,6 +68,7 @@ jobs:
6668
- samples/client/petstore/kotlin-name-parameter-mappings
6769
- samples/client/others/kotlin-jvm-okhttp-parameter-tests
6870
- samples/client/others/kotlin-jvm-okhttp-path-comments
71+
- samples/client/others/kotlin-integer-enum
6972
- samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization
7073
steps:
7174
- uses: actions/checkout@v5

.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
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: kotlin
2+
outputDir: samples/client/others/kotlin-integer-enum
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/pr_21746.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
5+
additionalProperties:
6+
artifactId: kotlin-integer-enum

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/OpenAPINormalizer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@
3333
import org.slf4j.LoggerFactory;
3434

3535
import java.lang.reflect.Constructor;
36-
import java.lang.reflect.InvocationTargetException;
3736
import java.util.*;
3837
import java.util.function.Function;
3938
import java.util.stream.Collectors;
4039

41-
import static org.openapitools.codegen.utils.ModelUtils.simplyOneOfAnyOfWithOnlyOneNonNullSubSchema;
40+
import static org.openapitools.codegen.utils.ModelUtils.simplifyOneOfAnyOfWithOnlyOneNonNullSubSchema;
4241
import static org.openapitools.codegen.utils.StringUtils.getUniqueString;
4342

4443
public class OpenAPINormalizer {
@@ -1318,7 +1317,7 @@ protected Schema processSimplifyOneOf(Schema schema) {
13181317
}
13191318
}
13201319

1321-
schema = simplyOneOfAnyOfWithOnlyOneNonNullSubSchema(openAPI, schema, oneOfSchemas);
1320+
schema = simplifyOneOfAnyOfWithOnlyOneNonNullSubSchema(openAPI, schema, oneOfSchemas);
13221321

13231322
if (ModelUtils.isIntegerSchema(schema) || ModelUtils.isNumberSchema(schema) || ModelUtils.isStringSchema(schema)) {
13241323
// TODO convert oneOf const to enum
@@ -1445,7 +1444,7 @@ protected Schema processSimplifyAnyOf(Schema schema) {
14451444
}
14461445
}
14471446

1448-
schema = simplyOneOfAnyOfWithOnlyOneNonNullSubSchema(openAPI, schema, anyOfSchemas);
1447+
schema = simplifyOneOfAnyOfWithOnlyOneNonNullSubSchema(openAPI, schema, anyOfSchemas);
14491448
}
14501449

14511450
return schema;

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/AbstractPythonCodegen.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,8 @@ private PythonType dateType(IJsonSchemaValidationProperties cp) {
20242024
}
20252025

20262026
private PythonType uuidType(IJsonSchemaValidationProperties cp) {
2027-
return new PythonType(cp.getDataType());
2027+
moduleImports.add("uuid", "UUID");
2028+
return new PythonType("UUID");
20282029
}
20292030

20302031
private PythonType modelType(IJsonSchemaValidationProperties cp) {
@@ -2051,6 +2052,8 @@ private PythonType fromCommon(IJsonSchemaValidationProperties cp) {
20512052
return arrayType(cp);
20522053
} else if (cp.getIsMap() || cp.getIsFreeFormObject()) {
20532054
return mapType(cp);
2055+
} else if (cp.getIsUuid()) {
2056+
return uuidType(cp);
20542057
} else if (cp.getIsString()) {
20552058
return stringType(cp);
20562059
} else if (cp.getIsNumber() || cp.getIsFloat() || cp.getIsDouble()) {
@@ -2067,8 +2070,6 @@ private PythonType fromCommon(IJsonSchemaValidationProperties cp) {
20672070
return anyType(cp);
20682071
} else if (cp.getIsDate() || cp.getIsDateTime()) {
20692072
return dateType(cp);
2070-
} else if (cp.getIsUuid()) {
2071-
return uuidType(cp);
20722073
}
20732074

20742075
return null;

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

0 commit comments

Comments
 (0)