Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into phpnextgen_client…
Browse files Browse the repository at this point in the history
…_builder
  • Loading branch information
ybelenko committed May 9, 2024
2 parents d35f080 + 29cfa33 commit c366840
Show file tree
Hide file tree
Showing 747 changed files with 21,038 additions and 5,615 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/samples-java-server-jdk8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ on:
- 'samples/server/petstore/java-pkmst/**'
# test in circleci instead
- 'samples/server/petstore/java-undertow/**'
- 'samples/server/petstore/java-microprofile/**'
pull_request:
paths:
#- 'samples/server/petstore/java-camel/**'
- 'samples/server/petstore/java-vertx-web/**'
- 'samples/server/petstore/java-inflector/**'
- 'samples/server/petstore/java-pkmst/**'
#- 'samples/server/petstore/java-undertow/**'
- 'samples/server/petstore/java-microprofile/**'
jobs:
build:
name: Build Java Server
Expand All @@ -31,6 +33,7 @@ jobs:
- samples/server/petstore/java-inflector/
- samples/server/petstore/java-pkmst/
#- samples/server/petstore/java-undertow/
- samples/server/petstore/java-microprofile/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generatorName: cpp-pistache-server
outputDir: samples/server/petstore/cpp-pistache-nested-schema-refs
inputSpec: modules/openapi-generator/src/test/resources/3_0/nested-schema-refs.yaml
templateDir: modules/openapi-generator/src/main/resources/cpp-pistache-server
additionalProperties:
useStructModel: "false"
addExternalLibs: "true"
4 changes: 2 additions & 2 deletions bin/configs/java-microprofile-rest-client.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
generatorName: java
outputDir: samples/client/petstore/java/microprofile-rest-client
library: microprofile
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: microprofile-rest-client
configKey: petstore
configKeyFromClassName: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generatorName: java-microprofile
outputDir: samples/server/petstore/java-microprofile
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-multiple-2xx-responses.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
hideGenerationTimestamp: "true"
microprofileMutiny: "true"
serializationLibrary: "jackson"
2 changes: 1 addition & 1 deletion bin/configs/jaxrs-spec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/jaxrs-spec/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-petstore-server
Expand Down
9 changes: 9 additions & 0 deletions bin/configs/manual/rust-axum-header-uuid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
generatorName: rust-axum
outputDir: samples/server/petstore/rust-axum/output/rust-axum-header-uuid
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust-axum/rust-axum-header-uuid.yaml
templateDir: modules/openapi-generator/src/main/resources/rust-axum
generateAliasAsModel: true
additionalProperties:
hideGenerationTimestamp: "true"
packageName: rust-axum-header-uui
enablePostProcessFile: true
10 changes: 10 additions & 0 deletions bin/configs/manual/rust-axum-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generatorName: rust-axum
outputDir: samples/server/petstore/rust-axum/output/rust-axum-validation-test
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-axum-validation-test.yaml
templateDir: modules/openapi-generator/src/main/resources/rust-axum
generateAliasAsModel: true
additionalProperties:
hideGenerationTimestamp: "true"
packageName: rust-axum-validation-test
disableValidator: "true"
enablePostProcessFile: true
File renamed without changes.
1 change: 1 addition & 0 deletions docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ The following generators are available:
* [java-helidon-server (beta)](generators/java-helidon-server.md)
* [java-inflector](generators/java-inflector.md)
* [java-micronaut-server (beta)](generators/java-micronaut-server.md)
* [java-microprofile](generators/java-microprofile.md)
* [java-msf4j](generators/java-msf4j.md)
* [java-pkmst](generators/java-pkmst.md)
* [java-play-framework](generators/java-play-framework.md)
Expand Down
364 changes: 364 additions & 0 deletions docs/generators/java-microprofile.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/generators/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|configKey|Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option.| |null|
|configKeyFromClassName|If true, set tag as key in @RegisterRestClient. Default to false. Only `microprofile` supports this option.| |null|
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
Expand Down
4 changes: 1 addition & 3 deletions modules/openapi-generator-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,7 @@ openApiGenerate {
apiPackage.set("org.openapi.example.api")
invokerPackage.set("org.openapi.example.invoker")
modelPackage.set("org.openapi.example.model")
configOptions.set([
dateLibrary: "java8"
])
configOptions.put("dateLibrary", "java8")
}
----

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions modules/openapi-generator-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

<properties>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
<gradleVersion>7.6</gradleVersion>
<gradle-tooling.version>7.3-20210825160000+0000</gradle-tooling.version>
<gradleVersion>7.6.4</gradleVersion>
<gradle-tooling.version>7.4.2</gradle-tooling.version>
</properties>

<pluginRepositories>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GenerateTaskConfigurationCacheTest : TestBase() {
}

@DataProvider(name = "gradle_version_provider")
private fun gradleVersionProviderWithConfigurationCache(): Array<Array<String>> = arrayOf(arrayOf("8.1.1"), arrayOf("7.6"))
private fun gradleVersionProviderWithConfigurationCache(): Array<Array<String>> = arrayOf(arrayOf("8.7"), arrayOf("7.6.4"))

@DataProvider(name = "gradle_version_provider_without_cc")
private fun gradleVersionProviderWithoutConfigurationCache(): Array<Array<String>> = arrayOf(arrayOf("5.6.1"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GenerateTaskFromCacheTest : TestBase() {
}

@DataProvider(name = "gradle_version_provider")
private fun gradleVersionProvider(): Array<Array<String>> = arrayOf(arrayOf("8.1.1"), arrayOf("7.6"))
private fun gradleVersionProvider(): Array<Array<String>> = arrayOf(arrayOf("8.7"), arrayOf("7.6.4"))

// inputSpec tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.test.assertEquals
class GenerateTaskUpToDateTest : TestBase() {

@DataProvider(name = "gradle_version_provider")
private fun gradleVersionProvider(): Array<Array<String>> = arrayOf(arrayOf("8.1.1"), arrayOf("7.6"))
private fun gradleVersionProvider(): Array<Array<String>> = arrayOf(arrayOf("8.7"), arrayOf("7.6.4"))

// inputSpec tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ValidateTaskDslTest : TestBase() {
@DataProvider(name = "gradle_version_provider")
fun gradleVersionProvider(): Array<Array<String?>> = arrayOf(
arrayOf(null), // uses the version of Gradle used to build the plugin itself
arrayOf("8.1.1"),
arrayOf("7.6")
arrayOf("8.7"),
arrayOf("7.6.4")
)

private fun getGradleRunner(gradleVersion: String?): GradleRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
<jodatime-version>2.7</jodatime-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.13.2</junit-version>
<junit-version>5.10.2</junit-version>
<http-signature-version>1.4</http-signature-version>
</properties>
</project>
4 changes: 2 additions & 2 deletions modules/openapi-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.openapitools.codegen.plugin;

import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.File;
import java.nio.file.Files;
Expand Down
4 changes: 2 additions & 2 deletions modules/openapi-generator-online/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.openapitools.codegen.online.api;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openapitools.codegen.online.model.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;

import static org.hamcrest.Matchers.hasItem;
Expand All @@ -18,7 +18,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebMvcTest(GenApiController.class)
public class GenApiControllerTest {

Expand Down
8 changes: 7 additions & 1 deletion modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,16 @@
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit4</artifactId>
<artifactId>archunit-junit5</artifactId>
<version>${archunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2492,10 +2492,10 @@ protected String getSingleSchemaType(Schema schema) {
private String getPrimitiveType(Schema schema) {
if (schema == null) {
throw new RuntimeException("schema cannot be null in getPrimitiveType");
} else if (typeMapping.containsKey(schema.getType() + "+" + schema.getFormat())) {
} else if (typeMapping.containsKey(ModelUtils.getType(schema) + "+" + schema.getFormat())) {
// allows custom type_format mapping.
// use {type}+{format}
return typeMapping.get(schema.getType() + "+" + schema.getFormat());
return typeMapping.get(ModelUtils.getType(schema) + "+" + schema.getFormat());
} else if (ModelUtils.isNullType(schema)) {
// The 'null' type is allowed in OAS 3.1 and above. It is not supported by OAS 3.0.x,
// though this tooling supports it.
Expand Down Expand Up @@ -2536,7 +2536,7 @@ private String getPrimitiveType(Schema schema) {
} else if (ModelUtils.isShortSchema(schema)) {// int32
return "integer";
} else {
return schema.getType(); // integer
return ModelUtils.getType(schema); // integer
}
} else if (ModelUtils.isMapSchema(schema)) {
return "map";
Expand Down Expand Up @@ -2567,11 +2567,11 @@ private String getPrimitiveType(Schema schema) {
return "object";
} else if (ModelUtils.isAnyType(schema)) {
return "AnyType";
} else if (StringUtils.isNotEmpty(schema.getType())) {
if (!schemaMapping.containsKey(schema.getType())) {
LOGGER.warn("Unknown type found in the schema: {}. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)", schema.getType());
} else if (StringUtils.isNotEmpty(ModelUtils.getType(schema))) {
if (!schemaMapping.containsKey(ModelUtils.getType(schema))) {
LOGGER.warn("Unknown type found in the schema: {}. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)", ModelUtils.getType(schema));
}
return schema.getType();
return ModelUtils.getType(schema);
}
// The 'type' attribute has not been set in the OAS schema, which means the value
// can be an arbitrary type, e.g. integer, string, object, array, number...
Expand Down Expand Up @@ -4019,10 +4019,10 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo

property.name = toVarName(name);
property.baseName = name;
if (p.getType() == null) {
if (ModelUtils.getType(p) == null) {
property.openApiType = getSchemaType(p);
} else {
property.openApiType = p.getType();
property.openApiType = ModelUtils.getType(p);
}
property.nameInPascalCase = camelize(property.name);
property.nameInCamelCase = camelize(property.name, LOWERCASE_FIRST_LETTER);
Expand Down Expand Up @@ -7128,7 +7128,7 @@ public List<CodegenParameter> fromRequestBodyToFormParameters(RequestBody body,
Schema original = null;
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
if (ModelUtils.isAllOf(schema) && schema.getAllOf().size() == 1 &&
schema.getType() == null && schema.getTypes() == null) {
ModelUtils.getType(schema) == null) {
if (schema.getAllOf().get(0) instanceof Schema) {
original = schema;
schema = (Schema) schema.getAllOf().get(0);
Expand Down Expand Up @@ -7781,7 +7781,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
Schema original = null;
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
if (ModelUtils.isAllOf(schema) && schema.getAllOf().size() == 1 &&
schema.getType() == null && schema.getTypes() == null) {
ModelUtils.getType(schema) == null) {
if (schema.getAllOf().get(0) instanceof Schema) {
original = schema;
schema = (Schema) schema.getAllOf().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ public void processOpts() {
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
importMapping.put("JsonIgnoreProperties", "com.fasterxml.jackson.annotation.JsonIgnoreProperties");
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable");
if (openApiNullable) {
importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable");
}
importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
importMapping.put("TypeAdapter", "com.google.gson.TypeAdapter");
importMapping.put("JsonAdapter", "com.google.gson.annotations.JsonAdapter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,14 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
}
if (operation.getParameters() != null) {
for (Parameter parameter : operation.getParameters()) {
if (StringUtils.isNotEmpty(parameter.get$ref())) {
parameter = ModelUtils.getReferencedParameter(openAPI, parameter);
}
String swaggerParameterName = parameter.getName();
String pythonParameterName = this.toParamName(swaggerParameterName);
if (swaggerParameterName == null) {
throw new RuntimeException("Please report the issue as the parameter name cannot be null: " + parameter);
}
if (!swaggerParameterName.equals(pythonParameterName)) {
LOGGER.warn(
"Parameter name '{}' is not consistent with Python variable names. It will be replaced by '{}'",
Expand Down
Loading

0 comments on commit c366840

Please sign in to comment.