Skip to content

Commit fd45b74

Browse files
wing328leonard84
andauthored
[Java] better default value handling (#14130)
* add test for array default value * update null return * minor fixes * move default value tests to echo api spec * add new files * remove unused files * fix enum array default, add tests * better array init * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java Co-authored-by: Leonard Brünings <lord_damokles@gmx.net> * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java Co-authored-by: Leonard Brünings <lord_damokles@gmx.net> * revert the fix * improve default value handling * update native samples, add tests * update samples * fix tests * use conditional test for timezone * add tests to apache http client echo api * add option to default container to null * fix map default value * minor refactoring * update samples * fix javadoc * fix pom.xml * add tests in java native echo client * add java apache client echo tests * fix test * fix test --------- Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>
1 parent b352734 commit fd45b74

290 files changed

Lines changed: 3688 additions & 651 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/configs/java-resttemplate.yaml

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

bin/configs/java-webclient.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ templateDir: modules/openapi-generator/src/main/resources/Java
66
additionalProperties:
77
artifactId: petstore-webclient
88
hideGenerationTimestamp: "true"
9+
containerDefaultToNull: "true"

docs/generators/groovy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2828
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
2929
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
3030
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
31+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3132
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
3233
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
3334
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

docs/generators/java-camel.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
4242
|camelUseDefaultValidationErrorProcessor|generate default validation error processor| |true|
4343
|camelValidationErrorProcessor|validation error processor bean name| |validationErrorProcessor|
4444
|configPackage|configuration package for generated code| |org.openapitools.configuration|
45+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
4546
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
4647
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
4748
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|

docs/generators/java-helidon-client.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3131
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
3232
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
3333
|configKey|Config key in @RegisterRestClient. Default to none.| |null|
34+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3435
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
3536
|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
3637
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|

docs/generators/java-helidon-server.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3030
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
3131
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
3232
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
33+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3334
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
3435
|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.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
3536
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|

docs/generators/java-inflector.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3030
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
3131
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
3232
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
33+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3334
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
3435
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
3536
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

docs/generators/java-micronaut-client.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3434
|build|Specify for which build tool to generate files|<dl><dt>**gradle**</dt><dd>Gradle configuration is generated for the project</dd><dt>**all**</dt><dd>Both Gradle and Maven configurations are generated</dd><dt>**maven**</dt><dd>Maven configuration is generated for the project</dd></dl>|all|
3535
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
3636
|configureAuth|Configure all the authorization methods as specified in the file| |false|
37+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3738
|dateFormat|Specify the format pattern of date as a string| |null|
3839
|dateLibrary|Option. Date library to use|<dl><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
3940
|datetimeFormat|Specify the format pattern of date-time as a string| |null|

docs/generators/java-micronaut-server.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3131
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
3232
|build|Specify for which build tool to generate files|<dl><dt>**gradle**</dt><dd>Gradle configuration is generated for the project</dd><dt>**all**</dt><dd>Both Gradle and Maven configurations are generated</dd><dt>**maven**</dt><dd>Maven configuration is generated for the project</dd></dl>|all|
3333
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
34+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3435
|controllerPackage|The package in which controllers will be generated| |org.openapitools.api|
3536
|dateFormat|Specify the format pattern of date as a string| |null|
3637
|dateLibrary|Option. Date library to use|<dl><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|

docs/generators/java-msf4j.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3030
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
3131
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
3232
|camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false|
33+
|containerDefaultToNull|Set containers (array, set, map) default to null| |false|
3334
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|legacy|
3435
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
3536
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|

0 commit comments

Comments
 (0)