forked from loafle/openapi-generator-original
[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>
This commit is contained in:
parent
b3527348f3
commit
fd45b74128
@ -7,3 +7,4 @@ additionalProperties:
|
||||
artifactId: petstore-resttemplate
|
||||
hideGenerationTimestamp: "true"
|
||||
java8: true
|
||||
containerDefaultToNull: true
|
||||
|
@ -6,3 +6,4 @@ templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: petstore-webclient
|
||||
hideGenerationTimestamp: "true"
|
||||
containerDefaultToNull: "true"
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|
@ -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|<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|
|
||||
|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|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|
@ -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|<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|
|
||||
|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|
|
||||
|discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|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|<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|
|
||||
|datetimeFormat|Specify the format pattern of date-time as a string| |null|
|
||||
|
@ -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|<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|
|
||||
|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|<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|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<dl><dt>**joda**</dt><dd>Joda (for legacy app only)</dd><dt>**legacy**</dt><dd>Legacy java.util.Date</dd><dt>**java8-localdatetime**</dt><dd>Java 8 using LocalDateTime (for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for jdk 1.8+)</dd></dl>|java8|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
|
||||
|
@ -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|<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|
|
||||
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|
||||
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|
||||
|
@ -2188,6 +2188,21 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return " = data." + name + ";";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of the property
|
||||
* <p>
|
||||
* 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;
|
||||
|
@ -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<String, String> 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
|
||||
* <p>
|
||||
* 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<String> _values = new ArrayList<>();
|
||||
|
||||
if (schema.getDefault() instanceof ArrayNode) { // array of default values
|
||||
ArrayNode _default = (ArrayNode) schema.getDefault();
|
||||
if (_default.isEmpty()) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
List<String> 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<String> 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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<String, String>()");
|
||||
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<String, ComplexModel>()");
|
||||
Assert.assertEquals(defaultValue, "null", "Expected string-ref map aliased model to default to null since nullable is not set to tru");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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:
|
||||
|
7
openapitools.json
Normal file
7
openapitools.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
||||
"spaces": 2,
|
||||
"generator-cli": {
|
||||
"version": "6.2.1"
|
||||
}
|
||||
}
|
1
pom.xml
1
pom.xml
@ -1296,6 +1296,7 @@
|
||||
<module>samples/client/others/java/okhttp-gson-streaming</module>
|
||||
<module>samples/client/petstore/java/okhttp-gson</module>
|
||||
<module>samples/client/petstore/java-micronaut-client</module>
|
||||
<module>samples/client/petstore/java/apache-httpclient</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<!-- test with Haskell -->
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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" |
|
||||
|
||||
|
||||
|
@ -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<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
private List<String> arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
private List<Integer> arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING = "array_string";
|
||||
private List<String> arrayString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
private JsonNullable<List<String>> arrayStringNullable = JsonNullable.<List<String>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable";
|
||||
private JsonNullable<String> stringNullable = JsonNullable.<String>undefined();
|
||||
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> 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<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> 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<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> 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<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> 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<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
|
||||
if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>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<String> getArrayStringNullable() {
|
||||
return arrayStringNullable.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<List<String>> getArrayStringNullable_JsonNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
public void setArrayStringNullable_JsonNullable(JsonNullable<List<String>> arrayStringNullable) {
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
}
|
||||
|
||||
public void setArrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue stringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>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<String> getStringNullable_JsonNullable() {
|
||||
return stringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
|
||||
public void setStringNullable_JsonNullable(JsonNullable<String> stringNullable) {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
public void setStringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>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 <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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 <T> int hashCodeNullable(JsonNullable<T> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
@ -78,7 +78,7 @@ public class Query {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_OUTCOMES = "outcomes";
|
||||
private List<OutcomesEnum> outcomes = null;
|
||||
private List<OutcomesEnum> 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;
|
||||
|
@ -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<String> values = null;
|
||||
private List<String> values = new ArrayList<>();
|
||||
|
||||
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
|
||||
}
|
||||
|
@ -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<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);
|
||||
|
||||
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<DefaultValue>() {
|
||||
});
|
||||
|
||||
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<DefaultValue>() {
|
||||
});
|
||||
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])");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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<ArrayStringEnumDefaultEnum> {
|
||||
@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<ArrayStringEnumDefaultEnum> 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<String> 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<Integer> arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING)
|
||||
private List<String> arrayString = new ArrayList<>();
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE)
|
||||
private List<String> 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<ArrayStringEnumDefaultEnum> 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<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> 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<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> 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<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> 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<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> 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<String> getArrayStringNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringNullable(List<String> 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 <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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 <T> int hashCodeNullable(JsonNullable<T> 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 ");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class Pet {
|
||||
|
||||
public static final String SERIALIZED_NAME_TAGS = "tags";
|
||||
@SerializedName(SERIALIZED_NAME_TAGS)
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
@ -84,7 +84,7 @@ public class Query {
|
||||
|
||||
public static final String SERIALIZED_NAME_OUTCOMES = "outcomes";
|
||||
@SerializedName(SERIALIZED_NAME_OUTCOMES)
|
||||
private List<OutcomesEnum> outcomes = null;
|
||||
private List<OutcomesEnum> 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;
|
||||
|
@ -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<String> values = null;
|
||||
private List<String> values = new ArrayList<>();
|
||||
|
||||
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
29
samples/client/echo_api/java/native/docs/DefaultValue.md
Normal file
29
samples/client/echo_api/java/native/docs/DefaultValue.md
Normal file
@ -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" |
|
||||
|
||||
|
||||
|
@ -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<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
private List<String> arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped"));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
private List<Integer> arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3));
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING = "array_string";
|
||||
private List<String> arrayString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
private JsonNullable<List<String>> arrayStringNullable = JsonNullable.<List<String>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable";
|
||||
private JsonNullable<String> stringNullable = JsonNullable.<String>undefined();
|
||||
|
||||
public DefaultValue() {
|
||||
}
|
||||
|
||||
public DefaultValue arrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> 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<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> 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<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> 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<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> 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<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) {
|
||||
if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>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<String> getArrayStringNullable() {
|
||||
return arrayStringNullable.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<List<String>> getArrayStringNullable_JsonNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE)
|
||||
public void setArrayStringNullable_JsonNullable(JsonNullable<List<String>> arrayStringNullable) {
|
||||
this.arrayStringNullable = arrayStringNullable;
|
||||
}
|
||||
|
||||
public void setArrayStringNullable(List<String> arrayStringNullable) {
|
||||
this.arrayStringNullable = JsonNullable.<List<String>>of(arrayStringNullable);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue stringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>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<String> getStringNullable_JsonNullable() {
|
||||
return stringNullable;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_STRING_NULLABLE)
|
||||
public void setStringNullable_JsonNullable(JsonNullable<String> stringNullable) {
|
||||
this.stringNullable = stringNullable;
|
||||
}
|
||||
|
||||
public void setStringNullable(String stringNullable) {
|
||||
this.stringNullable = JsonNullable.<String>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 <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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 <T> int hashCodeNullable(JsonNullable<T> 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();
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class Pet {
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
@ -80,7 +80,7 @@ public class Query {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_OUTCOMES = "outcomes";
|
||||
private List<OutcomesEnum> outcomes = null;
|
||||
private List<OutcomesEnum> outcomes = new ArrayList<>(Arrays.asList(OutcomesEnum.SUCCESS, OutcomesEnum.FAILURE));
|
||||
|
||||
public Query() {
|
||||
}
|
||||
|
@ -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<String> values = null;
|
||||
private List<String> values = new ArrayList<>();
|
||||
|
||||
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter() {
|
||||
}
|
||||
|
@ -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<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);
|
||||
|
||||
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<DefaultValue>() {
|
||||
});
|
||||
|
||||
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<DefaultValue>() {
|
||||
});
|
||||
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])");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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" |
|
||||
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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<ArrayStringEnumDefaultEnum> {
|
||||
@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<ArrayStringEnumDefaultEnum> arrayStringEnumDefault = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT)
|
||||
private List<String> arrayStringDefault = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT)
|
||||
private List<Integer> arrayIntegerDefault = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING)
|
||||
private List<String> arrayString = null;
|
||||
|
||||
public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable";
|
||||
@SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE)
|
||||
private List<String> 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<ArrayStringEnumDefaultEnum> 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<ArrayStringEnumDefaultEnum> getArrayStringEnumDefault() {
|
||||
return arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringEnumDefault(List<ArrayStringEnumDefaultEnum> arrayStringEnumDefault) {
|
||||
this.arrayStringEnumDefault = arrayStringEnumDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringDefault(List<String> 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<String> getArrayStringDefault() {
|
||||
return arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringDefault(List<String> arrayStringDefault) {
|
||||
this.arrayStringDefault = arrayStringDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayIntegerDefault(List<Integer> 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<Integer> getArrayIntegerDefault() {
|
||||
return arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayIntegerDefault(List<Integer> arrayIntegerDefault) {
|
||||
this.arrayIntegerDefault = arrayIntegerDefault;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayString(List<String> 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<String> getArrayString() {
|
||||
return arrayString;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayString(List<String> arrayString) {
|
||||
this.arrayString = arrayString;
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue arrayStringNullable(List<String> 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<String> getArrayStringNullable() {
|
||||
return arrayStringNullable;
|
||||
}
|
||||
|
||||
|
||||
public void setArrayStringNullable(List<String> 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 <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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 <T> int hashCodeNullable(JsonNullable<T> 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<String> openapiFields;
|
||||
public static HashSet<String> openapiRequiredFields;
|
||||
|
||||
static {
|
||||
// a set of all properties/fields (JSON key names)
|
||||
openapiFields = new HashSet<String>();
|
||||
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<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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 <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!DefaultValue.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'DefaultValue' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<DefaultValue> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(DefaultValue.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<DefaultValue>() {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -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<String, String> mapProperty = null;
|
||||
private Map<String, String> mapProperty = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_OF_MAP_PROPERTY = "map_of_map_property";
|
||||
private Map<String, Map<String, String>> mapOfMapProperty = null;
|
||||
private Map<String, Map<String, String>> mapOfMapProperty = new HashMap<>();
|
||||
|
||||
public AdditionalPropertiesClass() {
|
||||
}
|
||||
|
@ -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<List<BigDecimal>> arrayArrayNumber = null;
|
||||
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<>();
|
||||
|
||||
public ArrayOfArrayOfNumberOnly() {
|
||||
}
|
||||
|
@ -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<BigDecimal> arrayNumber = null;
|
||||
private List<BigDecimal> arrayNumber = new ArrayList<>();
|
||||
|
||||
public ArrayOfNumberOnly() {
|
||||
}
|
||||
|
@ -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<String> arrayOfString = null;
|
||||
private List<String> arrayOfString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER = "array_array_of_integer";
|
||||
private List<List<Long>> arrayArrayOfInteger = null;
|
||||
private List<List<Long>> arrayArrayOfInteger = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = null;
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = new ArrayList<>();
|
||||
|
||||
public ArrayTest() {
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ENUM = "array_enum";
|
||||
private List<ArrayEnumEnum> arrayEnum = null;
|
||||
private List<ArrayEnumEnum> arrayEnum = new ArrayList<>();
|
||||
|
||||
public EnumArrays() {
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class FileSchemaTestClass {
|
||||
private ModelFile _file;
|
||||
|
||||
public static final String JSON_PROPERTY_FILES = "files";
|
||||
private List<ModelFile> files = null;
|
||||
private List<ModelFile> files = new ArrayList<>();
|
||||
|
||||
public FileSchemaTestClass() {
|
||||
}
|
||||
|
@ -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<String, Map<String, String>> mapMapOfString = null;
|
||||
private Map<String, Map<String, String>> 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<String, InnerEnum> mapOfEnumString = null;
|
||||
private Map<String, InnerEnum> mapOfEnumString = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_DIRECT_MAP = "direct_map";
|
||||
private Map<String, Boolean> directMap = null;
|
||||
private Map<String, Boolean> directMap = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_INDIRECT_MAP = "indirect_map";
|
||||
private Map<String, Boolean> indirectMap = null;
|
||||
private Map<String, Boolean> indirectMap = new HashMap<>();
|
||||
|
||||
public MapTest() {
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
private OffsetDateTime dateTime;
|
||||
|
||||
public static final String JSON_PROPERTY_MAP = "map";
|
||||
private Map<String, Animal> map = null;
|
||||
private Map<String, Animal> map = new HashMap<>();
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass() {
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
private JsonNullable<List<Object>> arrayAndItemsNullableProp = JsonNullable.<List<Object>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ITEMS_NULLABLE = "array_items_nullable";
|
||||
private List<Object> arrayItemsNullable = null;
|
||||
private List<Object> arrayItemsNullable = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_OBJECT_NULLABLE_PROP = "object_nullable_prop";
|
||||
private JsonNullable<Map<String, Object>> objectNullableProp = JsonNullable.<Map<String, Object>>undefined();
|
||||
@ -90,7 +90,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
private JsonNullable<Map<String, Object>> objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_OBJECT_ITEMS_NULLABLE = "object_items_nullable";
|
||||
private Map<String, Object> objectItemsNullable = null;
|
||||
private Map<String, Object> objectItemsNullable = new HashMap<>();
|
||||
|
||||
public NullableClass() {
|
||||
|
||||
@ -308,7 +308,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) {
|
||||
if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) {
|
||||
this.arrayNullableProp = JsonNullable.<List<Object>>of(new ArrayList<>());
|
||||
this.arrayNullableProp = JsonNullable.<List<Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.arrayNullableProp.get().add(arrayNullablePropItem);
|
||||
@ -354,7 +354,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) {
|
||||
if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) {
|
||||
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(new ArrayList<>());
|
||||
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.arrayAndItemsNullableProp.get().add(arrayAndItemsNullablePropItem);
|
||||
@ -434,7 +434,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass putObjectNullablePropItem(String key, Object objectNullablePropItem) {
|
||||
if (this.objectNullableProp == null || !this.objectNullableProp.isPresent()) {
|
||||
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(new HashMap<>());
|
||||
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.objectNullableProp.get().put(key, objectNullablePropItem);
|
||||
@ -480,7 +480,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) {
|
||||
if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) {
|
||||
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(new HashMap<>());
|
||||
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.objectAndItemsNullableProp.get().put(key, objectAndItemsNullablePropItem);
|
||||
|
@ -51,7 +51,7 @@ public class ObjectWithDeprecatedFields {
|
||||
private DeprecatedObject deprecatedRef;
|
||||
|
||||
public static final String JSON_PROPERTY_BARS = "bars";
|
||||
private List<String> bars = null;
|
||||
private List<String> bars = new ArrayList<>();
|
||||
|
||||
public ObjectWithDeprecatedFields() {
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class Pet {
|
||||
private Set<String> photoUrls = new LinkedHashSet<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
@ -47,28 +47,28 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class AdditionalPropertiesClass {
|
||||
public static final String JSON_PROPERTY_MAP_STRING = "map_string";
|
||||
private Map<String, String> mapString = null;
|
||||
private Map<String, String> mapString = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_NUMBER = "map_number";
|
||||
private Map<String, BigDecimal> mapNumber = null;
|
||||
private Map<String, BigDecimal> mapNumber = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_INTEGER = "map_integer";
|
||||
private Map<String, Integer> mapInteger = null;
|
||||
private Map<String, Integer> mapInteger = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_BOOLEAN = "map_boolean";
|
||||
private Map<String, Boolean> mapBoolean = null;
|
||||
private Map<String, Boolean> mapBoolean = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_ARRAY_INTEGER = "map_array_integer";
|
||||
private Map<String, List<Integer>> mapArrayInteger = null;
|
||||
private Map<String, List<Integer>> mapArrayInteger = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_ARRAY_ANYTYPE = "map_array_anytype";
|
||||
private Map<String, List<Object>> mapArrayAnytype = null;
|
||||
private Map<String, List<Object>> mapArrayAnytype = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_MAP_STRING = "map_map_string";
|
||||
private Map<String, Map<String, String>> mapMapString = null;
|
||||
private Map<String, Map<String, String>> mapMapString = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_MAP_ANYTYPE = "map_map_anytype";
|
||||
private Map<String, Map<String, Object>> mapMapAnytype = null;
|
||||
private Map<String, Map<String, Object>> mapMapAnytype = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ANYTYPE1 = "anytype_1";
|
||||
private Object anytype1;
|
||||
|
@ -36,7 +36,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class ArrayOfArrayOfNumberOnly {
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_NUMBER = "ArrayArrayNumber";
|
||||
private List<List<BigDecimal>> arrayArrayNumber = null;
|
||||
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<>();
|
||||
|
||||
public ArrayOfArrayOfNumberOnly() {
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class ArrayOfNumberOnly {
|
||||
public static final String JSON_PROPERTY_ARRAY_NUMBER = "ArrayNumber";
|
||||
private List<BigDecimal> arrayNumber = null;
|
||||
private List<BigDecimal> arrayNumber = new ArrayList<>();
|
||||
|
||||
public ArrayOfNumberOnly() {
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@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<String> arrayOfString = null;
|
||||
private List<String> arrayOfString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER = "array_array_of_integer";
|
||||
private List<List<Long>> arrayArrayOfInteger = null;
|
||||
private List<List<Long>> arrayArrayOfInteger = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = null;
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = new ArrayList<>();
|
||||
|
||||
public ArrayTest() {
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ENUM = "array_enum";
|
||||
private List<ArrayEnumEnum> arrayEnum = null;
|
||||
private List<ArrayEnumEnum> arrayEnum = new ArrayList<>();
|
||||
|
||||
public EnumArrays() {
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class FileSchemaTestClass {
|
||||
private File file;
|
||||
|
||||
public static final String JSON_PROPERTY_FILES = "files";
|
||||
private List<File> files = null;
|
||||
private List<File> files = new ArrayList<>();
|
||||
|
||||
public FileSchemaTestClass() {
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@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<String, Map<String, String>> mapMapOfString = null;
|
||||
private Map<String, Map<String, String>> mapMapOfString = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Gets or Sets inner
|
||||
@ -76,13 +76,13 @@ public class MapTest {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_OF_ENUM_STRING = "map_of_enum_string";
|
||||
private Map<String, InnerEnum> mapOfEnumString = null;
|
||||
private Map<String, InnerEnum> mapOfEnumString = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_DIRECT_MAP = "direct_map";
|
||||
private Map<String, Boolean> directMap = null;
|
||||
private Map<String, Boolean> directMap = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_INDIRECT_MAP = "indirect_map";
|
||||
private Map<String, Boolean> indirectMap = null;
|
||||
private Map<String, Boolean> indirectMap = new HashMap<>();
|
||||
|
||||
public MapTest() {
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
private OffsetDateTime dateTime;
|
||||
|
||||
public static final String JSON_PROPERTY_MAP = "map";
|
||||
private Map<String, Animal> map = null;
|
||||
private Map<String, Animal> map = new HashMap<>();
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass() {
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class Pet {
|
||||
private Set<String> photoUrls = new LinkedHashSet<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
@ -76,7 +76,7 @@ public class XmlItem {
|
||||
private Boolean attributeBoolean;
|
||||
|
||||
public static final String JSON_PROPERTY_WRAPPED_ARRAY = "wrapped_array";
|
||||
private List<Integer> wrappedArray = null;
|
||||
private List<Integer> wrappedArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_NAME_STRING = "name_string";
|
||||
private String nameString;
|
||||
@ -91,10 +91,10 @@ public class XmlItem {
|
||||
private Boolean nameBoolean;
|
||||
|
||||
public static final String JSON_PROPERTY_NAME_ARRAY = "name_array";
|
||||
private List<Integer> nameArray = null;
|
||||
private List<Integer> nameArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_NAME_WRAPPED_ARRAY = "name_wrapped_array";
|
||||
private List<Integer> nameWrappedArray = null;
|
||||
private List<Integer> nameWrappedArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_PREFIX_STRING = "prefix_string";
|
||||
private String prefixString;
|
||||
@ -109,10 +109,10 @@ public class XmlItem {
|
||||
private Boolean prefixBoolean;
|
||||
|
||||
public static final String JSON_PROPERTY_PREFIX_ARRAY = "prefix_array";
|
||||
private List<Integer> prefixArray = null;
|
||||
private List<Integer> prefixArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_PREFIX_WRAPPED_ARRAY = "prefix_wrapped_array";
|
||||
private List<Integer> prefixWrappedArray = null;
|
||||
private List<Integer> prefixWrappedArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_NAMESPACE_STRING = "namespace_string";
|
||||
private String namespaceString;
|
||||
@ -127,10 +127,10 @@ public class XmlItem {
|
||||
private Boolean namespaceBoolean;
|
||||
|
||||
public static final String JSON_PROPERTY_NAMESPACE_ARRAY = "namespace_array";
|
||||
private List<Integer> namespaceArray = null;
|
||||
private List<Integer> namespaceArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_NAMESPACE_WRAPPED_ARRAY = "namespace_wrapped_array";
|
||||
private List<Integer> namespaceWrappedArray = null;
|
||||
private List<Integer> namespaceWrappedArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_PREFIX_NS_STRING = "prefix_ns_string";
|
||||
private String prefixNsString;
|
||||
@ -145,10 +145,10 @@ public class XmlItem {
|
||||
private Boolean prefixNsBoolean;
|
||||
|
||||
public static final String JSON_PROPERTY_PREFIX_NS_ARRAY = "prefix_ns_array";
|
||||
private List<Integer> prefixNsArray = null;
|
||||
private List<Integer> prefixNsArray = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_PREFIX_NS_WRAPPED_ARRAY = "prefix_ns_wrapped_array";
|
||||
private List<Integer> prefixNsWrappedArray = null;
|
||||
private List<Integer> prefixNsWrappedArray = new ArrayList<>();
|
||||
|
||||
public XmlItem() {
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class AdditionalPropertiesClass {
|
||||
public static final String JSON_PROPERTY_MAP_PROPERTY = "map_property";
|
||||
private Map<String, String> mapProperty = null;
|
||||
private Map<String, String> mapProperty = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_OF_MAP_PROPERTY = "map_of_map_property";
|
||||
private Map<String, Map<String, String>> mapOfMapProperty = null;
|
||||
private Map<String, Map<String, String>> mapOfMapProperty = new HashMap<>();
|
||||
|
||||
public AdditionalPropertiesClass() {
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class ArrayOfArrayOfNumberOnly {
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_NUMBER = "ArrayArrayNumber";
|
||||
private List<List<BigDecimal>> arrayArrayNumber = null;
|
||||
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<>();
|
||||
|
||||
public ArrayOfArrayOfNumberOnly() {
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class ArrayOfNumberOnly {
|
||||
public static final String JSON_PROPERTY_ARRAY_NUMBER = "ArrayNumber";
|
||||
private List<BigDecimal> arrayNumber = null;
|
||||
private List<BigDecimal> arrayNumber = new ArrayList<>();
|
||||
|
||||
public ArrayOfNumberOnly() {
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@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<String> arrayOfString = null;
|
||||
private List<String> arrayOfString = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER = "array_array_of_integer";
|
||||
private List<List<Long>> arrayArrayOfInteger = null;
|
||||
private List<List<Long>> arrayArrayOfInteger = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = null;
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = new ArrayList<>();
|
||||
|
||||
public ArrayTest() {
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ENUM = "array_enum";
|
||||
private List<ArrayEnumEnum> arrayEnum = null;
|
||||
private List<ArrayEnumEnum> arrayEnum = new ArrayList<>();
|
||||
|
||||
public EnumArrays() {
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class FileSchemaTestClass {
|
||||
private File file;
|
||||
|
||||
public static final String JSON_PROPERTY_FILES = "files";
|
||||
private List<File> files = null;
|
||||
private List<File> files = new ArrayList<>();
|
||||
|
||||
public FileSchemaTestClass() {
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@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<String, Map<String, String>> mapMapOfString = null;
|
||||
private Map<String, Map<String, String>> mapMapOfString = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Gets or Sets inner
|
||||
@ -75,13 +75,13 @@ public class MapTest {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_MAP_OF_ENUM_STRING = "map_of_enum_string";
|
||||
private Map<String, InnerEnum> mapOfEnumString = null;
|
||||
private Map<String, InnerEnum> mapOfEnumString = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_DIRECT_MAP = "direct_map";
|
||||
private Map<String, Boolean> directMap = null;
|
||||
private Map<String, Boolean> directMap = new HashMap<>();
|
||||
|
||||
public static final String JSON_PROPERTY_INDIRECT_MAP = "indirect_map";
|
||||
private Map<String, Boolean> indirectMap = null;
|
||||
private Map<String, Boolean> indirectMap = new HashMap<>();
|
||||
|
||||
public MapTest() {
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
private OffsetDateTime dateTime;
|
||||
|
||||
public static final String JSON_PROPERTY_MAP = "map";
|
||||
private Map<String, Animal> map = null;
|
||||
private Map<String, Animal> map = new HashMap<>();
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass() {
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
private JsonNullable<List<Object>> arrayAndItemsNullableProp = JsonNullable.<List<Object>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_ARRAY_ITEMS_NULLABLE = "array_items_nullable";
|
||||
private List<Object> arrayItemsNullable = null;
|
||||
private List<Object> arrayItemsNullable = new ArrayList<>();
|
||||
|
||||
public static final String JSON_PROPERTY_OBJECT_NULLABLE_PROP = "object_nullable_prop";
|
||||
private JsonNullable<Map<String, Object>> objectNullableProp = JsonNullable.<Map<String, Object>>undefined();
|
||||
@ -87,7 +87,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
private JsonNullable<Map<String, Object>> objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>undefined();
|
||||
|
||||
public static final String JSON_PROPERTY_OBJECT_ITEMS_NULLABLE = "object_items_nullable";
|
||||
private Map<String, Object> objectItemsNullable = null;
|
||||
private Map<String, Object> objectItemsNullable = new HashMap<>();
|
||||
|
||||
public NullableClass() {
|
||||
|
||||
@ -305,7 +305,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) {
|
||||
if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) {
|
||||
this.arrayNullableProp = JsonNullable.<List<Object>>of(new ArrayList<>());
|
||||
this.arrayNullableProp = JsonNullable.<List<Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.arrayNullableProp.get().add(arrayNullablePropItem);
|
||||
@ -351,7 +351,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) {
|
||||
if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) {
|
||||
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(new ArrayList<>());
|
||||
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.arrayAndItemsNullableProp.get().add(arrayAndItemsNullablePropItem);
|
||||
@ -431,7 +431,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass putObjectNullablePropItem(String key, Object objectNullablePropItem) {
|
||||
if (this.objectNullableProp == null || !this.objectNullableProp.isPresent()) {
|
||||
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(new HashMap<>());
|
||||
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.objectNullableProp.get().put(key, objectNullablePropItem);
|
||||
@ -477,7 +477,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) {
|
||||
if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) {
|
||||
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(new HashMap<>());
|
||||
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(null);
|
||||
}
|
||||
try {
|
||||
this.objectAndItemsNullableProp.get().put(key, objectAndItemsNullablePropItem);
|
||||
|
@ -48,7 +48,7 @@ public class ObjectWithDeprecatedFields {
|
||||
private DeprecatedObject deprecatedRef;
|
||||
|
||||
public static final String JSON_PROPERTY_BARS = "bars";
|
||||
private List<String> bars = null;
|
||||
private List<String> bars = new ArrayList<>();
|
||||
|
||||
public ObjectWithDeprecatedFields() {
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class Pet {
|
||||
private Set<String> photoUrls = new LinkedHashSet<>();
|
||||
|
||||
public static final String JSON_PROPERTY_TAGS = "tags";
|
||||
private List<Tag> tags = null;
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user