Skip to content

Commit 344a210

Browse files
committed
2 parents 57d567e + 216ba30 commit 344a210

454 files changed

Lines changed: 10672 additions & 2769 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/samples-java-client-jdk11.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ jobs:
6363
- samples/client/petstore/java/rest-assured
6464
- samples/client/petstore/java/rest-assured-jackson
6565
- samples/client/petstore/java/microprofile-rest-client
66+
- samples/client/petstore/java/microprofile-rest-client-mutiny
6667
- samples/client/petstore/java/microprofile-rest-client-3.0
6768
- samples/client/petstore/java/microprofile-rest-client-3.0-jackson
6869
- samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml
70+
- samples/client/petstore/java/microprofile-rest-client-3.0-mutiny
6971
- samples/client/petstore/java/microprofile-rest-client-with-useSingleRequestParameter
7072
- samples/client/petstore/java/apache-httpclient
7173
- samples/client/petstore/java/feign
74+
- samples/client/petstore/java/feign-no-nullable
7275
- samples/client/petstore/java/okhttp-gson-awsv4signature
7376
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters
7477
- samples/openapi3/client/petstore/java/native

bin/configs/java-feign-no-nullable.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ templateDir: modules/openapi-generator/src/main/resources/Java
66
additionalProperties:
77
booleanGetterPrefix: is
88
artifactId: petstore-feign-no-nullable
9-
hideGenerationTimestamp: "true"
9+
hideGenerationTimestamp: true
1010
additionalModelTypeAnnotations: '@javax.annotation.concurrent.Immutable'
11-
openApiNullable: "false"
11+
openApiNullable: false
12+
useReflectionEqualsHashCode: true
13+
annotationLibrary: "swagger1"

bin/configs/java-jersey2-8.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ additionalProperties:
1111
useOneOfDiscriminatorLookup: true
1212
disallowAdditionalPropertiesIfNotPresent: false
1313
gradleProperties: "\n# JVM arguments\norg.gradle.jvmargs=-Xmx2024m -XX:MaxPermSize=512m\n# set timeout\norg.gradle.daemon.idletimeout=3600000\n# show all warnings\norg.gradle.warning.mode=all"
14-
failOnUnknownProperties: true
14+
failOnUnknownProperties: true
15+
useReflectionEqualsHashCode: true

bin/configs/java-jersey3.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ additionalProperties:
1212
useOneOfDiscriminatorLookup: true
1313
disallowAdditionalPropertiesIfNotPresent: false
1414
gradleProperties: "\n# JVM arguments\norg.gradle.jvmargs=-Xmx2024m -XX:MaxPermSize=512m\n# set timeout\norg.gradle.daemon.idletimeout=3600000\n# show all warnings\norg.gradle.warning.mode=all"
15-
failOnUnknownProperties: true
15+
failOnUnknownProperties: true
16+
useReflectionEqualsHashCode: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
generatorName: java
2+
outputDir: samples/client/petstore/java/microprofile-rest-client-3.0-mutiny
3+
library: microprofile
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
artifactId: microprofile-rest-client-3-mutiny
8+
configKey: petstore
9+
microprofileRestClientVersion: "3.0"
10+
microprofileMutiny: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
generatorName: java
2+
outputDir: samples/client/petstore/java/microprofile-rest-client-mutiny
3+
library: microprofile
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
artifactId: microprofile-rest-client-mutiny
8+
configKeyFromClassName: true
9+
microprofileMutiny: true

bin/configs/java-native.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ additionalProperties:
77
artifactId: petstore-native
88
hideGenerationTimestamp: "true"
99
generateBuilders: true
10+
useReflectionEqualsHashCode: "true"

bin/configs/java-okhttp-gson.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ parameterNameMappings:
1111
type_: typeWithUnderscore
1212
additionalProperties:
1313
artifactId: petstore-okhttp-gson
14-
hideGenerationTimestamp: "true"
15-
useOneOfDiscriminatorLookup: "true"
14+
hideGenerationTimestamp: true
15+
useOneOfDiscriminatorLookup: true
1616
disallowAdditionalPropertiesIfNotPresent: false
17+
useReflectionEqualsHashCode:: true
1718
enumNameMappings:
1819
s: LOWER_CASE_S
1920
S: UPPER_CASE_S

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
8484

8585
// Grouping (Method, Operation) by Path.
8686
private final Map<String, ArrayList<MethodOperation>> pathMethodOpMap = new HashMap<>();
87+
private boolean havingAuthMethods = false;
8788

8889
// Logger
8990
private final Logger LOGGER = LoggerFactory.getLogger(RustAxumServerCodegen.class);
@@ -595,21 +596,26 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
595596

596597
@Override
597598
public OperationsMap postProcessOperationsWithModels(final OperationsMap operationsMap, List<ModelMap> allModels) {
598-
OperationMap operations = operationsMap.getOperations();
599+
final OperationMap operations = operationsMap.getOperations();
599600
operations.put("classnamePascalCase", camelize(operations.getClassname()));
600-
List<CodegenOperation> operationList = operations.getOperation();
601601

602-
for (CodegenOperation op : operationList) {
603-
postProcessOperationWithModels(op);
602+
final boolean hasAuthMethod = operations.getOperation().stream()
603+
.map(this::postProcessOperationWithModels)
604+
.reduce(false, (a, b) -> a || b);
605+
if (hasAuthMethod) {
606+
operations.put("havingAuthMethod", true);
607+
operations.getOperation().forEach(op -> op.vendorExtensions.put("havingAuthMethod", true));
608+
this.havingAuthMethods = true;
604609
}
605610

606611
return operationsMap;
607612
}
608613

609-
private void postProcessOperationWithModels(final CodegenOperation op) {
614+
private boolean postProcessOperationWithModels(final CodegenOperation op) {
610615
boolean consumesJson = false;
611616
boolean consumesPlainText = false;
612617
boolean consumesFormUrlEncoded = false;
618+
boolean hasAuthMethod = false;
613619

614620
if (op.consumes != null) {
615621
for (Map<String, String> consume : op.consumes) {
@@ -666,17 +672,20 @@ private void postProcessOperationWithModels(final CodegenOperation op) {
666672
for (CodegenSecurity s : op.authMethods) {
667673
if (s.isApiKey && (s.isKeyInCookie || s.isKeyInHeader)) {
668674
if (s.isKeyInCookie) {
669-
op.vendorExtensions.put("x-has-cookie-auth-methods", "true");
670-
op.vendorExtensions.put("x-api-key-cookie-name", toModelName(s.keyParamName));
675+
op.vendorExtensions.put("x-has-cookie-auth-methods", true);
676+
op.vendorExtensions.put("x-api-key-cookie-name", s.keyParamName);
671677
} else {
672-
op.vendorExtensions.put("x-has-header-auth-methods", "true");
673-
op.vendorExtensions.put("x-api-key-header-name", toModelName(s.keyParamName));
678+
op.vendorExtensions.put("x-has-header-auth-methods", true);
679+
op.vendorExtensions.put("x-api-key-header-name", s.keyParamName);
674680
}
675681

676-
op.vendorExtensions.put("x-has-auth-methods", "true");
682+
op.vendorExtensions.put("x-has-auth-methods", true);
683+
hasAuthMethod = true;
677684
}
678685
}
679686
}
687+
688+
return hasAuthMethod;
680689
}
681690

682691
@Override
@@ -772,6 +781,7 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> bun
772781
.sorted(Comparator.comparing(a -> a.path))
773782
.collect(Collectors.toList());
774783
bundle.put("pathMethodOps", pathMethodOps);
784+
if (havingAuthMethods) bundle.put("havingAuthMethods", true);
775785

776786
return super.postProcessSupportingFileData(bundle);
777787
}

modules/openapi-generator/src/main/resources/Java/build.gradle.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ ext {
126126
jersey_version = "1.19.4"
127127
jodatime_version = "2.9.9"
128128
junit_version = "5.10.2"
129+
{{#useReflectionEqualsHashCode}}
130+
commons_lang3_version = "3.17.0"
131+
{{/useReflectionEqualsHashCode}}
129132
}
130133

131134
dependencies {
@@ -148,6 +151,9 @@ dependencies {
148151
{{#useBeanValidation}}
149152
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
150153
{{/useBeanValidation}}
154+
{{#useReflectionEqualsHashCode}}
155+
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
156+
{{/useReflectionEqualsHashCode}}
151157
testImplementation "junit:junit:$junit_version"
152158
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
153159
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"

0 commit comments

Comments
 (0)