Skip to content

Commit

Permalink
Merge branch 'OpenAPITools:master' into feature/CBR-python-pydantic-v…
Browse files Browse the repository at this point in the history
…1-secret-str
  • Loading branch information
webertim authored Nov 14, 2024
2 parents 331c04a + 216ba30 commit 8629c7f
Show file tree
Hide file tree
Showing 459 changed files with 10,715 additions and 2,777 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/samples-java-client-jdk11.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ jobs:
- samples/client/petstore/java/rest-assured
- samples/client/petstore/java/rest-assured-jackson
- samples/client/petstore/java/microprofile-rest-client
- samples/client/petstore/java/microprofile-rest-client-mutiny
- samples/client/petstore/java/microprofile-rest-client-3.0
- samples/client/petstore/java/microprofile-rest-client-3.0-jackson
- samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml
- samples/client/petstore/java/microprofile-rest-client-3.0-mutiny
- samples/client/petstore/java/microprofile-rest-client-with-useSingleRequestParameter
- samples/client/petstore/java/apache-httpclient
- samples/client/petstore/java/feign
- samples/client/petstore/java/feign-no-nullable
- samples/client/petstore/java/okhttp-gson-awsv4signature
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters
- samples/openapi3/client/petstore/java/native
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Stable releases in Maven Central](https://img.shields.io/maven-metadata/v/https/repo1.maven.org/maven2/org/openapitools/openapi-generator/maven-metadata.xml.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22)
[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-orange)](./LICENSE)
[![Open Collective backers](https://img.shields.io/opencollective/backers/openapi_generator?color=orange&label=OpenCollective%20Backers)](https://opencollective.com/openapi_generator)
[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g)
[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ)
[![Follow OpenAPI Generator Twitter account to get the latest update](https://img.shields.io/twitter/follow/oas_generator.svg?style=social&label=Follow)](https://twitter.com/oas_generator)
[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/OpenAPITools/openapi-generator)
[![Conan Center](https://shields.io/conan/v/openapi-generator)](https://conan.io/center/recipes/openapi-generator)
Expand Down
6 changes: 4 additions & 2 deletions bin/configs/java-feign-no-nullable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
booleanGetterPrefix: is
artifactId: petstore-feign-no-nullable
hideGenerationTimestamp: "true"
hideGenerationTimestamp: true
additionalModelTypeAnnotations: '@javax.annotation.concurrent.Immutable'
openApiNullable: "false"
openApiNullable: false
useReflectionEqualsHashCode: true
annotationLibrary: "swagger1"
3 changes: 2 additions & 1 deletion bin/configs/java-jersey2-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ additionalProperties:
useOneOfDiscriminatorLookup: true
disallowAdditionalPropertiesIfNotPresent: false
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"
failOnUnknownProperties: true
failOnUnknownProperties: true
useReflectionEqualsHashCode: true
3 changes: 2 additions & 1 deletion bin/configs/java-jersey3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ additionalProperties:
useOneOfDiscriminatorLookup: true
disallowAdditionalPropertiesIfNotPresent: false
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"
failOnUnknownProperties: true
failOnUnknownProperties: true
useReflectionEqualsHashCode: true
10 changes: 10 additions & 0 deletions bin/configs/java-microprofile-rest-client-3.0-mutiny.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generatorName: java
outputDir: samples/client/petstore/java/microprofile-rest-client-3.0-mutiny
library: microprofile
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: microprofile-rest-client-3-mutiny
configKey: petstore
microprofileRestClientVersion: "3.0"
microprofileMutiny: true
9 changes: 9 additions & 0 deletions bin/configs/java-microprofile-rest-client-mutiny.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
generatorName: java
outputDir: samples/client/petstore/java/microprofile-rest-client-mutiny
library: microprofile
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: microprofile-rest-client-mutiny
configKeyFromClassName: true
microprofileMutiny: true
1 change: 1 addition & 0 deletions bin/configs/java-native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ additionalProperties:
artifactId: petstore-native
hideGenerationTimestamp: "true"
generateBuilders: true
useReflectionEqualsHashCode: "true"
5 changes: 3 additions & 2 deletions bin/configs/java-okhttp-gson.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ parameterNameMappings:
type_: typeWithUnderscore
additionalProperties:
artifactId: petstore-okhttp-gson
hideGenerationTimestamp: "true"
useOneOfDiscriminatorLookup: "true"
hideGenerationTimestamp: true
useOneOfDiscriminatorLookup: true
disallowAdditionalPropertiesIfNotPresent: false
useReflectionEqualsHashCode:: true
enumNameMappings:
s: LOWER_CASE_S
S: UPPER_CASE_S
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,16 @@ private Schema normalizeAllOfWithProperties(Schema schema, Set<Schema> visitedSc
return schema;
}

// process rule to refactor properties into allOf sub-schema
schema = processRefactorAllOfWithPropertiesOnly(schema);

for (Object item : schema.getAllOf()) {
if (!(item instanceof Schema)) {
throw new RuntimeException("Error! allOf schema is not of the type Schema: " + item);
}
// normalize allOf sub schemas one by one
normalizeSchema((Schema) item, visitedSchemas);
}
// process rules here
schema = processRefactorAllOfWithPropertiesOnly(schema);

return schema;
}
Expand Down Expand Up @@ -1325,9 +1326,8 @@ private Schema processRefactorAllOfWithPropertiesOnly(Schema schema) {
schema.setTitle(null);

// at this point the schema becomes a simple allOf (no properties) with an additional schema containing
// the properties

return schema;
// the properties. Normalize it before returning.
return normalizeSchema(schema, new HashSet<>());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege

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

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

@Override
public OperationsMap postProcessOperationsWithModels(final OperationsMap operationsMap, List<ModelMap> allModels) {
OperationMap operations = operationsMap.getOperations();
final OperationMap operations = operationsMap.getOperations();
operations.put("classnamePascalCase", camelize(operations.getClassname()));
List<CodegenOperation> operationList = operations.getOperation();

for (CodegenOperation op : operationList) {
postProcessOperationWithModels(op);
final boolean hasAuthMethod = operations.getOperation().stream()
.map(this::postProcessOperationWithModels)
.reduce(false, (a, b) -> a || b);
if (hasAuthMethod) {
operations.put("havingAuthMethod", true);
operations.getOperation().forEach(op -> op.vendorExtensions.put("havingAuthMethod", true));
this.havingAuthMethods = true;
}

return operationsMap;
}

private void postProcessOperationWithModels(final CodegenOperation op) {
private boolean postProcessOperationWithModels(final CodegenOperation op) {
boolean consumesJson = false;
boolean consumesPlainText = false;
boolean consumesFormUrlEncoded = false;
boolean hasAuthMethod = false;

if (op.consumes != null) {
for (Map<String, String> consume : op.consumes) {
Expand Down Expand Up @@ -666,17 +672,20 @@ private void postProcessOperationWithModels(final CodegenOperation op) {
for (CodegenSecurity s : op.authMethods) {
if (s.isApiKey && (s.isKeyInCookie || s.isKeyInHeader)) {
if (s.isKeyInCookie) {
op.vendorExtensions.put("x-has-cookie-auth-methods", "true");
op.vendorExtensions.put("x-api-key-cookie-name", toModelName(s.keyParamName));
op.vendorExtensions.put("x-has-cookie-auth-methods", true);
op.vendorExtensions.put("x-api-key-cookie-name", s.keyParamName);
} else {
op.vendorExtensions.put("x-has-header-auth-methods", "true");
op.vendorExtensions.put("x-api-key-header-name", toModelName(s.keyParamName));
op.vendorExtensions.put("x-has-header-auth-methods", true);
op.vendorExtensions.put("x-api-key-header-name", s.keyParamName);
}

op.vendorExtensions.put("x-has-auth-methods", "true");
op.vendorExtensions.put("x-has-auth-methods", true);
hasAuthMethod = true;
}
}
}

return hasAuthMethod;
}

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

return super.postProcessSupportingFileData(bundle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ ext {
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "5.10.2"
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
}

dependencies {
Expand All @@ -148,6 +151,9 @@ dependencies {
{{#useBeanValidation}}
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
{{/useBeanValidation}}
{{#useReflectionEqualsHashCode}}
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/useReflectionEqualsHashCode}}
testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ ext {
feign_form_version = "3.8.0"
junit_version = "5.7.0"
scribejava_version = "8.0.0"
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
}

dependencies {
Expand All @@ -127,9 +130,9 @@ dependencies {
implementation "io.github.openfeign:feign-okhttp:$feign_version"
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
{{#jackson}}
{{#joda}}
{{#joda}}
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
{{/joda}}
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
Expand All @@ -142,6 +145,9 @@ dependencies {
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
implementation "com.brsanthu:migbase64:2.2"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
{{#useReflectionEqualsHashCode}}
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/useReflectionEqualsHashCode}}
testImplementation "org.junit.jupiter:junit-jupiter:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ lazy val root = (project in file(".")).
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
"com.brsanthu" % "migbase64" % "2.2" % "compile",
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
{{#useReflectionEqualsHashCode}}
"org.apache.commons" % "commons-lang3" % "3.17.0" % "compile",
{{/useReflectionEqualsHashCode}}
"org.junit.jupiter" % "junit-jupiter" % "5.7.0" % "test",
"org.junit.jupiter" % "junit-jupiter-params" % "5.7.0" % "test",
"com.github.tomakehurst" % "wiremock-jre8" % "2.35.1" % "test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@
<scope>provided</scope>
</dependency>
{{/useBeanValidation}}
{{#useReflectionEqualsHashCode}}
<!-- For equals and hashCode using reflection -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3-version}</version>
</dependency>
{{/useReflectionEqualsHashCode}}

<!-- test dependencies -->
<dependency>
Expand Down Expand Up @@ -409,6 +417,9 @@
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>2.0.2</beanvalidation-version>
{{/useJakartaEe}}
{{#useReflectionEqualsHashCode}}
<commons-lang3-version>3.17.0</commons-lang3-version>
{{/useReflectionEqualsHashCode}}
<junit-version>5.10.0</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<scribejava-version>8.3.3</scribejava-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ ext {
{{#hasHttpSignatureMethods}}
tomitribe_http_signatures_version = "1.7"
{{/hasHttpSignatureMethods}}
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
}

dependencies {
Expand Down Expand Up @@ -146,6 +149,9 @@ dependencies {
{{#useBeanValidation}}
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
{{/useBeanValidation}}
{{#useReflectionEqualsHashCode}}
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/useReflectionEqualsHashCode}}
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ lazy val root = (project in file(".")).
"org.tomitribe" % "tomitribe-http-signatures" % "1.7" % "compile",
{{/hasHttpSignatureMethods}}
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
{{#useReflectionEqualsHashCode}}
"org.apache.commons" % "commons-lang3" % "3.17.0" % "compile",
{{/useReflectionEqualsHashCode}}
"org.junit.jupiter" % "junit-jupiter-api" % "5.8.2" % "test"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@
<artifactId>jersey-apache-connector</artifactId>
<version>${jersey-version}</version>
</dependency>
{{#useReflectionEqualsHashCode}}
<!-- For equals and hashCode using reflection -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3-version}</version>
</dependency>
{{/useReflectionEqualsHashCode}}
<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -414,6 +423,9 @@
{{#hasOAuthMethods}}
<scribejava-apis-version>8.3.3</scribejava-apis-version>
{{/hasOAuthMethods}}
{{#useReflectionEqualsHashCode}}
<commons-lang3-version>3.17.0</commons-lang3-version>
{{/useReflectionEqualsHashCode}}
<spotless.version>2.21.0</spotless.version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ ext {
{{#hasHttpSignatureMethods}}
tomitribe_http_signatures_version = "1.7"
{{/hasHttpSignatureMethods}}
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
}

dependencies {
Expand Down Expand Up @@ -146,6 +149,9 @@ dependencies {
{{#useBeanValidation}}
implementation "jakarta.validation:jakarta.validation-api:$bean_validation_version"
{{/useBeanValidation}}
{{#useReflectionEqualsHashCode}}
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/useReflectionEqualsHashCode}}

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ lazy val root = (project in file(".")).
"org.tomitribe" % "tomitribe-http-signatures" % "1.7" % "compile",
{{/hasHttpSignatureMethods}}
"jakarta.annotation" % "jakarta.annotation-api" % "2.1.0" % "compile",
{{#useReflectionEqualsHashCode}}
"org.apache.commons" % "commons-lang3" % "3.17.0" % "compile",
{{/useReflectionEqualsHashCode}}
"org.junit.jupiter" % "junit-jupiter-api" % "5.8.2" % "test"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@
<artifactId>jersey-apache-connector</artifactId>
<version>${jersey-version}</version>
</dependency>
{{#useReflectionEqualsHashCode}}
<!-- For equals and hashCode using reflection -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3-version}</version>
</dependency>
{{/useReflectionEqualsHashCode}}
<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -408,6 +417,9 @@
{{#hasOAuthMethods}}
<scribejava-apis-version>8.3.3</scribejava-apis-version>
{{/hasOAuthMethods}}
{{#useReflectionEqualsHashCode}}
<commons-lang3-version>3.17.0</commons-lang3-version>
{{/useReflectionEqualsHashCode}}
<spotless.version>2.21.0</spotless.version>
</properties>
</project>
Loading

0 comments on commit 8629c7f

Please sign in to comment.