diff --git a/bin/configs/java-resttemplate.yaml b/bin/configs/java-resttemplate.yaml
index 9c61a34ba90..477b09658db 100644
--- a/bin/configs/java-resttemplate.yaml
+++ b/bin/configs/java-resttemplate.yaml
@@ -7,3 +7,4 @@ additionalProperties:
artifactId: petstore-resttemplate
hideGenerationTimestamp: "true"
java8: true
+ containerDefaultToNull: true
diff --git a/bin/configs/java-webclient.yaml b/bin/configs/java-webclient.yaml
index a78b3f5e47d..d05ea4bc14b 100644
--- a/bin/configs/java-webclient.yaml
+++ b/bin/configs/java-webclient.yaml
@@ -6,3 +6,4 @@ templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: petstore-webclient
hideGenerationTimestamp: "true"
+ containerDefaultToNull: "true"
diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md
index d42218a5f56..6fb7665f64d 100644
--- a/docs/generators/groovy.md
+++ b/docs/generators/groovy.md
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md
index 0acffa5698b..d704c3b68a1 100644
--- a/docs/generators/java-camel.md
+++ b/docs/generators/java-camel.md
@@ -42,6 +42,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|camelUseDefaultValidationErrorProcessor|generate default validation error processor| |true|
|camelValidationErrorProcessor|validation error processor bean name| |validationErrorProcessor|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md
index 5d4fb37757f..485eb65eac1 100644
--- a/docs/generators/java-helidon-client.md
+++ b/docs/generators/java-helidon-client.md
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configKey|Config key in @RegisterRestClient. Default to none.| |null|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true|
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md
index 9fd013b114c..276a7ebc863 100644
--- a/docs/generators/java-helidon-server.md
+++ b/docs/generators/java-helidon-server.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|
**false**
The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
**true**
Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true|
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md
index c99e23f5f04..d1d6d4ae89f 100644
--- a/docs/generators/java-inflector.md
+++ b/docs/generators/java-inflector.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md
index 7078d72c7e4..2d5e5585050 100644
--- a/docs/generators/java-micronaut-client.md
+++ b/docs/generators/java-micronaut-client.md
@@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|build|Specify for which build tool to generate files|
**gradle**
Gradle configuration is generated for the project
**all**
Both Gradle and Maven configurations are generated
**maven**
Maven configuration is generated for the project
|all|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configureAuth|Configure all the authorization methods as specified in the file| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateFormat|Specify the format pattern of date as a string| |null|
|dateLibrary|Option. Date library to use|
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|datetimeFormat|Specify the format pattern of date-time as a string| |null|
diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md
index ce3c74cf026..5aecff1e6a0 100644
--- a/docs/generators/java-micronaut-server.md
+++ b/docs/generators/java-micronaut-server.md
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|build|Specify for which build tool to generate files|
**gradle**
Gradle configuration is generated for the project
**all**
Both Gradle and Maven configurations are generated
**maven**
Maven configuration is generated for the project
|all|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|controllerPackage|The package in which controllers will be generated| |org.openapitools.api|
|dateFormat|Specify the format pattern of date as a string| |null|
|dateLibrary|Option. Date library to use|
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md
index 685e0357e72..7d4532cab34 100644
--- a/docs/generators/java-msf4j.md
+++ b/docs/generators/java-msf4j.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md
index 30a48087f16..0a5ee14c224 100644
--- a/docs/generators/java-pkmst.md
+++ b/docs/generators/java-pkmst.md
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md
index 3fcaa8449c5..e41abb5b575 100644
--- a/docs/generators/java-play-framework.md
+++ b/docs/generators/java-play-framework.md
@@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|controllerOnly|Whether to generate only API interface stubs without the server files.| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md
index cf0eaf29204..a4a74abd19a 100644
--- a/docs/generators/java-undertow-server.md
+++ b/docs/generators/java-undertow-server.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md
index 0d46a523a50..93f60ef39ca 100644
--- a/docs/generators/java-vertx-web.md
+++ b/docs/generators/java-vertx-web.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md
index a919b2b4045..063da873d5b 100644
--- a/docs/generators/java-vertx.md
+++ b/docs/generators/java-vertx.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/java.md b/docs/generators/java.md
index 3a5aea732c4..3b299ddbd5f 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -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|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md
index 8e857d9fead..aac09068b9b 100644
--- a/docs/generators/jaxrs-cxf-cdi.md
+++ b/docs/generators/jaxrs-cxf-cdi.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md
index ee6f46499da..a9f89032ebe 100644
--- a/docs/generators/jaxrs-cxf-client.md
+++ b/docs/generators/jaxrs-cxf-client.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md
index 88bad1716bc..dc00f40d577 100644
--- a/docs/generators/jaxrs-cxf-extended.md
+++ b/docs/generators/jaxrs-cxf-extended.md
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md
index 414843f9b37..f1b0b294f79 100644
--- a/docs/generators/jaxrs-cxf.md
+++ b/docs/generators/jaxrs-cxf.md
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md
index 9a8da73eee2..be59dac624b 100644
--- a/docs/generators/jaxrs-jersey.md
+++ b/docs/generators/jaxrs-jersey.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md
index d2802b42e82..0f5e5eed3d0 100644
--- a/docs/generators/jaxrs-resteasy-eap.md
+++ b/docs/generators/jaxrs-resteasy-eap.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md
index 6f86b8a6427..ce4320fc60d 100644
--- a/docs/generators/jaxrs-resteasy.md
+++ b/docs/generators/jaxrs-resteasy.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md
index b043a13b824..076c45813a1 100644
--- a/docs/generators/jaxrs-spec.md
+++ b/docs/generators/jaxrs-spec.md
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|legacy|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/docs/generators/spring.md b/docs/generators/spring.md
index e6fb7565584..a15382a171e 100644
--- a/docs/generators/spring.md
+++ b/docs/generators/spring.md
@@ -35,6 +35,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
|configPackage|configuration package for generated code| |org.openapitools.configuration|
+|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+)
|java8|
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index d0cd1f0e5fd..b6ab78eac51 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -2188,6 +2188,21 @@ public class DefaultCodegen implements CodegenConfig {
return " = data." + name + ";";
}
+ /**
+ * Return the default value of the property
+ *
+ * Return null if you do NOT want a default value.
+ * Any non-null value will cause {{#defaultValue} check to pass.
+ *
+ * @param schema Property schema
+ * @param codegenProperty Codegen property
+ * @return string presentation of the default value of the property
+ */
+ public String toDefaultValue(CodegenProperty codegenProperty, Schema schema) {
+ // use toDefaultValue(schema) if generator has not overriden this method
+ return toDefaultValue(schema);
+ }
+
/**
* returns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type
*
@@ -3786,8 +3801,7 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.debug("Exception from toExampleValue: {}", e.getMessage());
property.example = "ERROR_TO_EXAMPLE_VALUE";
}
- property.defaultValue = toDefaultValue(p);
- property.defaultValueWithParam = toDefaultValueWithParam(name, p);
+
property.jsonSchema = Json.pretty(p);
if (p.getDeprecated() != null) {
@@ -3939,6 +3953,10 @@ public class DefaultCodegen implements CodegenConfig {
property.isModel = (ModelUtils.isComposedSchema(referencedSchema) || ModelUtils.isObjectSchema(referencedSchema)) && ModelUtils.isModel(referencedSchema);
}
+ // set the default value
+ property.defaultValue = toDefaultValue(property, p);
+ property.defaultValueWithParam = toDefaultValueWithParam(name, p);
+
LOGGER.debug("debugging from property return: {}", property);
schemaCodegenPropertyCache.put(ns, property);
return property;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
index fd709d11eb6..8a2fdf7aa89 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
@@ -85,6 +85,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String IMPLICIT_HEADERS_REGEX = "implicitHeadersRegex";
public static final String JAVAX_PACKAGE = "javaxPackage";
public static final String USE_JAKARTA_EE = "useJakartaEe";
+ public static final String CONTAINER_DEFAULT_TO_NULL = "containerDefaultToNull";
public static final String CAMEL_CASE_DOLLAR_SIGN = "camelCaseDollarSign";
@@ -137,9 +138,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected AnnotationLibrary annotationLibrary;
protected boolean implicitHeaders = false;
protected String implicitHeadersRegex = null;
-
protected boolean camelCaseDollarSign = false;
protected boolean useJakartaEe = false;
+ protected boolean containerDefaultToNull = false;
private Map schemaKeyToModelNameCache = new HashMap<>();
@@ -276,6 +277,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
cliOptions.add(CliOption.newString(IMPLICIT_HEADERS_REGEX, "Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true"));
cliOptions.add(CliOption.newBoolean(CAMEL_CASE_DOLLAR_SIGN, "Fix camelCase when starting with $ sign. when true : $Value when false : $value"));
cliOptions.add(CliOption.newBoolean(USE_JAKARTA_EE, "whether to use Jakarta EE namespace instead of javax"));
+ cliOptions.add(CliOption.newBoolean(CONTAINER_DEFAULT_TO_NULL, "Set containers (array, set, map) default to null"));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_ARTIFACT_ID, CodegenConstants.PARENT_ARTIFACT_ID_DESC));
@@ -686,6 +688,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} else {
applyJavaxPackage();
}
+
+ if (additionalProperties.containsKey(CONTAINER_DEFAULT_TO_NULL)) {
+ this.setContainerDefaultToNull(Boolean.parseBoolean(additionalProperties.get(CONTAINER_DEFAULT_TO_NULL).toString()));
+ }
+ additionalProperties.put(CONTAINER_DEFAULT_TO_NULL, containerDefaultToNull);
}
@Override
@@ -966,20 +973,84 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return name;
}
+ /**
+ * Return the default value of array property
+ *
+ * Return null if there's no default value.
+ * Any non-null value will cause {{#defaultValue} check to pass.
+ *
+ * @param cp Codegen property
+ * @param schema Property schema
+ * @return string presentation of the default value of the property
+ */
+ public String toArrayDefaultValue(CodegenProperty cp, Schema schema) {
+ if (schema.getDefault() != null) { // has default value
+ if (cp.isArray && !cp.getUniqueItems()) { // array
+ List _values = new ArrayList<>();
+
+ if (schema.getDefault() instanceof ArrayNode) { // array of default values
+ ArrayNode _default = (ArrayNode) schema.getDefault();
+ if (_default.isEmpty()) {
+ return "null";
+ }
+
+ List final_values = _values;
+ _default.elements().forEachRemaining((element) -> {
+ final_values.add(element.asText());
+ });
+ } else { // single value
+ _values = java.util.Collections.singletonList(String.valueOf(schema.getDefault()));
+ }
+
+ String defaultValue = "";
+
+ if (cp.items.isEnum) { // enum
+ List defaultValues = new ArrayList<>();
+ for (String _value : _values) {
+ defaultValues.add(cp.items.datatypeWithEnum + "." + toEnumVarName(_value, cp.items.dataType));
+ }
+ defaultValue = StringUtils.join(defaultValues, ", ");
+ } else {
+ if (cp.items.isString) { // array item is string
+ defaultValue = String.format(Locale.ROOT, "\"%s\"", StringUtils.join(_values, "\", \""));
+ } else { // array item is non-string, e.g. integer
+ defaultValue = StringUtils.join(_values, ", ");
+ }
+ }
+ return String.format(Locale.ROOT, "new ArrayList<>(Arrays.asList(%s))", defaultValue);
+ } else if (cp.isArray && cp.getUniqueItems()) { // set
+ // TODO
+ return null;
+ } else if (cp.isMap) { // map
+ // TODO
+ return null;
+ } else {
+ throw new RuntimeException("Error. Codegen Property must be array/set/map: " + cp);
+ }
+ } else {
+ return null;
+ }
+ }
+
@Override
- public String toDefaultValue(Schema schema) {
+ public String toDefaultValue(CodegenProperty cp, Schema schema) {
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (ModelUtils.isArraySchema(schema)) {
- final String pattern;
- if (ModelUtils.isSet(schema)) {
- String mapInstantiationType = instantiationTypes().getOrDefault("set", "LinkedHashSet");
- pattern = "new " + mapInstantiationType + "<%s>()";
- } else {
- String arrInstantiationType = instantiationTypes().getOrDefault("array", "ArrayList");
- pattern = "new " + arrInstantiationType + "<%s>()";
+ if (schema.getDefault() == null) {
+ if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
+ return "null";
+ } else {
+ if (ModelUtils.isSet(schema)) {
+ return String.format(Locale.ROOT, "new %s<>()",
+ instantiationTypes().getOrDefault("set", "LinkedHashSet"));
+ } else {
+ return String.format(Locale.ROOT, "new %s<>()",
+ instantiationTypes().getOrDefault("array", "ArrayList"));
+ }
+ }
+ } else { // has default value
+ return toArrayDefaultValue(cp, schema);
}
-
- return String.format(Locale.ROOT, pattern, "");
} else if (ModelUtils.isMapSchema(schema) && !(schema instanceof ComposedSchema)) {
if (schema.getProperties() != null && schema.getProperties().size() > 0) {
// object is complex object with free-form additional properties
@@ -989,14 +1060,16 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
return null;
}
- String mapInstantiationType = instantiationTypes().getOrDefault("map", "HashMap");
- final String pattern = "new " + mapInstantiationType + "<%s>()";
+ if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
+ return "null";
+ }
if (getAdditionalProperties(schema) == null) {
return null;
}
- return String.format(Locale.ROOT, pattern, "");
+ return String.format(Locale.ROOT, "new %s<>()",
+ instantiationTypes().getOrDefault("map", "HashMap"));
} else if (ModelUtils.isIntegerSchema(schema)) {
if (schema.getDefault() != null) {
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(schema.getFormat())) {
@@ -1963,6 +2036,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.useJakartaEe = useJakartaEe;
}
+ public void setContainerDefaultToNull(boolean containerDefaultToNull) {
+ this.containerDefaultToNull = containerDefaultToNull;
+ }
+
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache
index 82e5582a11e..64ea0694fe8 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache
@@ -83,7 +83,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
- private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
+ private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
@@ -148,7 +148,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
if (this.{{name}} == null) {
- this.{{name}} = {{{defaultValue}}};
+ this.{{name}} = new ArrayList<>();
}
{{/required}}
this.{{name}}.add({{name}}Item);
diff --git a/modules/openapi-generator/src/main/resources/Java/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/pojo.mustache
index 45c8174e4d4..94ef14a7e2a 100644
--- a/modules/openapi-generator/src/main/resources/Java/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/pojo.mustache
@@ -84,7 +84,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
- private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
+ private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}};
{{/isContainer}}
{{^isContainer}}
{{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
@@ -111,7 +111,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#jsonb}}@JsonbCreator{{/jsonb}}{{#jackson}}@JsonCreator{{/jackson}}
public {{classname}}(
{{#readOnlyVars}}
- {{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nillable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
+ {{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nullable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
{{/readOnlyVars}}
) {
this();
@@ -134,7 +134,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
- this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
+ this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}});
}
try {
this.{{name}}.get().add({{name}}Item);
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java
index 0e2817fd9b5..22c55a4dba1 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java
@@ -23,14 +23,9 @@ import io.swagger.v3.oas.models.media.*;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
-import org.openapitools.codegen.CodegenConstants;
-import org.openapitools.codegen.CodegenModel;
-import org.openapitools.codegen.CodegenParameter;
-import org.openapitools.codegen.CodegenType;
-import org.openapitools.codegen.TestUtils;
+import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.openapitools.codegen.utils.ModelUtils;
import org.testng.Assert;
@@ -39,10 +34,6 @@ import org.testng.annotations.Test;
import java.io.File;
import java.time.LocalDate;
import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Collections;
public class AbstractJavaCodegenTest {
@@ -564,24 +555,31 @@ public class AbstractJavaCodegenTest {
codegen.setDateLibrary("legacy");
String defaultValue;
- // Test default value for date format
+ // Test default value for date format (DateSchema)
DateSchema dateSchema = new DateSchema();
- LocalDate defaultLocalDate = LocalDate.of(2019, 2, 15);
+
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ LocalDate defaultLocalDate = LocalDate.of(2021, 5, 23);
Date date = Date.from(defaultLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ Assert.assertEquals(date.toString(), "Sun May 23 00:00:00 UTC 2021");
+
dateSchema.setDefault(date);
defaultValue = codegen.toDefaultValue(dateSchema);
// dateLibrary <> java8
- Assert.assertNull(defaultValue);
+ Assert.assertEquals(defaultValue, "Sun May 23 00:00:00 UTC 2021");
+ // Test default value for date format (DateTimeSchema)
DateTimeSchema dateTimeSchema = new DateTimeSchema();
- OffsetDateTime defaultDateTime = OffsetDateTime.parse("1984-12-19T03:39:57-08:00");
- ZonedDateTime expectedDateTime = defaultDateTime.atZoneSameInstant(ZoneId.systemDefault());
+
+ OffsetDateTime defaultDateTime = OffsetDateTime.parse("1984-12-19T03:39:57-09:00");
+ Assert.assertEquals(defaultDateTime.toString(), "1984-12-19T03:39:57-09:00");
+
dateTimeSchema.setDefault(defaultDateTime);
defaultValue = codegen.toDefaultValue(dateTimeSchema);
// dateLibrary <> java8
- Assert.assertNull(defaultValue);
+ Assert.assertEquals(defaultValue, "1984-12-19T03:39:57-09:00");
}
@Test
@@ -592,7 +590,7 @@ public class AbstractJavaCodegenTest {
Schema> schema = createObjectSchemaWithMinItems();
String defaultValue = codegen.toDefaultValue(schema);
- Assert.assertNull(defaultValue);
+ Assert.assertEquals(defaultValue, "null");
// Create an alias to an array schema
Schema> nestedArraySchema = new ArraySchema().items(new IntegerSchema().format("int32"));
@@ -602,22 +600,22 @@ public class AbstractJavaCodegenTest {
schema = new ArraySchema().items(new Schema().$ref("#/components/schemas/NestedArray"));
ModelUtils.setGenerateAliasAsModel(false);
- defaultValue = codegen.toDefaultValue(schema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), schema);
Assert.assertEquals(defaultValue, "new ArrayList<>()");
ModelUtils.setGenerateAliasAsModel(true);
- defaultValue = codegen.toDefaultValue(schema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), schema);
Assert.assertEquals(defaultValue, "new ArrayList<>()");
// Create a map schema with additionalProperties type set to array alias
schema = new MapSchema().additionalProperties(new Schema().$ref("#/components/schemas/NestedArray"));
ModelUtils.setGenerateAliasAsModel(false);
- defaultValue = codegen.toDefaultValue(schema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), schema);
Assert.assertEquals(defaultValue, "new HashMap<>()");
ModelUtils.setGenerateAliasAsModel(true);
- defaultValue = codegen.toDefaultValue(schema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), schema);
Assert.assertEquals(defaultValue, "new HashMap<>()");
// Test default value for date format
@@ -625,26 +623,26 @@ public class AbstractJavaCodegenTest {
LocalDate defaultLocalDate = LocalDate.of(2019, 2, 15);
Date date = Date.from(defaultLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
dateSchema.setDefault(date);
- defaultValue = codegen.toDefaultValue(dateSchema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), dateSchema);
Assert.assertEquals(defaultValue, "LocalDate.parse(\"" + defaultLocalDate.toString() + "\")");
DateTimeSchema dateTimeSchema = new DateTimeSchema();
OffsetDateTime defaultDateTime = OffsetDateTime.parse("1984-12-19T03:39:57-08:00");
ZonedDateTime expectedDateTime = defaultDateTime.atZoneSameInstant(ZoneId.systemDefault());
dateTimeSchema.setDefault(defaultDateTime);
- defaultValue = codegen.toDefaultValue(dateTimeSchema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), dateTimeSchema);
Assert.assertTrue(defaultValue.startsWith("OffsetDateTime.parse(\"" + expectedDateTime.toString()));
// Test default value for number without format
NumberSchema numberSchema = new NumberSchema();
Double doubleValue = 100.0;
numberSchema.setDefault(doubleValue);
- defaultValue = codegen.toDefaultValue(numberSchema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), numberSchema);
Assert.assertEquals(defaultValue, "new BigDecimal(\"" + doubleValue + "\")");
// Test default value for number with format set to double
numberSchema.setFormat("double");
- defaultValue = codegen.toDefaultValue(numberSchema);
+ defaultValue = codegen.toDefaultValue(codegen.fromProperty("", schema), numberSchema);
Assert.assertEquals(defaultValue, doubleValue + "d");
}
@@ -811,7 +809,7 @@ public class AbstractJavaCodegenTest {
Assert.assertNull(cm.defaultValue, "Expected no defined default value in spec");
String defaultValue = codegen.toDefaultValue(schema);
- Assert.assertNull(defaultValue);
+ Assert.assertEquals(defaultValue, "null");
}
@Test
@@ -827,7 +825,7 @@ public class AbstractJavaCodegenTest {
Assert.assertNull(cm.defaultValue, "Expected no defined default value in spec");
String defaultValue = codegen.toDefaultValue(schema);
- Assert.assertEquals(defaultValue, "new HashMap<>()", "Expected string-string map aliased model to default to new HashMap()");
+ Assert.assertEquals(defaultValue, "null", "Expected string-string map aliased model to default to null since nullable is not set to true");
}
@Test
@@ -843,7 +841,7 @@ public class AbstractJavaCodegenTest {
Assert.assertNull(cm.defaultValue, "Expected no defined default value in spec");
String defaultValue = codegen.toDefaultValue(schema);
- Assert.assertEquals(defaultValue, "new HashMap<>()", "Expected string-ref map aliased model to default to new HashMap()");
+ Assert.assertEquals(defaultValue, "null", "Expected string-ref map aliased model to default to null since nullable is not set to tru");
}
@Test
diff --git a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
index 82bfa963c10..3a1fb1d13a5 100644
--- a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
@@ -288,6 +288,47 @@ components:
- sold
xml:
name: pet
+ DefaultValue:
+ type: object
+ description: to test the default value of properties
+ properties:
+ array_string_enum_default:
+ type: array
+ items:
+ type: string
+ enum:
+ - success
+ - failure
+ - unclassified
+ default:
+ - success
+ - failure
+ array_string_default:
+ type: array
+ items:
+ type: string
+ default:
+ - failure
+ - skipped
+ array_integer_default:
+ type: array
+ items:
+ type: integer
+ default:
+ - 1
+ - 3
+ array_string:
+ type: array
+ items:
+ type: string
+ array_string_nullable:
+ nullable: true
+ type: array
+ items:
+ type: string
+ string_nullable:
+ type: string
+ nullable: true
Bird:
type: object
properties:
diff --git a/openapitools.json b/openapitools.json
new file mode 100644
index 00000000000..f5f966a1030
--- /dev/null
+++ b/openapitools.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
+ "spaces": 2,
+ "generator-cli": {
+ "version": "6.2.1"
+ }
+}
diff --git a/pom.xml b/pom.xml
index 42fdcead022..7ddc66c86bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1296,6 +1296,7 @@
samples/client/others/java/okhttp-gson-streamingsamples/client/petstore/java/okhttp-gsonsamples/client/petstore/java-micronaut-client
+ samples/client/petstore/java/apache-httpclient
diff --git a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES
index 211be50eebe..d799647fefc 100644
--- a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES
@@ -10,6 +10,7 @@ docs/BodyApi.md
docs/Category.md
docs/DataQuery.md
docs/DataQueryAllOf.md
+docs/DefaultValue.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@@ -46,6 +47,7 @@ src/main/java/org/openapitools/client/model/Bird.java
src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
+src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/Tag.java
diff --git a/samples/client/echo_api/java/apache-httpclient/README.md b/samples/client/echo_api/java/apache-httpclient/README.md
index 2b9dc39df25..4067df7d734 100644
--- a/samples/client/echo_api/java/apache-httpclient/README.md
+++ b/samples/client/echo_api/java/apache-httpclient/README.md
@@ -122,6 +122,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
+ - [DefaultValue](docs/DefaultValue.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [Tag](docs/Tag.md)
diff --git a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml
index 3fc6ac3d6c8..44b2b84e6e2 100644
--- a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml
+++ b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml
@@ -301,6 +301,47 @@ components:
type: object
xml:
name: pet
+ DefaultValue:
+ description: to test the default value of properties
+ properties:
+ array_string_enum_default:
+ default:
+ - success
+ - failure
+ items:
+ enum:
+ - success
+ - failure
+ - unclassified
+ type: string
+ type: array
+ array_string_default:
+ default:
+ - failure
+ - skipped
+ items:
+ type: string
+ type: array
+ array_integer_default:
+ default:
+ - 1
+ - 3
+ items:
+ type: integer
+ type: array
+ array_string:
+ items:
+ type: string
+ type: array
+ array_string_nullable:
+ items:
+ type: string
+ nullable: true
+ type: array
+ string_nullable:
+ nullable: true
+ type: string
+ type: object
Bird:
properties:
size:
diff --git a/samples/client/echo_api/java/apache-httpclient/docs/DefaultValue.md b/samples/client/echo_api/java/apache-httpclient/docs/DefaultValue.md
new file mode 100644
index 00000000000..ea7323bc04d
--- /dev/null
+++ b/samples/client/echo_api/java/apache-httpclient/docs/DefaultValue.md
@@ -0,0 +1,29 @@
+
+
+# DefaultValue
+
+to test the default value of properties
+
+## Properties
+
+| Name | Type | Description | Notes |
+|------------ | ------------- | ------------- | -------------|
+|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
+|**arrayStringDefault** | **List<String>** | | [optional] |
+|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
+|**arrayString** | **List<String>** | | [optional] |
+|**arrayStringNullable** | **List<String>** | | [optional] |
+|**stringNullable** | **String** | | [optional] |
+
+
+
+## Enum: List<ArrayStringEnumDefaultEnum>
+
+| Name | Value |
+|---- | -----|
+| SUCCESS | "success" |
+| FAILURE | "failure" |
+| UNCLASSIFIED | "unclassified" |
+
+
+
diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java
new file mode 100644
index 00000000000..120f1c9152a
--- /dev/null
+++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java
@@ -0,0 +1,496 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Arrays;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openapitools.jackson.nullable.JsonNullable;
+import java.util.NoSuchElementException;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.StringJoiner;
+
+/**
+ * to test the default value of properties
+ */
+@JsonPropertyOrder({
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT,
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT,
+ DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT,
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING,
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE,
+ DefaultValue.JSON_PROPERTY_STRING_NULLABLE
+})
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class DefaultValue {
+ /**
+ * Gets or Sets arrayStringEnumDefault
+ */
+ public enum ArrayStringEnumDefaultEnum {
+ SUCCESS("success"),
+
+ FAILURE("failure"),
+
+ UNCLASSIFIED("unclassified");
+
+ private String value;
+
+ ArrayStringEnumDefaultEnum(String value) {
+ this.value = value;
+ }
+
+ @JsonValue
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ @JsonCreator
+ public static ArrayStringEnumDefaultEnum fromValue(String value) {
+ for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
+ if (b.value.equals(value)) {
+ return b;
+ }
+ }
+ throw new IllegalArgumentException("Unexpected value '" + value + "'");
+ }
+ }
+
+ public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
+ private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
+
+ public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default";
+ private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
+
+ public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default";
+ private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
+
+ public static final String JSON_PROPERTY_ARRAY_STRING = "array_string";
+ private List arrayString = new ArrayList<>();
+
+ public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable";
+ private JsonNullable> arrayStringNullable = JsonNullable.>undefined();
+
+ public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable";
+ private JsonNullable stringNullable = JsonNullable.undefined();
+
+ public DefaultValue() {
+ }
+
+ public DefaultValue arrayStringEnumDefault(List arrayStringEnumDefault) {
+
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
+ if (this.arrayStringEnumDefault == null) {
+ this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
+ }
+ this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringEnumDefault
+ * @return arrayStringEnumDefault
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayStringEnumDefault() {
+ return arrayStringEnumDefault;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayStringEnumDefault(List arrayStringEnumDefault) {
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ }
+
+
+ public DefaultValue arrayStringDefault(List arrayStringDefault) {
+
+ this.arrayStringDefault = arrayStringDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
+ if (this.arrayStringDefault == null) {
+ this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
+ }
+ this.arrayStringDefault.add(arrayStringDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringDefault
+ * @return arrayStringDefault
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayStringDefault() {
+ return arrayStringDefault;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayStringDefault(List arrayStringDefault) {
+ this.arrayStringDefault = arrayStringDefault;
+ }
+
+
+ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) {
+
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
+ if (this.arrayIntegerDefault == null) {
+ this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
+ }
+ this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayIntegerDefault
+ * @return arrayIntegerDefault
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayIntegerDefault() {
+ return arrayIntegerDefault;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayIntegerDefault(List arrayIntegerDefault) {
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ }
+
+
+ public DefaultValue arrayString(List arrayString) {
+
+ this.arrayString = arrayString;
+ return this;
+ }
+
+ public DefaultValue addArrayStringItem(String arrayStringItem) {
+ if (this.arrayString == null) {
+ this.arrayString = new ArrayList<>();
+ }
+ this.arrayString.add(arrayStringItem);
+ return this;
+ }
+
+ /**
+ * Get arrayString
+ * @return arrayString
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayString() {
+ return arrayString;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayString(List arrayString) {
+ this.arrayString = arrayString;
+ }
+
+
+ public DefaultValue arrayStringNullable(List arrayStringNullable) {
+ this.arrayStringNullable = JsonNullable.>of(arrayStringNullable);
+
+ return this;
+ }
+
+ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
+ if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) {
+ this.arrayStringNullable = JsonNullable.>of(null);
+ }
+ try {
+ this.arrayStringNullable.get().add(arrayStringNullableItem);
+ } catch (java.util.NoSuchElementException e) {
+ // this can never happen, as we make sure above that the value is present
+ }
+ return this;
+ }
+
+ /**
+ * Get arrayStringNullable
+ * @return arrayStringNullable
+ **/
+ @javax.annotation.Nullable
+ @JsonIgnore
+
+ public List getArrayStringNullable() {
+ return arrayStringNullable.orElse(null);
+ }
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public JsonNullable> getArrayStringNullable_JsonNullable() {
+ return arrayStringNullable;
+ }
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
+ public void setArrayStringNullable_JsonNullable(JsonNullable> arrayStringNullable) {
+ this.arrayStringNullable = arrayStringNullable;
+ }
+
+ public void setArrayStringNullable(List arrayStringNullable) {
+ this.arrayStringNullable = JsonNullable.>of(arrayStringNullable);
+ }
+
+
+ public DefaultValue stringNullable(String stringNullable) {
+ this.stringNullable = JsonNullable.of(stringNullable);
+
+ return this;
+ }
+
+ /**
+ * Get stringNullable
+ * @return stringNullable
+ **/
+ @javax.annotation.Nullable
+ @JsonIgnore
+
+ public String getStringNullable() {
+ return stringNullable.orElse(null);
+ }
+
+ @JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public JsonNullable getStringNullable_JsonNullable() {
+ return stringNullable;
+ }
+
+ @JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
+ public void setStringNullable_JsonNullable(JsonNullable stringNullable) {
+ this.stringNullable = stringNullable;
+ }
+
+ public void setStringNullable(String stringNullable) {
+ this.stringNullable = JsonNullable.of(stringNullable);
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultValue defaultValue = (DefaultValue) o;
+ return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
+ Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
+ Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
+ Objects.equals(this.arrayString, defaultValue.arrayString) &&
+ equalsNullable(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
+ equalsNullable(this.stringNullable, defaultValue.stringNullable);
+ }
+
+ private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
+ return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
+ }
+
+ private static int hashCodeNullable(JsonNullable a) {
+ if (a == null) {
+ return 1;
+ }
+ return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DefaultValue {\n");
+ sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
+ sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
+ sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
+ sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
+ sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
+ sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+ /**
+ * Convert the instance into URL query string.
+ *
+ * @return URL query string
+ */
+ public String toUrlQueryString() {
+ return toUrlQueryString(null);
+ }
+
+ /**
+ * Convert the instance into URL query string.
+ *
+ * @param prefix prefix of the query string
+ * @return URL query string
+ */
+ public String toUrlQueryString(String prefix) {
+ String suffix = "";
+ String containerSuffix = "";
+ String containerPrefix = "";
+ if (prefix == null) {
+ // style=form, explode=true, e.g. /pet?name=cat&type=manx
+ prefix = "";
+ } else {
+ // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
+ prefix = prefix + "[";
+ suffix = "]";
+ containerSuffix = "]";
+ containerPrefix = "[";
+ }
+
+ StringJoiner joiner = new StringJoiner("&");
+
+ // add `array_string_enum_default` to the URL query string
+ if (getArrayStringEnumDefault() != null) {
+ for (int i = 0; i < getArrayStringEnumDefault().size(); i++) {
+ try {
+ joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // add `array_string_default` to the URL query string
+ if (getArrayStringDefault() != null) {
+ for (int i = 0; i < getArrayStringDefault().size(); i++) {
+ try {
+ joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // add `array_integer_default` to the URL query string
+ if (getArrayIntegerDefault() != null) {
+ for (int i = 0; i < getArrayIntegerDefault().size(); i++) {
+ try {
+ joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // add `array_string` to the URL query string
+ if (getArrayString() != null) {
+ for (int i = 0; i < getArrayString().size(); i++) {
+ try {
+ joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayString().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // add `array_string_nullable` to the URL query string
+ if (getArrayStringNullable() != null) {
+ for (int i = 0; i < getArrayStringNullable().size(); i++) {
+ try {
+ joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // add `string_nullable` to the URL query string
+ if (getStringNullable() != null) {
+ try {
+ joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
+ }
+ }
+
+ return joiner.toString();
+ }
+
+}
+
diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java
index dbdb5ed4472..ffb0408d05b 100644
--- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java
+++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java
@@ -56,7 +56,7 @@ public class Pet {
private List photoUrls = new ArrayList<>();
public static final String JSON_PROPERTY_TAGS = "tags";
- private List tags = null;
+ private List tags = new ArrayList<>();
/**
* pet status in the store
diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java
index 69afb02eb4c..fc8dbda1c66 100644
--- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java
+++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java
@@ -78,7 +78,7 @@ public class Query {
}
public static final String JSON_PROPERTY_OUTCOMES = "outcomes";
- private List outcomes = null;
+ private List outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
public Query() {
}
@@ -117,7 +117,7 @@ public class Query {
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
if (this.outcomes == null) {
- this.outcomes = new ArrayList<>();
+ this.outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
}
this.outcomes.add(outcomesItem);
return this;
diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
index c62cd859c36..0e5bfd5253a 100644
--- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
+++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
@@ -38,7 +38,7 @@ import java.util.StringJoiner;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
public static final String JSON_PROPERTY_VALUES = "values";
- private List values = null;
+ private List values = new ArrayList<>();
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
}
diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java
index b76e3601e32..97114ea9836 100644
--- a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java
+++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java
@@ -13,6 +13,7 @@
package org.openapitools.client;
+import com.fasterxml.jackson.core.type.TypeReference;
import org.junit.Assert;
import org.openapitools.client.ApiException;
import org.openapitools.client.api.*;
@@ -20,6 +21,7 @@ import org.openapitools.client.model.*;
import org.junit.Test;
import org.junit.Ignore;
+import java.io.IOException;
import java.util.*;
@@ -138,4 +140,106 @@ public class CustomTest {
Assert.assertEquals("/query/integer/boolean/string?integer_query=1&boolean_query=true&string_query=Hello%20World", p.path);
}
+ @Test
+ public void testArrayDefaultValues() {
+ // test array default values
+ DefaultValue d = new DefaultValue();
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
+
+ Assert.assertEquals(d.getArrayStringDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
+ Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
+
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
+ Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
+
+ Assert.assertNull(d.getArrayStringNullable());
+ Assert.assertEquals(d.getArrayString().size(), 0);
+
+ // test addItem
+ d.addArrayStringEnumDefaultItem(DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 3);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(2), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
+
+ d.addArrayStringDefaultItem("new item");
+ Assert.assertEquals(d.getArrayStringDefault().size(), 3);
+ Assert.assertEquals(d.getArrayStringDefault().get(2), "new item");
+
+ d.addArrayIntegerDefaultItem(5);
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 3);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(2), Integer.valueOf(5));
+
+ }
+
+ @Test
+ public void testDefaultValuesSerializationWithEmptyPayload() throws IOException {
+ ApiClient apiClient = new ApiClient();
+
+ String str = "{}";
+
+ DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference() {
+ });
+
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
+
+ Assert.assertEquals(d.getArrayStringDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
+ Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
+
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
+ Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
+
+ Assert.assertNull(d.getArrayStringNullable());
+ Assert.assertEquals(d.getArrayString().size(), 0);
+
+ Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"success\",\"failure\"],\"array_string_default\":[\"failure\",\"skipped\"],\"array_integer_default\":[1,3],\"array_string\":[],\"array_string_nullable\":{\"present\":false},\"string_nullable\":{\"present\":false}}");
+ }
+
+ @Test
+ public void testDefaultValuesSerializationWithJSONString() throws IOException {
+ ApiClient apiClient = new ApiClient();
+
+ String str = "{ \"array_string_enum_default\": [\"unclassified\"], \"array_string_default\": [\"failure\"] }";
+
+ DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference() {
+ });
+
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 1);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
+
+ Assert.assertEquals(d.getArrayStringDefault().size(), 1);
+ Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
+
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
+ Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
+
+ Assert.assertNull(d.getArrayStringNullable());
+ Assert.assertEquals(d.getArrayString().size(), 0);
+
+ Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[],\"array_string_nullable\":{\"present\":false},\"string_nullable\":{\"present\":false}}");
+ }
+
+ @Test
+ public void testDefaultValuesSerializationWithIncorrectDefaultValues() throws IOException {
+ ApiClient apiClient = new ApiClient();
+
+ String str = "{ \"array_string_enum_default\": [\"invalid\"] }";
+
+ try {
+ DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference() {
+ });
+ Assert.assertTrue(false); // the test should not reach this line
+ } catch (com.fasterxml.jackson.databind.exc.ValueInstantiationException e) {
+ Assert.assertEquals(e.getMessage(), "Cannot construct instance of `org.openapitools.client.model.DefaultValue$ArrayStringEnumDefaultEnum`, problem: Unexpected value 'invalid'\n" +
+ " at [Source: (String)\"{ \"array_string_enum_default\": [\"invalid\"] }\"; line: 1, column: 33] (through reference chain: org.openapitools.client.model.DefaultValue[\"array_string_enum_default\"]->java.util.ArrayList[0])");
+ }
+ }
+
}
diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DefaultValueTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DefaultValueTest.java
new file mode 100644
index 00000000000..8adf113d6ea
--- /dev/null
+++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DefaultValueTest.java
@@ -0,0 +1,94 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openapitools.jackson.nullable.JsonNullable;
+import java.util.NoSuchElementException;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Model tests for DefaultValue
+ */
+public class DefaultValueTest {
+ private final DefaultValue model = new DefaultValue();
+
+ /**
+ * Model tests for DefaultValue
+ */
+ @Test
+ public void testDefaultValue() {
+ // TODO: test DefaultValue
+ }
+
+ /**
+ * Test the property 'arrayStringEnumDefault'
+ */
+ @Test
+ public void arrayStringEnumDefaultTest() {
+ // TODO: test arrayStringEnumDefault
+ }
+
+ /**
+ * Test the property 'arrayStringDefault'
+ */
+ @Test
+ public void arrayStringDefaultTest() {
+ // TODO: test arrayStringDefault
+ }
+
+ /**
+ * Test the property 'arrayIntegerDefault'
+ */
+ @Test
+ public void arrayIntegerDefaultTest() {
+ // TODO: test arrayIntegerDefault
+ }
+
+ /**
+ * Test the property 'arrayString'
+ */
+ @Test
+ public void arrayStringTest() {
+ // TODO: test arrayString
+ }
+
+ /**
+ * Test the property 'arrayStringNullable'
+ */
+ @Test
+ public void arrayStringNullableTest() {
+ // TODO: test arrayStringNullable
+ }
+
+ /**
+ * Test the property 'stringNullable'
+ */
+ @Test
+ public void stringNullableTest() {
+ // TODO: test stringNullable
+ }
+
+}
diff --git a/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES b/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES
index 7a45316b566..ccc1a3dbfd0 100644
--- a/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES
@@ -30,6 +30,7 @@ src/main/java/org/openapitools/client/model/Bird.java
src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
+src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/Tag.java
diff --git a/samples/client/echo_api/java/feign-gson/api/openapi.yaml b/samples/client/echo_api/java/feign-gson/api/openapi.yaml
index 3fc6ac3d6c8..44b2b84e6e2 100644
--- a/samples/client/echo_api/java/feign-gson/api/openapi.yaml
+++ b/samples/client/echo_api/java/feign-gson/api/openapi.yaml
@@ -301,6 +301,47 @@ components:
type: object
xml:
name: pet
+ DefaultValue:
+ description: to test the default value of properties
+ properties:
+ array_string_enum_default:
+ default:
+ - success
+ - failure
+ items:
+ enum:
+ - success
+ - failure
+ - unclassified
+ type: string
+ type: array
+ array_string_default:
+ default:
+ - failure
+ - skipped
+ items:
+ type: string
+ type: array
+ array_integer_default:
+ default:
+ - 1
+ - 3
+ items:
+ type: integer
+ type: array
+ array_string:
+ items:
+ type: string
+ type: array
+ array_string_nullable:
+ items:
+ type: string
+ nullable: true
+ type: array
+ string_nullable:
+ nullable: true
+ type: string
+ type: object
Bird:
properties:
size:
diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java
new file mode 100644
index 00000000000..192754a61bd
--- /dev/null
+++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java
@@ -0,0 +1,340 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Arrays;
+import com.google.gson.TypeAdapter;
+import com.google.gson.annotations.JsonAdapter;
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+/**
+ * to test the default value of properties
+ */
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class DefaultValue {
+ /**
+ * Gets or Sets arrayStringEnumDefault
+ */
+ @JsonAdapter(ArrayStringEnumDefaultEnum.Adapter.class)
+ public enum ArrayStringEnumDefaultEnum {
+ SUCCESS("success"),
+
+ FAILURE("failure"),
+
+ UNCLASSIFIED("unclassified");
+
+ private String value;
+
+ ArrayStringEnumDefaultEnum(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ public static ArrayStringEnumDefaultEnum fromValue(String value) {
+ for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
+ if (b.value.equals(value)) {
+ return b;
+ }
+ }
+ throw new IllegalArgumentException("Unexpected value '" + value + "'");
+ }
+
+ public static class Adapter extends TypeAdapter {
+ @Override
+ public void write(final JsonWriter jsonWriter, final ArrayStringEnumDefaultEnum enumeration) throws IOException {
+ jsonWriter.value(enumeration.getValue());
+ }
+
+ @Override
+ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOException {
+ String value = jsonReader.nextString();
+ return ArrayStringEnumDefaultEnum.fromValue(value);
+ }
+ }
+ }
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT)
+ private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT)
+ private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
+
+ public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default";
+ @SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT)
+ private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING)
+ private List arrayString = new ArrayList<>();
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE)
+ private List arrayStringNullable = null;
+
+ public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable";
+ @SerializedName(SERIALIZED_NAME_STRING_NULLABLE)
+ private String stringNullable;
+
+ public DefaultValue() {
+ }
+
+ public DefaultValue arrayStringEnumDefault(List arrayStringEnumDefault) {
+
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
+ if (this.arrayStringEnumDefault == null) {
+ this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
+ }
+ this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringEnumDefault
+ * @return arrayStringEnumDefault
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayStringEnumDefault() {
+ return arrayStringEnumDefault;
+ }
+
+
+ public void setArrayStringEnumDefault(List arrayStringEnumDefault) {
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ }
+
+
+ public DefaultValue arrayStringDefault(List arrayStringDefault) {
+
+ this.arrayStringDefault = arrayStringDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
+ if (this.arrayStringDefault == null) {
+ this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
+ }
+ this.arrayStringDefault.add(arrayStringDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringDefault
+ * @return arrayStringDefault
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayStringDefault() {
+ return arrayStringDefault;
+ }
+
+
+ public void setArrayStringDefault(List arrayStringDefault) {
+ this.arrayStringDefault = arrayStringDefault;
+ }
+
+
+ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) {
+
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
+ if (this.arrayIntegerDefault == null) {
+ this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
+ }
+ this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayIntegerDefault
+ * @return arrayIntegerDefault
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayIntegerDefault() {
+ return arrayIntegerDefault;
+ }
+
+
+ public void setArrayIntegerDefault(List arrayIntegerDefault) {
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ }
+
+
+ public DefaultValue arrayString(List arrayString) {
+
+ this.arrayString = arrayString;
+ return this;
+ }
+
+ public DefaultValue addArrayStringItem(String arrayStringItem) {
+ if (this.arrayString == null) {
+ this.arrayString = new ArrayList<>();
+ }
+ this.arrayString.add(arrayStringItem);
+ return this;
+ }
+
+ /**
+ * Get arrayString
+ * @return arrayString
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayString() {
+ return arrayString;
+ }
+
+
+ public void setArrayString(List arrayString) {
+ this.arrayString = arrayString;
+ }
+
+
+ public DefaultValue arrayStringNullable(List arrayStringNullable) {
+
+ this.arrayStringNullable = arrayStringNullable;
+ return this;
+ }
+
+ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
+ if (this.arrayStringNullable == null) {
+ this.arrayStringNullable = null;
+ }
+ this.arrayStringNullable.add(arrayStringNullableItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringNullable
+ * @return arrayStringNullable
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayStringNullable() {
+ return arrayStringNullable;
+ }
+
+
+ public void setArrayStringNullable(List arrayStringNullable) {
+ this.arrayStringNullable = arrayStringNullable;
+ }
+
+
+ public DefaultValue stringNullable(String stringNullable) {
+
+ this.stringNullable = stringNullable;
+ return this;
+ }
+
+ /**
+ * Get stringNullable
+ * @return stringNullable
+ **/
+ @javax.annotation.Nullable
+
+ public String getStringNullable() {
+ return stringNullable;
+ }
+
+
+ public void setStringNullable(String stringNullable) {
+ this.stringNullable = stringNullable;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultValue defaultValue = (DefaultValue) o;
+ return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
+ Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
+ Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
+ Objects.equals(this.arrayString, defaultValue.arrayString) &&
+ Objects.equals(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
+ Objects.equals(this.stringNullable, defaultValue.stringNullable);
+ }
+
+ private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
+ return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
+ }
+
+ private static int hashCodeNullable(JsonNullable a) {
+ if (a == null) {
+ return 1;
+ }
+ return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DefaultValue {\n");
+ sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
+ sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
+ sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
+ sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
+ sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
+ sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+}
+
diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java
index 0f511d550b7..23b255c290d 100644
--- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java
+++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java
@@ -49,7 +49,7 @@ public class Pet {
public static final String SERIALIZED_NAME_TAGS = "tags";
@SerializedName(SERIALIZED_NAME_TAGS)
- private List tags = null;
+ private List tags = new ArrayList<>();
/**
* pet status in the store
diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java
index ee7c8929fe7..a8e911881cc 100644
--- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java
+++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java
@@ -84,7 +84,7 @@ public class Query {
public static final String SERIALIZED_NAME_OUTCOMES = "outcomes";
@SerializedName(SERIALIZED_NAME_OUTCOMES)
- private List outcomes = null;
+ private List outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
public Query() {
}
@@ -119,7 +119,7 @@ public class Query {
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
if (this.outcomes == null) {
- this.outcomes = new ArrayList<>();
+ this.outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
}
this.outcomes.add(outcomesItem);
return this;
diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
index 433e40e1376..845aab85423 100644
--- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
+++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
@@ -31,7 +31,7 @@ import java.util.List;
public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
public static final String SERIALIZED_NAME_VALUES = "values";
@SerializedName(SERIALIZED_NAME_VALUES)
- private List values = null;
+ private List values = new ArrayList<>();
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
}
diff --git a/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DefaultValueTest.java b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DefaultValueTest.java
new file mode 100644
index 00000000000..b5f523bde62
--- /dev/null
+++ b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DefaultValueTest.java
@@ -0,0 +1,90 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.annotations.JsonAdapter;
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+import org.junit.jupiter.api.Test;
+
+
+/**
+ * Model tests for DefaultValue
+ */
+class DefaultValueTest {
+ private final DefaultValue model = new DefaultValue();
+
+ /**
+ * Model tests for DefaultValue
+ */
+ @Test
+ void testDefaultValue() {
+ // TODO: test DefaultValue
+ }
+
+ /**
+ * Test the property 'arrayStringEnumDefault'
+ */
+ @Test
+ void arrayStringEnumDefaultTest() {
+ // TODO: test arrayStringEnumDefault
+ }
+
+ /**
+ * Test the property 'arrayStringDefault'
+ */
+ @Test
+ void arrayStringDefaultTest() {
+ // TODO: test arrayStringDefault
+ }
+
+ /**
+ * Test the property 'arrayIntegerDefault'
+ */
+ @Test
+ void arrayIntegerDefaultTest() {
+ // TODO: test arrayIntegerDefault
+ }
+
+ /**
+ * Test the property 'arrayString'
+ */
+ @Test
+ void arrayStringTest() {
+ // TODO: test arrayString
+ }
+
+ /**
+ * Test the property 'arrayStringNullable'
+ */
+ @Test
+ void arrayStringNullableTest() {
+ // TODO: test arrayStringNullable
+ }
+
+ /**
+ * Test the property 'stringNullable'
+ */
+ @Test
+ void stringNullableTest() {
+ // TODO: test stringNullable
+ }
+
+}
diff --git a/samples/client/echo_api/java/native/.openapi-generator/FILES b/samples/client/echo_api/java/native/.openapi-generator/FILES
index 90a697b6ff2..39773914b69 100644
--- a/samples/client/echo_api/java/native/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/native/.openapi-generator/FILES
@@ -10,6 +10,7 @@ docs/BodyApi.md
docs/Category.md
docs/DataQuery.md
docs/DataQueryAllOf.md
+docs/DefaultValue.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@@ -43,6 +44,7 @@ src/main/java/org/openapitools/client/model/Bird.java
src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
+src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/Tag.java
diff --git a/samples/client/echo_api/java/native/README.md b/samples/client/echo_api/java/native/README.md
index 55864e1c18d..2a3b7e52c75 100644
--- a/samples/client/echo_api/java/native/README.md
+++ b/samples/client/echo_api/java/native/README.md
@@ -129,6 +129,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
+ - [DefaultValue](docs/DefaultValue.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [Tag](docs/Tag.md)
diff --git a/samples/client/echo_api/java/native/api/openapi.yaml b/samples/client/echo_api/java/native/api/openapi.yaml
index 3fc6ac3d6c8..44b2b84e6e2 100644
--- a/samples/client/echo_api/java/native/api/openapi.yaml
+++ b/samples/client/echo_api/java/native/api/openapi.yaml
@@ -301,6 +301,47 @@ components:
type: object
xml:
name: pet
+ DefaultValue:
+ description: to test the default value of properties
+ properties:
+ array_string_enum_default:
+ default:
+ - success
+ - failure
+ items:
+ enum:
+ - success
+ - failure
+ - unclassified
+ type: string
+ type: array
+ array_string_default:
+ default:
+ - failure
+ - skipped
+ items:
+ type: string
+ type: array
+ array_integer_default:
+ default:
+ - 1
+ - 3
+ items:
+ type: integer
+ type: array
+ array_string:
+ items:
+ type: string
+ type: array
+ array_string_nullable:
+ items:
+ type: string
+ nullable: true
+ type: array
+ string_nullable:
+ nullable: true
+ type: string
+ type: object
Bird:
properties:
size:
diff --git a/samples/client/echo_api/java/native/docs/DefaultValue.md b/samples/client/echo_api/java/native/docs/DefaultValue.md
new file mode 100644
index 00000000000..ea7323bc04d
--- /dev/null
+++ b/samples/client/echo_api/java/native/docs/DefaultValue.md
@@ -0,0 +1,29 @@
+
+
+# DefaultValue
+
+to test the default value of properties
+
+## Properties
+
+| Name | Type | Description | Notes |
+|------------ | ------------- | ------------- | -------------|
+|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
+|**arrayStringDefault** | **List<String>** | | [optional] |
+|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
+|**arrayString** | **List<String>** | | [optional] |
+|**arrayStringNullable** | **List<String>** | | [optional] |
+|**stringNullable** | **String** | | [optional] |
+
+
+
+## Enum: List<ArrayStringEnumDefaultEnum>
+
+| Name | Value |
+|---- | -----|
+| SUCCESS | "success" |
+| FAILURE | "failure" |
+| UNCLASSIFIED | "unclassified" |
+
+
+
diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java
new file mode 100644
index 00000000000..4b8d34854ca
--- /dev/null
+++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java
@@ -0,0 +1,464 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.StringJoiner;
+import java.util.Objects;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openapitools.jackson.nullable.JsonNullable;
+import java.util.NoSuchElementException;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+
+/**
+ * to test the default value of properties
+ */
+@JsonPropertyOrder({
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT,
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT,
+ DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT,
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING,
+ DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE,
+ DefaultValue.JSON_PROPERTY_STRING_NULLABLE
+})
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class DefaultValue {
+ /**
+ * Gets or Sets arrayStringEnumDefault
+ */
+ public enum ArrayStringEnumDefaultEnum {
+ SUCCESS("success"),
+
+ FAILURE("failure"),
+
+ UNCLASSIFIED("unclassified");
+
+ private String value;
+
+ ArrayStringEnumDefaultEnum(String value) {
+ this.value = value;
+ }
+
+ @JsonValue
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ @JsonCreator
+ public static ArrayStringEnumDefaultEnum fromValue(String value) {
+ for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
+ if (b.value.equals(value)) {
+ return b;
+ }
+ }
+ throw new IllegalArgumentException("Unexpected value '" + value + "'");
+ }
+ }
+
+ public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
+ private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
+
+ public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default";
+ private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
+
+ public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default";
+ private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
+
+ public static final String JSON_PROPERTY_ARRAY_STRING = "array_string";
+ private List arrayString = new ArrayList<>();
+
+ public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable";
+ private JsonNullable> arrayStringNullable = JsonNullable.>undefined();
+
+ public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable";
+ private JsonNullable stringNullable = JsonNullable.undefined();
+
+ public DefaultValue() {
+ }
+
+ public DefaultValue arrayStringEnumDefault(List arrayStringEnumDefault) {
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
+ if (this.arrayStringEnumDefault == null) {
+ this.arrayStringEnumDefault = new ArrayList<>();
+ }
+ this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringEnumDefault
+ * @return arrayStringEnumDefault
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayStringEnumDefault() {
+ return arrayStringEnumDefault;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayStringEnumDefault(List arrayStringEnumDefault) {
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ }
+
+
+ public DefaultValue arrayStringDefault(List arrayStringDefault) {
+ this.arrayStringDefault = arrayStringDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
+ if (this.arrayStringDefault == null) {
+ this.arrayStringDefault = new ArrayList<>();
+ }
+ this.arrayStringDefault.add(arrayStringDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringDefault
+ * @return arrayStringDefault
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayStringDefault() {
+ return arrayStringDefault;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayStringDefault(List arrayStringDefault) {
+ this.arrayStringDefault = arrayStringDefault;
+ }
+
+
+ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) {
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
+ if (this.arrayIntegerDefault == null) {
+ this.arrayIntegerDefault = new ArrayList<>();
+ }
+ this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayIntegerDefault
+ * @return arrayIntegerDefault
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayIntegerDefault() {
+ return arrayIntegerDefault;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayIntegerDefault(List arrayIntegerDefault) {
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ }
+
+
+ public DefaultValue arrayString(List arrayString) {
+ this.arrayString = arrayString;
+ return this;
+ }
+
+ public DefaultValue addArrayStringItem(String arrayStringItem) {
+ if (this.arrayString == null) {
+ this.arrayString = new ArrayList<>();
+ }
+ this.arrayString.add(arrayStringItem);
+ return this;
+ }
+
+ /**
+ * Get arrayString
+ * @return arrayString
+ **/
+ @javax.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public List getArrayString() {
+ return arrayString;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setArrayString(List arrayString) {
+ this.arrayString = arrayString;
+ }
+
+
+ public DefaultValue arrayStringNullable(List arrayStringNullable) {
+ this.arrayStringNullable = JsonNullable.>of(arrayStringNullable);
+ return this;
+ }
+
+ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
+ if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) {
+ this.arrayStringNullable = JsonNullable.>of(null);
+ }
+ try {
+ this.arrayStringNullable.get().add(arrayStringNullableItem);
+ } catch (java.util.NoSuchElementException e) {
+ // this can never happen, as we make sure above that the value is present
+ }
+ return this;
+ }
+
+ /**
+ * Get arrayStringNullable
+ * @return arrayStringNullable
+ **/
+ @javax.annotation.Nullable
+ @JsonIgnore
+
+ public List getArrayStringNullable() {
+ return arrayStringNullable.orElse(null);
+ }
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public JsonNullable> getArrayStringNullable_JsonNullable() {
+ return arrayStringNullable;
+ }
+
+ @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
+ public void setArrayStringNullable_JsonNullable(JsonNullable> arrayStringNullable) {
+ this.arrayStringNullable = arrayStringNullable;
+ }
+
+ public void setArrayStringNullable(List arrayStringNullable) {
+ this.arrayStringNullable = JsonNullable.>of(arrayStringNullable);
+ }
+
+
+ public DefaultValue stringNullable(String stringNullable) {
+ this.stringNullable = JsonNullable.of(stringNullable);
+ return this;
+ }
+
+ /**
+ * Get stringNullable
+ * @return stringNullable
+ **/
+ @javax.annotation.Nullable
+ @JsonIgnore
+
+ public String getStringNullable() {
+ return stringNullable.orElse(null);
+ }
+
+ @JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public JsonNullable getStringNullable_JsonNullable() {
+ return stringNullable;
+ }
+
+ @JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
+ public void setStringNullable_JsonNullable(JsonNullable stringNullable) {
+ this.stringNullable = stringNullable;
+ }
+
+ public void setStringNullable(String stringNullable) {
+ this.stringNullable = JsonNullable.of(stringNullable);
+ }
+
+
+ /**
+ * Return true if this DefaultValue object is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultValue defaultValue = (DefaultValue) o;
+ return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
+ Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
+ Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
+ Objects.equals(this.arrayString, defaultValue.arrayString) &&
+ equalsNullable(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
+ equalsNullable(this.stringNullable, defaultValue.stringNullable);
+ }
+
+ private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
+ return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable));
+ }
+
+ private static int hashCodeNullable(JsonNullable a) {
+ if (a == null) {
+ return 1;
+ }
+ return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DefaultValue {\n");
+ sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
+ sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
+ sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
+ sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
+ sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
+ sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+ /**
+ * Convert the instance into URL query string.
+ *
+ * @return URL query string
+ */
+ public String toUrlQueryString() {
+ return toUrlQueryString(null);
+ }
+
+ /**
+ * Convert the instance into URL query string.
+ *
+ * @param prefix prefix of the query string
+ * @return URL query string
+ */
+ public String toUrlQueryString(String prefix) {
+ String suffix = "";
+ String containerSuffix = "";
+ String containerPrefix = "";
+ if (prefix == null) {
+ // style=form, explode=true, e.g. /pet?name=cat&type=manx
+ prefix = "";
+ } else {
+ // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
+ prefix = prefix + "[";
+ suffix = "]";
+ containerSuffix = "]";
+ containerPrefix = "[";
+ }
+
+ StringJoiner joiner = new StringJoiner("&");
+
+ // add `array_string_enum_default` to the URL query string
+ if (getArrayStringEnumDefault() != null) {
+ for (int i = 0; i < getArrayStringEnumDefault().size(); i++) {
+ joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
+ }
+ }
+
+ // add `array_string_default` to the URL query string
+ if (getArrayStringDefault() != null) {
+ for (int i = 0; i < getArrayStringDefault().size(); i++) {
+ joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
+ }
+ }
+
+ // add `array_integer_default` to the URL query string
+ if (getArrayIntegerDefault() != null) {
+ for (int i = 0; i < getArrayIntegerDefault().size(); i++) {
+ joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
+ }
+ }
+
+ // add `array_string` to the URL query string
+ if (getArrayString() != null) {
+ for (int i = 0; i < getArrayString().size(); i++) {
+ joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
+ }
+ }
+
+ // add `array_string_nullable` to the URL query string
+ if (getArrayStringNullable() != null) {
+ for (int i = 0; i < getArrayStringNullable().size(); i++) {
+ joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
+ }
+ }
+
+ // add `string_nullable` to the URL query string
+ if (getStringNullable() != null) {
+ joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
+ }
+
+ return joiner.toString();
+ }
+}
+
diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java
index 5e38df45aaf..9eab225992f 100644
--- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java
+++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java
@@ -58,7 +58,7 @@ public class Pet {
private List photoUrls = new ArrayList<>();
public static final String JSON_PROPERTY_TAGS = "tags";
- private List tags = null;
+ private List tags = new ArrayList<>();
/**
* pet status in the store
diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java
index 287716592f3..8e9d339067a 100644
--- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java
+++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java
@@ -80,7 +80,7 @@ public class Query {
}
public static final String JSON_PROPERTY_OUTCOMES = "outcomes";
- private List outcomes = null;
+ private List outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
public Query() {
}
diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
index efeaf3133cc..bede74ea0ea 100644
--- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
+++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
@@ -39,7 +39,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
public static final String JSON_PROPERTY_VALUES = "values";
- private List values = null;
+ private List values = new ArrayList<>();
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
}
diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java
index 1c6db656c4f..58b55d72c81 100644
--- a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java
+++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java
@@ -13,6 +13,7 @@
package org.openapitools.client;
+import com.fasterxml.jackson.core.type.TypeReference;
import org.junit.Assert;
import org.openapitools.client.ApiException;
import org.openapitools.client.api.*;
@@ -20,9 +21,9 @@ import org.openapitools.client.model.*;
import org.junit.Test;
import org.junit.Ignore;
+import java.io.IOException;
import java.util.*;
-
/**
* API tests for QueryApi
*/
@@ -143,4 +144,105 @@ public class CustomTest {
org.openapitools.client.EchoServerResponseParser p = new org.openapitools.client.EchoServerResponseParser(response);
Assert.assertEquals("/query/style_form/explode_true/array_string?values=hello%20world%201&values=hello%20world%202", p.path);
}
+
+ @Test
+ public void testArrayDefaultValues() {
+ // test array default values
+ DefaultValue d = new DefaultValue();
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
+
+ Assert.assertEquals(d.getArrayStringDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
+ Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
+
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
+ Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
+
+ Assert.assertNull(d.getArrayStringNullable());
+ Assert.assertEquals(d.getArrayString().size(), 0);
+
+ // test addItem
+ d.addArrayStringEnumDefaultItem(DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 3);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(2), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
+
+ d.addArrayStringDefaultItem("new item");
+ Assert.assertEquals(d.getArrayStringDefault().size(), 3);
+ Assert.assertEquals(d.getArrayStringDefault().get(2), "new item");
+
+ d.addArrayIntegerDefaultItem(5);
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 3);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(2), Integer.valueOf(5));
+ }
+
+ @Test
+ public void testDefaultValuesSerializationWithEmptyPayload() throws IOException {
+ ApiClient apiClient = new ApiClient();
+
+ String str = "{}";
+
+ DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference() {
+ });
+
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.SUCCESS);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(1), DefaultValue.ArrayStringEnumDefaultEnum.FAILURE);
+
+ Assert.assertEquals(d.getArrayStringDefault().size(), 2);
+ Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
+ Assert.assertEquals(d.getArrayStringDefault().get(1), "skipped");
+
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
+ Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
+
+ Assert.assertNull(d.getArrayStringNullable());
+ Assert.assertEquals(d.getArrayString().size(), 0);
+
+ Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"success\",\"failure\"],\"array_string_default\":[\"failure\",\"skipped\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
+ }
+
+ @Test
+ public void testDefaultValuesSerializationWithJSONString() throws IOException {
+ ApiClient apiClient = new ApiClient();
+
+ String str = "{ \"array_string_enum_default\": [\"unclassified\"], \"array_string_default\": [\"failure\"] }";
+
+ DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference() {
+ });
+
+ Assert.assertEquals(d.getArrayStringEnumDefault().size(), 1);
+ Assert.assertEquals(d.getArrayStringEnumDefault().get(0), DefaultValue.ArrayStringEnumDefaultEnum.UNCLASSIFIED);
+
+ Assert.assertEquals(d.getArrayStringDefault().size(), 1);
+ Assert.assertEquals(d.getArrayStringDefault().get(0), "failure");
+
+ Assert.assertEquals(d.getArrayIntegerDefault().size(), 2);
+ Assert.assertEquals(d.getArrayIntegerDefault().get(0), Integer.valueOf(1));
+ Assert.assertEquals(d.getArrayIntegerDefault().get(1), Integer.valueOf(3));
+
+ Assert.assertNull(d.getArrayStringNullable());
+ Assert.assertEquals(d.getArrayString().size(), 0);
+
+ Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
+ }
+
+ @Test
+ public void testDefaultValuesSerializationWithIncorrectDefaultValues() throws IOException {
+ ApiClient apiClient = new ApiClient();
+
+ String str = "{ \"array_string_enum_default\": [\"invalid\"] }";
+
+ try {
+ DefaultValue d = apiClient.getObjectMapper().readValue(str, new TypeReference() {
+ });
+ Assert.assertTrue(false); // the test should not reach this line
+ } catch (com.fasterxml.jackson.databind.exc.ValueInstantiationException e) {
+ Assert.assertEquals(e.getMessage(), "Cannot construct instance of `org.openapitools.client.model.DefaultValue$ArrayStringEnumDefaultEnum`, problem: Unexpected value 'invalid'\n" +
+ " at [Source: (String)\"{ \"array_string_enum_default\": [\"invalid\"] }\"; line: 1, column: 33] (through reference chain: org.openapitools.client.model.DefaultValue[\"array_string_enum_default\"]->java.util.ArrayList[0])");
+ }
+ }
}
diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DefaultValueTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DefaultValueTest.java
new file mode 100644
index 00000000000..809a14bb008
--- /dev/null
+++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DefaultValueTest.java
@@ -0,0 +1,86 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openapitools.jackson.nullable.JsonNullable;
+import java.util.NoSuchElementException;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Model tests for DefaultValue
+ */
+public class DefaultValueTest {
+ private final DefaultValue model = new DefaultValue();
+
+ /**
+ * Model tests for DefaultValue
+ */
+ @Test
+ public void testDefaultValue() {
+ // TODO: test DefaultValue
+ }
+
+ /**
+ * Test the property 'arrayStringEnumDefault'
+ */
+ @Test
+ public void arrayStringEnumDefaultTest() {
+ // TODO: test arrayStringEnumDefault
+ }
+
+ /**
+ * Test the property 'arrayStringDefault'
+ */
+ @Test
+ public void arrayStringDefaultTest() {
+ // TODO: test arrayStringDefault
+ }
+
+ /**
+ * Test the property 'arrayString'
+ */
+ @Test
+ public void arrayStringTest() {
+ // TODO: test arrayString
+ }
+
+ /**
+ * Test the property 'arrayStringNullable'
+ */
+ @Test
+ public void arrayStringNullableTest() {
+ // TODO: test arrayStringNullable
+ }
+
+ /**
+ * Test the property 'stringNullable'
+ */
+ @Test
+ public void stringNullableTest() {
+ // TODO: test stringNullable
+ }
+
+}
diff --git a/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES b/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES
index 0492026a89c..625d04321f9 100644
--- a/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES
@@ -10,6 +10,7 @@ docs/BodyApi.md
docs/Category.md
docs/DataQuery.md
docs/DataQueryAllOf.md
+docs/DefaultValue.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
@@ -51,6 +52,7 @@ src/main/java/org/openapitools/client/model/Bird.java
src/main/java/org/openapitools/client/model/Category.java
src/main/java/org/openapitools/client/model/DataQuery.java
src/main/java/org/openapitools/client/model/DataQueryAllOf.java
+src/main/java/org/openapitools/client/model/DefaultValue.java
src/main/java/org/openapitools/client/model/Pet.java
src/main/java/org/openapitools/client/model/Query.java
src/main/java/org/openapitools/client/model/Tag.java
diff --git a/samples/client/echo_api/java/okhttp-gson/README.md b/samples/client/echo_api/java/okhttp-gson/README.md
index b9fb0fdd274..bd4fe601a60 100644
--- a/samples/client/echo_api/java/okhttp-gson/README.md
+++ b/samples/client/echo_api/java/okhttp-gson/README.md
@@ -129,6 +129,7 @@ Class | Method | HTTP request | Description
- [Category](docs/Category.md)
- [DataQuery](docs/DataQuery.md)
- [DataQueryAllOf](docs/DataQueryAllOf.md)
+ - [DefaultValue](docs/DefaultValue.md)
- [Pet](docs/Pet.md)
- [Query](docs/Query.md)
- [Tag](docs/Tag.md)
diff --git a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml
index 3fc6ac3d6c8..44b2b84e6e2 100644
--- a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml
+++ b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml
@@ -301,6 +301,47 @@ components:
type: object
xml:
name: pet
+ DefaultValue:
+ description: to test the default value of properties
+ properties:
+ array_string_enum_default:
+ default:
+ - success
+ - failure
+ items:
+ enum:
+ - success
+ - failure
+ - unclassified
+ type: string
+ type: array
+ array_string_default:
+ default:
+ - failure
+ - skipped
+ items:
+ type: string
+ type: array
+ array_integer_default:
+ default:
+ - 1
+ - 3
+ items:
+ type: integer
+ type: array
+ array_string:
+ items:
+ type: string
+ type: array
+ array_string_nullable:
+ items:
+ type: string
+ nullable: true
+ type: array
+ string_nullable:
+ nullable: true
+ type: string
+ type: object
Bird:
properties:
size:
diff --git a/samples/client/echo_api/java/okhttp-gson/docs/DefaultValue.md b/samples/client/echo_api/java/okhttp-gson/docs/DefaultValue.md
new file mode 100644
index 00000000000..ea7323bc04d
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson/docs/DefaultValue.md
@@ -0,0 +1,29 @@
+
+
+# DefaultValue
+
+to test the default value of properties
+
+## Properties
+
+| Name | Type | Description | Notes |
+|------------ | ------------- | ------------- | -------------|
+|**arrayStringEnumDefault** | [**List<ArrayStringEnumDefaultEnum>**](#List<ArrayStringEnumDefaultEnum>) | | [optional] |
+|**arrayStringDefault** | **List<String>** | | [optional] |
+|**arrayIntegerDefault** | **List<Integer>** | | [optional] |
+|**arrayString** | **List<String>** | | [optional] |
+|**arrayStringNullable** | **List<String>** | | [optional] |
+|**stringNullable** | **String** | | [optional] |
+
+
+
+## Enum: List<ArrayStringEnumDefaultEnum>
+
+| Name | Value |
+|---- | -----|
+| SUCCESS | "success" |
+| FAILURE | "failure" |
+| UNCLASSIFIED | "unclassified" |
+
+
+
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java
index 89f5cec6d71..8345513ed98 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java
@@ -97,6 +97,7 @@ public class JSON {
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQuery.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQueryAllOf.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DefaultValue.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.CustomTypeAdapterFactory());
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java
new file mode 100644
index 00000000000..a24a511f4d9
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java
@@ -0,0 +1,473 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Arrays;
+import com.google.gson.TypeAdapter;
+import com.google.gson.annotations.JsonAdapter;
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.TypeAdapterFactory;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.openapitools.client.JSON;
+
+/**
+ * to test the default value of properties
+ */
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class DefaultValue {
+ /**
+ * Gets or Sets arrayStringEnumDefault
+ */
+ @JsonAdapter(ArrayStringEnumDefaultEnum.Adapter.class)
+ public enum ArrayStringEnumDefaultEnum {
+ SUCCESS("success"),
+
+ FAILURE("failure"),
+
+ UNCLASSIFIED("unclassified");
+
+ private String value;
+
+ ArrayStringEnumDefaultEnum(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ public static ArrayStringEnumDefaultEnum fromValue(String value) {
+ for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) {
+ if (b.value.equals(value)) {
+ return b;
+ }
+ }
+ throw new IllegalArgumentException("Unexpected value '" + value + "'");
+ }
+
+ public static class Adapter extends TypeAdapter {
+ @Override
+ public void write(final JsonWriter jsonWriter, final ArrayStringEnumDefaultEnum enumeration) throws IOException {
+ jsonWriter.value(enumeration.getValue());
+ }
+
+ @Override
+ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOException {
+ String value = jsonReader.nextString();
+ return ArrayStringEnumDefaultEnum.fromValue(value);
+ }
+ }
+ }
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT)
+ private List arrayStringEnumDefault = null;
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT)
+ private List arrayStringDefault = null;
+
+ public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default";
+ @SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT)
+ private List arrayIntegerDefault = null;
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING)
+ private List arrayString = null;
+
+ public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable";
+ @SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE)
+ private List arrayStringNullable = null;
+
+ public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable";
+ @SerializedName(SERIALIZED_NAME_STRING_NULLABLE)
+ private String stringNullable;
+
+ public DefaultValue() {
+ }
+
+ public DefaultValue arrayStringEnumDefault(List arrayStringEnumDefault) {
+
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) {
+ if (this.arrayStringEnumDefault == null) {
+ this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
+ }
+ this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringEnumDefault
+ * @return arrayStringEnumDefault
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayStringEnumDefault() {
+ return arrayStringEnumDefault;
+ }
+
+
+ public void setArrayStringEnumDefault(List arrayStringEnumDefault) {
+ this.arrayStringEnumDefault = arrayStringEnumDefault;
+ }
+
+
+ public DefaultValue arrayStringDefault(List arrayStringDefault) {
+
+ this.arrayStringDefault = arrayStringDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) {
+ if (this.arrayStringDefault == null) {
+ this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
+ }
+ this.arrayStringDefault.add(arrayStringDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringDefault
+ * @return arrayStringDefault
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayStringDefault() {
+ return arrayStringDefault;
+ }
+
+
+ public void setArrayStringDefault(List arrayStringDefault) {
+ this.arrayStringDefault = arrayStringDefault;
+ }
+
+
+ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) {
+
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ return this;
+ }
+
+ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) {
+ if (this.arrayIntegerDefault == null) {
+ this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
+ }
+ this.arrayIntegerDefault.add(arrayIntegerDefaultItem);
+ return this;
+ }
+
+ /**
+ * Get arrayIntegerDefault
+ * @return arrayIntegerDefault
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayIntegerDefault() {
+ return arrayIntegerDefault;
+ }
+
+
+ public void setArrayIntegerDefault(List arrayIntegerDefault) {
+ this.arrayIntegerDefault = arrayIntegerDefault;
+ }
+
+
+ public DefaultValue arrayString(List arrayString) {
+
+ this.arrayString = arrayString;
+ return this;
+ }
+
+ public DefaultValue addArrayStringItem(String arrayStringItem) {
+ if (this.arrayString == null) {
+ this.arrayString = new ArrayList<>();
+ }
+ this.arrayString.add(arrayStringItem);
+ return this;
+ }
+
+ /**
+ * Get arrayString
+ * @return arrayString
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayString() {
+ return arrayString;
+ }
+
+
+ public void setArrayString(List arrayString) {
+ this.arrayString = arrayString;
+ }
+
+
+ public DefaultValue arrayStringNullable(List arrayStringNullable) {
+
+ this.arrayStringNullable = arrayStringNullable;
+ return this;
+ }
+
+ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
+ if (this.arrayStringNullable == null) {
+ this.arrayStringNullable = null;
+ }
+ this.arrayStringNullable.add(arrayStringNullableItem);
+ return this;
+ }
+
+ /**
+ * Get arrayStringNullable
+ * @return arrayStringNullable
+ **/
+ @javax.annotation.Nullable
+
+ public List getArrayStringNullable() {
+ return arrayStringNullable;
+ }
+
+
+ public void setArrayStringNullable(List arrayStringNullable) {
+ this.arrayStringNullable = arrayStringNullable;
+ }
+
+
+ public DefaultValue stringNullable(String stringNullable) {
+
+ this.stringNullable = stringNullable;
+ return this;
+ }
+
+ /**
+ * Get stringNullable
+ * @return stringNullable
+ **/
+ @javax.annotation.Nullable
+
+ public String getStringNullable() {
+ return stringNullable;
+ }
+
+
+ public void setStringNullable(String stringNullable) {
+ this.stringNullable = stringNullable;
+ }
+
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultValue defaultValue = (DefaultValue) o;
+ return Objects.equals(this.arrayStringEnumDefault, defaultValue.arrayStringEnumDefault) &&
+ Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) &&
+ Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) &&
+ Objects.equals(this.arrayString, defaultValue.arrayString) &&
+ Objects.equals(this.arrayStringNullable, defaultValue.arrayStringNullable) &&
+ Objects.equals(this.stringNullable, defaultValue.stringNullable);
+ }
+
+ private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
+ return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable);
+ }
+
+ private static int hashCodeNullable(JsonNullable a) {
+ if (a == null) {
+ return 1;
+ }
+ return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DefaultValue {\n");
+ sb.append(" arrayStringEnumDefault: ").append(toIndentedString(arrayStringEnumDefault)).append("\n");
+ sb.append(" arrayStringDefault: ").append(toIndentedString(arrayStringDefault)).append("\n");
+ sb.append(" arrayIntegerDefault: ").append(toIndentedString(arrayIntegerDefault)).append("\n");
+ sb.append(" arrayString: ").append(toIndentedString(arrayString)).append("\n");
+ sb.append(" arrayStringNullable: ").append(toIndentedString(arrayStringNullable)).append("\n");
+ sb.append(" stringNullable: ").append(toIndentedString(stringNullable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+
+ public static HashSet openapiFields;
+ public static HashSet openapiRequiredFields;
+
+ static {
+ // a set of all properties/fields (JSON key names)
+ openapiFields = new HashSet();
+ openapiFields.add("array_string_enum_default");
+ openapiFields.add("array_string_default");
+ openapiFields.add("array_integer_default");
+ openapiFields.add("array_string");
+ openapiFields.add("array_string_nullable");
+ openapiFields.add("string_nullable");
+
+ // a set of required properties/fields (JSON key names)
+ openapiRequiredFields = new HashSet();
+ }
+
+ /**
+ * Validates the JSON Object and throws an exception if issues found
+ *
+ * @param jsonObj JSON Object
+ * @throws IOException if the JSON Object is invalid with respect to DefaultValue
+ */
+ public static void validateJsonObject(JsonObject jsonObj) throws IOException {
+ if (jsonObj == null) {
+ if (!DefaultValue.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ throw new IllegalArgumentException(String.format("The required field(s) %s in DefaultValue is not found in the empty JSON string", DefaultValue.openapiRequiredFields.toString()));
+ }
+ }
+
+ Set> entries = jsonObj.entrySet();
+ // check to see if the JSON string contains additional fields
+ for (Entry entry : entries) {
+ if (!DefaultValue.openapiFields.contains(entry.getKey())) {
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DefaultValue` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ }
+ }
+ // ensure the optional json data is an array if present
+ if (jsonObj.get("array_string_enum_default") != null && !jsonObj.get("array_string_enum_default").isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected the field `array_string_enum_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_enum_default").toString()));
+ }
+ // ensure the optional json data is an array if present
+ if (jsonObj.get("array_string_default") != null && !jsonObj.get("array_string_default").isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected the field `array_string_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_default").toString()));
+ }
+ // ensure the optional json data is an array if present
+ if (jsonObj.get("array_integer_default") != null && !jsonObj.get("array_integer_default").isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected the field `array_integer_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_integer_default").toString()));
+ }
+ // ensure the optional json data is an array if present
+ if (jsonObj.get("array_string") != null && !jsonObj.get("array_string").isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected the field `array_string` to be an array in the JSON string but got `%s`", jsonObj.get("array_string").toString()));
+ }
+ // ensure the optional json data is an array if present
+ if (jsonObj.get("array_string_nullable") != null && !jsonObj.get("array_string_nullable").isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected the field `array_string_nullable` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_nullable").toString()));
+ }
+ if ((jsonObj.get("string_nullable") != null && !jsonObj.get("string_nullable").isJsonNull()) && !jsonObj.get("string_nullable").isJsonPrimitive()) {
+ throw new IllegalArgumentException(String.format("Expected the field `string_nullable` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_nullable").toString()));
+ }
+ }
+
+ public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public TypeAdapter create(Gson gson, TypeToken type) {
+ if (!DefaultValue.class.isAssignableFrom(type.getRawType())) {
+ return null; // this class only serializes 'DefaultValue' and its subtypes
+ }
+ final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
+ final TypeAdapter thisAdapter
+ = gson.getDelegateAdapter(this, TypeToken.get(DefaultValue.class));
+
+ return (TypeAdapter) new TypeAdapter() {
+ @Override
+ public void write(JsonWriter out, DefaultValue value) throws IOException {
+ JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
+ elementAdapter.write(out, obj);
+ }
+
+ @Override
+ public DefaultValue read(JsonReader in) throws IOException {
+ JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
+ validateJsonObject(jsonObj);
+ return thisAdapter.fromJsonTree(jsonObj);
+ }
+
+ }.nullSafe();
+ }
+ }
+
+ /**
+ * Create an instance of DefaultValue given an JSON string
+ *
+ * @param jsonString JSON string
+ * @return An instance of DefaultValue
+ * @throws IOException if the JSON string is invalid with respect to DefaultValue
+ */
+ public static DefaultValue fromJson(String jsonString) throws IOException {
+ return JSON.getGson().fromJson(jsonString, DefaultValue.class);
+ }
+
+ /**
+ * Convert an instance of DefaultValue to an JSON string
+ *
+ * @return JSON string
+ */
+ public String toJson() {
+ return JSON.getGson().toJson(this);
+ }
+}
+
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java
index 0e9e9a12fa1..4ec58288899 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java
@@ -140,7 +140,7 @@ public class Query {
public Query addOutcomesItem(OutcomesEnum outcomesItem) {
if (this.outcomes == null) {
- this.outcomes = new ArrayList<>();
+ this.outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
}
this.outcomes.add(outcomesItem);
return this;
diff --git a/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DefaultValueTest.java b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DefaultValueTest.java
new file mode 100644
index 00000000000..9ef0b55db29
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DefaultValueTest.java
@@ -0,0 +1,91 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.annotations.JsonAdapter;
+import com.google.gson.annotations.SerializedName;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.openapitools.jackson.nullable.JsonNullable;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+
+/**
+ * Model tests for DefaultValue
+ */
+public class DefaultValueTest {
+ private final DefaultValue model = new DefaultValue();
+
+ /**
+ * Model tests for DefaultValue
+ */
+ @Test
+ public void testDefaultValue() {
+ // TODO: test DefaultValue
+ }
+
+ /**
+ * Test the property 'arrayStringEnumDefault'
+ */
+ @Test
+ public void arrayStringEnumDefaultTest() {
+ // TODO: test arrayStringEnumDefault
+ }
+
+ /**
+ * Test the property 'arrayStringDefault'
+ */
+ @Test
+ public void arrayStringDefaultTest() {
+ // TODO: test arrayStringDefault
+ }
+
+ /**
+ * Test the property 'arrayIntegerDefault'
+ */
+ @Test
+ public void arrayIntegerDefaultTest() {
+ // TODO: test arrayIntegerDefault
+ }
+
+ /**
+ * Test the property 'arrayString'
+ */
+ @Test
+ public void arrayStringTest() {
+ // TODO: test arrayString
+ }
+
+ /**
+ * Test the property 'arrayStringNullable'
+ */
+ @Test
+ public void arrayStringNullableTest() {
+ // TODO: test arrayStringNullable
+ }
+
+ /**
+ * Test the property 'stringNullable'
+ */
+ @Test
+ public void stringNullableTest() {
+ // TODO: test stringNullable
+ }
+
+}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
index ba15c9f60f0..adac805a396 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
@@ -38,10 +38,10 @@ import java.util.StringJoiner;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class AdditionalPropertiesClass {
public static final String JSON_PROPERTY_MAP_PROPERTY = "map_property";
- private Map mapProperty = null;
+ private Map mapProperty = new HashMap<>();
public static final String JSON_PROPERTY_MAP_OF_MAP_PROPERTY = "map_of_map_property";
- private Map> mapOfMapProperty = null;
+ private Map> mapOfMapProperty = new HashMap<>();
public AdditionalPropertiesClass() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
index 28c52b25098..c0e0edadabb 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
@@ -38,7 +38,7 @@ import java.util.StringJoiner;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ArrayOfArrayOfNumberOnly {
public static final String JSON_PROPERTY_ARRAY_ARRAY_NUMBER = "ArrayArrayNumber";
- private List> arrayArrayNumber = null;
+ private List> arrayArrayNumber = new ArrayList<>();
public ArrayOfArrayOfNumberOnly() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
index b1b948208d8..d17bdca9103 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
@@ -38,7 +38,7 @@ import java.util.StringJoiner;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ArrayOfNumberOnly {
public static final String JSON_PROPERTY_ARRAY_NUMBER = "ArrayNumber";
- private List arrayNumber = null;
+ private List arrayNumber = new ArrayList<>();
public ArrayOfNumberOnly() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java
index 1107b2d5c1b..832b2bd3ca8 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java
@@ -40,13 +40,13 @@ import java.util.StringJoiner;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ArrayTest {
public static final String JSON_PROPERTY_ARRAY_OF_STRING = "array_of_string";
- private List arrayOfString = null;
+ private List arrayOfString = new ArrayList<>();
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER = "array_array_of_integer";
- private List> arrayArrayOfInteger = null;
+ private List> arrayArrayOfInteger = new ArrayList<>();
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
- private List> arrayArrayOfModel = null;
+ private List> arrayArrayOfModel = new ArrayList<>();
public ArrayTest() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java
index 98d930c37f7..adc690cf3cc 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java
@@ -111,7 +111,7 @@ public class EnumArrays {
}
public static final String JSON_PROPERTY_ARRAY_ENUM = "array_enum";
- private List arrayEnum = null;
+ private List arrayEnum = new ArrayList<>();
public EnumArrays() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
index f3f28bbd8d0..f8b0436c273 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
@@ -42,7 +42,7 @@ public class FileSchemaTestClass {
private ModelFile _file;
public static final String JSON_PROPERTY_FILES = "files";
- private List files = null;
+ private List files = new ArrayList<>();
public FileSchemaTestClass() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java
index 9470661d8fc..3760d8ad968 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java
@@ -40,7 +40,7 @@ import java.util.StringJoiner;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class MapTest {
public static final String JSON_PROPERTY_MAP_MAP_OF_STRING = "map_map_of_string";
- private Map> mapMapOfString = null;
+ private Map> mapMapOfString = new HashMap<>();
/**
* Gets or Sets inner
@@ -78,13 +78,13 @@ public class MapTest {
}
public static final String JSON_PROPERTY_MAP_OF_ENUM_STRING = "map_of_enum_string";
- private Map mapOfEnumString = null;
+ private Map mapOfEnumString = new HashMap<>();
public static final String JSON_PROPERTY_DIRECT_MAP = "direct_map";
- private Map directMap = null;
+ private Map directMap = new HashMap<>();
public static final String JSON_PROPERTY_INDIRECT_MAP = "indirect_map";
- private Map indirectMap = null;
+ private Map indirectMap = new HashMap<>();
public MapTest() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
index 689701a7d35..e2338e16854 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
@@ -48,7 +48,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
private OffsetDateTime dateTime;
public static final String JSON_PROPERTY_MAP = "map";
- private Map map = null;
+ private Map map = new HashMap<>();
public MixedPropertiesAndAdditionalPropertiesClass() {
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java
index 17de80dbc28..6c0930e4f2d 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java
@@ -81,7 +81,7 @@ public class NullableClass extends HashMap {
private JsonNullable> arrayAndItemsNullableProp = JsonNullable.>undefined();
public static final String JSON_PROPERTY_ARRAY_ITEMS_NULLABLE = "array_items_nullable";
- private List