diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/beanValidation.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/beanValidation.mustache index e427a43a0acd..0aed4a92d734 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/beanValidation.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/beanValidation.mustache @@ -1 +1 @@ -{{#required}}{{^isReadOnly}}@NotNull {{/isReadOnly}}{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}@Valid {{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}@Valid {{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}} \ No newline at end of file +{{#required}}{{^isReadOnly}}@NotNull {{/isReadOnly}}{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}@Valid {{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}@Valid {{/isPrimitiveType}}{{/isContainer}}{{^openApiNullable}}{{>beanValidationCore}}{{/openApiNullable}}{{#openApiNullable}}{{^useOptional}}{{>beanValidationCore}}{{/useOptional}}{{/openApiNullable}}{{#useOptional}}{{#openApiNullable}}{{#isContainer}}{{^required}}{{>beanValidationCore}}{{/required}}{{/isContainer}}{{/openApiNullable}}{{#openApiNullable}}{{#required}}{{>beanValidationCore}}{{/required}}{{/openApiNullable}}{{/useOptional}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/beanValidationCore.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/beanValidationCore.mustache index 25138626ce7c..1e347f2f9505 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/beanValidationCore.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/beanValidationCore.mustache @@ -12,9 +12,9 @@ minLength not set, maxLength set @Size: minItems not set && maxItems set }}{{^minItems}}{{#maxItems}}@Size(max = {{.}}) {{/maxItems}}{{/minItems}}{{! @Email: useBeanValidation -}}{{#isEmail}}{{#useBeanValidation}}@{{javaxPackage}}.validation.constraints.Email{{/useBeanValidation}}{{! +}}{{#isEmail}}{{#useBeanValidation}}@{{javaxPackage}}.validation.constraints.Email {{/useBeanValidation}}{{! @Email: performBeanValidation exclusive -}}{{^useBeanValidation}}{{#performBeanValidation}}@org.hibernate.validator.constraints.Email{{/performBeanValidation}}{{/useBeanValidation}}{{/isEmail}}{{! +}}{{^useBeanValidation}}{{#performBeanValidation}}@org.hibernate.validator.constraints.Email {{/performBeanValidation}}{{/useBeanValidation}}{{/isEmail}}{{! check for integer or long / all others=decimal type with @Decimal* isInteger set }}{{#isInteger}}{{#minimum}}@Min({{.}}) {{/minimum}}{{#maximum}}@Max({{.}}) {{/maximum}}{{/isInteger}}{{! diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataType.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataType.mustache index ba9bb946318e..fd94338fcf4d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataType.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataType.mustache @@ -1 +1 @@ -{{#openApiNullable}}{{#isNullable}}JsonNullable<{{{datatypeWithEnum}}}>{{/isNullable}}{{^isNullable}}{{{datatypeWithEnum}}}{{/isNullable}}{{/openApiNullable}}{{^openApiNullable}}{{{datatypeWithEnum}}}{{/openApiNullable}} \ No newline at end of file +{{#openApiNullable}}{{#isNullable}}JsonNullable<{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional<{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{{datatypeWithEnum}}}{{#openApiNullable}}{{#isNullable}}>{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}>{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataTypeBeanValidation.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataTypeBeanValidation.mustache new file mode 100644 index 000000000000..8d6fc6deca2a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/nullableDataTypeBeanValidation.mustache @@ -0,0 +1 @@ +{{#openApiNullable}}{{#isNullable}}{{^isContainer}}JsonNullable<{{#useBeanValidation}}{{>beanValidationCore}}{{/useBeanValidation}}{{/isContainer}}{{#isContainer}}JsonNullable<{{/isContainer}}{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional<{{#useBeanValidation}}{{>beanValidationCore}}{{/useBeanValidation}}{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{{datatypeWithEnum}}}{{#openApiNullable}}{{#isNullable}}>{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}>{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache index 8874448a597d..45caf64ee3fc 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache @@ -65,7 +65,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}} {{#isContainer}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} {{#openApiNullable}} - private {{>nullableDataType}} {{name}}{{#isNullable}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined(){{/isNullable}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}}; + private {{#isNullable}}{{>nullableDataTypeBeanValidation}} {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();{{/isNullable}}{{^required}}{{^isNullable}}{{>nullableDataTypeBeanValidation}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/isNullable}}{{/required}}{{#required}}{{^isNullable}}{{>nullableDataTypeBeanValidation}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/isNullable}}{{/required}} {{/openApiNullable}} {{^openApiNullable}} private {{>nullableDataType}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}; @@ -79,7 +79,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}} @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) {{/isDateTime}} {{#openApiNullable}} - private {{>nullableDataType}} {{name}}{{#isNullable}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined(){{/isNullable}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}}; + private {{#isNullable}}{{>nullableDataTypeBeanValidation}} {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();{{/isNullable}}{{^required}}{{^isNullable}}{{>nullableDataTypeBeanValidation}} {{name}}{{#useOptional}} = Optional.{{^defaultValue}}empty(){{/defaultValue}}{{#defaultValue}}of({{{.}}}){{/defaultValue}};{{/useOptional}}{{^useOptional}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/useOptional}}{{/isNullable}}{{/required}}{{^isNullable}}{{#required}}{{>nullableDataTypeBeanValidation}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/required}}{{/isNullable}} {{/openApiNullable}} {{^openApiNullable}} private {{>nullableDataType}} {{name}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}}; @@ -103,7 +103,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}} {{#vars}} {{#required}} {{#openApiNullable}} - this.{{name}} = {{#isNullable}}JsonNullable.of({{name}}){{/isNullable}}{{^isNullable}}{{name}}{{/isNullable}}; + this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional.ofNullable({{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{name}}{{#isNullable}}){{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}){{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}; {{/openApiNullable}} {{^openApiNullable}} this.{{name}} = {{name}}; @@ -118,7 +118,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}} {{! begin feature: fluent setter methods }} public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { {{#openApiNullable}} - this.{{name}} = {{#isNullable}}JsonNullable.of({{name}}){{/isNullable}}{{^isNullable}}{{name}}{{/isNullable}}; + this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional.of({{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{name}}{{#isNullable}}){{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}){{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}; {{/openApiNullable}} {{^openApiNullable}} this.{{name}} = {{name}}; @@ -203,7 +203,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}} {{#deprecated}} @Deprecated {{/deprecated}} - public {{>nullableDataType}} {{getter}}() { + public {{>nullableDataTypeBeanValidation}} {{getter}}() { return {{name}}; } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/MethodAssert.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/MethodAssert.java index 0eed63a86a5e..cdfb564ff75a 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/MethodAssert.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/MethodAssert.java @@ -54,6 +54,13 @@ public MethodAssert doesNotHaveParameter(final String paramName) { return this; } + public MethodAssert doesNotHaveParameters() { + Assertions.assertThat(actual.getParameters()) + .withFailMessage("Method %s shouldn't have parameter, but it does", methodSignature) + .isEmpty(); + return this; + } + public MethodAssert bodyContainsLines(final String... lines) { Assertions.assertThat(isWithImplementation()) .withFailMessage("Method %s is abstract", methodSignature) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index 4095c2104da3..ae01734ec88d 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -47,6 +47,7 @@ import java.io.File; import java.io.IOException; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; @@ -56,6 +57,7 @@ import java.util.function.Function; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.assertj.core.api.MapAssert; import org.openapitools.codegen.CliOption; import org.openapitools.codegen.ClientOptInput; @@ -178,6 +180,84 @@ public void doAnnotateDatesOnModelParameters() throws IOException { .doesNotHaveComment(); } + @Test + public void doAnnotateDatesOnModelParametersWithOptionalAndJsonNullable() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/issue_5436.yml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOpenApiNullable(true); + codegen.setUseOptional(true); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + generator.opts(input).generate(); + + JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java")) + .assertTypeAnnotations() + .hasSize(3) + .containsWithName("Validated") + .containsWithName("Generated") + .containsWithNameAndAttributes("Generated", ImmutableMap.of( + "value", "\"org.openapitools.codegen.languages.SpringCodegen\"" + )) + .containsWithNameAndAttributes("Tag", ImmutableMap.of( + "name", "\"zebras\"" + )) + .toType() + .assertMethod("getZebras") + .hasReturnType("ResponseEntity") + .assertMethodAnnotations() + .hasSize(2) + .containsWithNameAndAttributes("Operation", ImmutableMap.of("operationId", "\"getZebras\"")) + .containsWithNameAndAttributes("RequestMapping", ImmutableMap.of( + "method", "RequestMethod.GET", + "value", "\"/zebras\"" + )) + .toMethod() + .hasParameter("limit").withType("Optional") + .assertParameterAnnotations() + .containsWithName("Valid") + .containsWithNameAndAttributes("Parameter", ImmutableMap.of("name", "\"limit\"")) + .containsWithNameAndAttributes("RequestParam", ImmutableMap.of("required", "false", "value", "\"limit\"")) + .toParameter() + .toMethod() + .hasParameter("animalParams").withType("Optional") + .toMethod() + .commentContainsLines("GET /zebras", "@param limit (optional)") + .bodyContainsLines("return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)"); + + JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/model/AnimalParams.java")) + .hasImports("org.springframework.format.annotation.DateTimeFormat") + .hasProperty("born").withType("Optional") + .assertPropertyAnnotations() + .containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE")) + .toProperty() + .toType() + .hasProperty("lastSeen").withType("Optional") + .assertPropertyAnnotations() + .containsWithNameAndAttributes("DateTimeFormat", ImmutableMap.of("iso", "DateTimeFormat.ISO.DATE_TIME")) + .toProperty().toType() + .assertMethod("born", "LocalDate") + .bodyContainsLines("this.born = Optional.of(born)") + .doesNotHaveComment(); + } + @Test public void doGenerateCookieParams() throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); @@ -987,7 +1067,6 @@ public void shouldAddValidAnnotationIntoCollectionWhenBeanValidationIsEnabled_is ; } - // Helper function, intended to reduce boilerplate private Map generateFiles(SpringCodegen codegen, String filePath) throws IOException { final File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); @@ -3185,6 +3264,985 @@ public void doCallFluentParentSettersFromChildModel() throws IOException { .assertNoMethod("setAlias"); } + + + @Test + public void testModelsWithNoneOptionalAndJsonNullable() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/issue_14765.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.setOpenApiNullable(true); + codegen.setUseOptional(false); + codegen.setUseSpringBoot3(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + generator.opts(input).generate(); + + + JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Animal.java")) + .hasImports("jakarta.validation.Valid") + .hasImports("jakarta.validation.constraints") + + .hasProperty("name") + .withType( "String" ) + .toType() + .hasProperty("age") + .withType( "JsonNullable" ) + .toType() + .hasProperty("alias") + .withType( "JsonNullable" ) + .toType() + .hasProperty("color") + .withType( "String" ) + .toType() + .hasProperty("names") + .withType( "List" ) + .toType() + .hasProperty("colors") + .withType( "JsonNullable>" ) + .toType() + .hasProperty("stringPattern") + .withType( "String" ) + .toType() + .hasProperty("stringMaxMinLength") + .withType( "String" ) + .toType() + .hasProperty("stringMinLength") + .withType( "String" ) + .toType() + .hasProperty("stringMaxLength") + .withType( "String" ) + .toType() + .hasProperty("stringEmail") + .withType( "String" ) + .toType() + .hasProperty("intMinMax") + .withType( "Integer" ) + .toType() + .hasProperty("intMin") + .withType( "Integer" ) + .toType() + .hasProperty("intMax") + .withType( "Integer" ) + .toType() + .hasProperty("numberMinMax") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMin") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMax") + .withType( "BigDecimal" ) + .toType() + .hasProperty("stringDefault") + .withType( "String" ) + .toType() + .fileContains("stringDefault = \"ABC\"") + .hasProperty("zebra") + .withType( "Zebra" ) + .toType() + + .hasProperty("stringPatternNullable") + .withType( "JsonNullable<@Pattern(regexp = \"[a-z]\") String>" ) + .toType() + .hasProperty("stringMaxMinLengthNullable") + .withType( "JsonNullable<@Size(min = 1, max = 10) String>" ) + .toType() + .hasProperty("stringMinLengthNullable") + .withType( "JsonNullable<@Size(min = 1) String>" ) + .toType() + .hasProperty("stringMaxLengthNullable") + .withType( "JsonNullable<@Size(max = 1) String>" ) + .toType() + .hasProperty("intMinMaxNullable") + .withType( "JsonNullable<@Min(1) @Max(10) Integer>" ) + .toType() + .hasProperty("intMinNullable") + .withType( "JsonNullable<@Min(1) Integer>" ) + .toType() + .hasProperty("intMaxNullable") + .withType( "JsonNullable<@Max(10) Integer>" ) + .toType() + .hasProperty("numberMinMaxNullable") + .withType( "JsonNullable<@DecimalMin(\"1\") @DecimalMax(\"10\") BigDecimal>" ) + .toType() + .hasProperty("numberMinNullable") + .withType( "JsonNullable<@DecimalMin(\"1\") BigDecimal>" ) + .toType() + .hasProperty("numberMaxNullable") + .withType( "JsonNullable<@DecimalMax(\"10\") BigDecimal>" ) + .toType() + .hasProperty("stringDefaultNullable") + .withType( "JsonNullable<@Size(max = 1) String>" ) + .toType() + .fileContains("stringDefaultNullable = JsonNullable.undefined();") + + .assertMethod("name") + .hasReturnType("Animal") + .bodyContainsLines("this.name = name;", "return this;") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setName") + .hasReturnType("void") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getName") + .hasReturnType("String") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("colors") + .hasReturnType("Animal") + .bodyContainsLines("this.colors = JsonNullable.of(colors);", "return this;") + .hasParameter("colors") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setColors") + .hasReturnType("void") + .hasParameter("colors") + .withType("JsonNullable>") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getColors") + .hasReturnType("JsonNullable>") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("names") + .hasReturnType("Animal") + .bodyContainsLines("this.names = names;", "return this;") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setNames") + .hasReturnType("void") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getNames") + .hasReturnType("List") + .doesNotHaveParameters() + .toFileAssert(); + + assertJsonNullableMethod(javaFileAssert, Integer.class, "age", "JsonNullable"); + assertJsonNullableMethod(javaFileAssert, String.class, "alias", "JsonNullable"); + assertMethod(javaFileAssert, String.class, "color"); + + assertMethod(javaFileAssert, String.class, "stringPattern"); + assertMethod(javaFileAssert, String.class, "stringMaxMinLength"); + assertMethod(javaFileAssert, String.class, "stringMinLength"); + assertMethod(javaFileAssert, String.class, "stringMaxLength"); + assertMethod(javaFileAssert, String.class, "stringEmail"); + assertMethod(javaFileAssert, Integer.class, "intMinMax"); + assertMethod(javaFileAssert, Integer.class, "intMin"); + assertMethod(javaFileAssert, Integer.class, "intMax"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinMax"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMin"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMax"); + assertMethod(javaFileAssert, "Zebra", "zebra"); + + assertJsonNullableMethod(javaFileAssert, String.class, "stringPatternNullable", "JsonNullable<@Pattern(regexp = \"[a-z]\") String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringMaxMinLengthNullable", "JsonNullable<@Size(min = 1, max = 10) String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringMinLengthNullable", "JsonNullable<@Size(min = 1) String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringMaxLengthNullable", "JsonNullable<@Size(max = 1) String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringEmailNullable", "JsonNullable<@jakarta.validation.constraints.Email String>"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "intMinMaxNullable", "JsonNullable<@Min(1) @Max(10) Integer>"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "intMinNullable", "JsonNullable<@Min(1) Integer>"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "intMaxNullable", "JsonNullable<@Max(10) Integer>"); + assertJsonNullableMethod(javaFileAssert, BigDecimal.class, "numberMinMaxNullable", "JsonNullable<@DecimalMin(\"1\") @DecimalMax(\"10\") BigDecimal>"); + assertJsonNullableMethod(javaFileAssert, BigDecimal.class, "numberMinNullable", "JsonNullable<@DecimalMin(\"1\") BigDecimal>"); + assertJsonNullableMethod(javaFileAssert, BigDecimal.class, "numberMaxNullable", "JsonNullable<@DecimalMax(\"10\") BigDecimal>"); + + } + + @Test + public void testModelsWithOptionalAndJsonNullable() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/issue_14765.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.setOpenApiNullable(true); + codegen.setUseOptional(true); + codegen.setUseSpringBoot3(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + generator.opts(input).generate(); + + + JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Animal.java")) + .hasImports("jakarta.validation.Valid") + .hasImports("jakarta.validation.constraints") + + .hasProperty("name") + .withType( "String" ) + .toType() + .hasProperty("age") + .withType( "JsonNullable" ) + .toType() + .hasProperty("alias") + .withType( "JsonNullable" ) + .toType() + .hasProperty("color") + .withType( "Optional" ) + .toType() + .hasProperty("names") + .withType( "List" ) + .toType() + .hasProperty("colors") + .withType( "JsonNullable>" ) + .toType() + .hasProperty("stringPattern") + .withType( "Optional<@Pattern(regexp = \"[a-z]\") String>" ) + .toType() + .hasProperty("stringMaxMinLength") + .withType( "Optional<@Size(min = 1, max = 10) String>" ) + .toType() + .hasProperty("stringMinLength") + .withType( "Optional<@Size(min = 1) String>" ) + .toType() + .hasProperty("stringMaxLength") + .withType( "Optional<@Size(max = 1) String>" ) + .toType() + .hasProperty("stringEmail") + .withType( "Optional<@jakarta.validation.constraints.Email String>" ) + .toType() + .hasProperty("intMinMax") + .withType( "Optional<@Min(1) @Max(10) Integer>" ) + .toType() + .hasProperty("intMin") + .withType( "Optional<@Min(1) Integer>" ) + .toType() + .hasProperty("intMax") + .withType( "Optional<@Max(10) Integer>" ) + .toType() + .hasProperty("numberMinMax") + .withType( "Optional<@DecimalMin(\"1\") @DecimalMax(\"10\") BigDecimal>" ) + .toType() + .hasProperty("numberMin") + .withType( "Optional<@DecimalMin(\"1\") BigDecimal>" ) + .toType() + .hasProperty("numberMax") + .withType( "Optional<@DecimalMax(\"10\") BigDecimal>" ) + .toType() + .hasProperty("stringDefault") + .withType( "Optional<@Size(max = 1) String>" ) + .toType() + .fileContains("stringDefault = Optional.of(\"ABC\")") + .hasProperty("zebra") + .withType( "Optional" ) + .toType() + + .hasProperty("stringPatternNullable") + .withType( "JsonNullable<@Pattern(regexp = \"[a-z]\") String>" ) + .toType() + .hasProperty("stringMaxMinLengthNullable") + .withType( "JsonNullable<@Size(min = 1, max = 10) String>" ) + .toType() + .hasProperty("stringMinLengthNullable") + .withType( "JsonNullable<@Size(min = 1) String>" ) + .toType() + .hasProperty("stringMaxLengthNullable") + .withType( "JsonNullable<@Size(max = 1) String>" ) + .toType() + .hasProperty("intMinMaxNullable") + .withType( "JsonNullable<@Min(1) @Max(10) Integer>" ) + .toType() + .hasProperty("intMinNullable") + .withType( "JsonNullable<@Min(1) Integer>" ) + .toType() + .hasProperty("intMaxNullable") + .withType( "JsonNullable<@Max(10) Integer>" ) + .toType() + .hasProperty("numberMinMaxNullable") + .withType( "JsonNullable<@DecimalMin(\"1\") @DecimalMax(\"10\") BigDecimal>" ) + .toType() + .hasProperty("numberMinNullable") + .withType( "JsonNullable<@DecimalMin(\"1\") BigDecimal>" ) + .toType() + .hasProperty("numberMaxNullable") + .withType( "JsonNullable<@DecimalMax(\"10\") BigDecimal>" ) + .toType() + .hasProperty("stringDefaultNullable") + .withType( "JsonNullable<@Size(max = 1) String>" ) + .toType() + .fileContains("stringDefaultNullable = JsonNullable.undefined();") + + .assertMethod("name") + .hasReturnType("Animal") + .bodyContainsLines("this.name = name;", "return this;") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setName") + .hasReturnType("void") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getName") + .hasReturnType("String") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("colors") + .hasReturnType("Animal") + .bodyContainsLines("this.colors = JsonNullable.of(colors);", "return this;") + .hasParameter("colors") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setColors") + .hasReturnType("void") + .hasParameter("colors") + .withType("JsonNullable>") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getColors") + .hasReturnType("JsonNullable>") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("names") + .hasReturnType("Animal") + .bodyContainsLines("this.names = names;", "return this;") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setNames") + .hasReturnType("void") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getNames") + .hasReturnType("List") + .doesNotHaveParameters() + .toFileAssert(); + + assertJsonNullableMethod(javaFileAssert, String.class, "alias", "JsonNullable"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "age", "JsonNullable"); + assertOptionalMethod(javaFileAssert, String.class, "color", "Optional"); + + assertOptionalMethod(javaFileAssert, String.class, "stringPattern", "Optional<@Pattern(regexp = \"[a-z]\") String>"); + assertOptionalMethod(javaFileAssert, String.class, "stringMaxMinLength", "Optional<@Size(min = 1, max = 10) String>"); + assertOptionalMethod(javaFileAssert, String.class, "stringMinLength", "Optional<@Size(min = 1) String>"); + assertOptionalMethod(javaFileAssert, String.class, "stringMaxLength", "Optional<@Size(max = 1) String>"); + assertOptionalMethod(javaFileAssert, String.class, "stringEmail", "Optional<@jakarta.validation.constraints.Email String>"); + assertOptionalMethod(javaFileAssert, Integer.class, "intMinMax", "Optional<@Min(1) @Max(10) Integer>"); + assertOptionalMethod(javaFileAssert, Integer.class, "intMin", "Optional<@Min(1) Integer>"); + assertOptionalMethod(javaFileAssert, Integer.class, "intMax", "Optional<@Max(10) Integer>"); + assertOptionalMethod(javaFileAssert, BigDecimal.class, "numberMinMax", "Optional<@DecimalMin(\"1\") @DecimalMax(\"10\") BigDecimal>"); + assertOptionalMethod(javaFileAssert, BigDecimal.class, "numberMin", "Optional<@DecimalMin(\"1\") BigDecimal>"); + assertOptionalMethod(javaFileAssert, BigDecimal.class, "numberMax", "Optional<@DecimalMax(\"10\") BigDecimal>"); + assertOptionalMethod(javaFileAssert,"Zebra", "zebra", "Optional"); + + assertJsonNullableMethod(javaFileAssert, String.class, "stringPatternNullable", "JsonNullable<@Pattern(regexp = \"[a-z]\") String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringMaxMinLengthNullable", "JsonNullable<@Size(min = 1, max = 10) String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringMinLengthNullable", "JsonNullable<@Size(min = 1) String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringMaxLengthNullable", "JsonNullable<@Size(max = 1) String>"); + assertJsonNullableMethod(javaFileAssert, String.class, "stringEmailNullable", "JsonNullable<@jakarta.validation.constraints.Email String>"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "intMinMaxNullable", "JsonNullable<@Min(1) @Max(10) Integer>"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "intMinNullable", "JsonNullable<@Min(1) Integer>"); + assertJsonNullableMethod(javaFileAssert, Integer.class, "intMaxNullable", "JsonNullable<@Max(10) Integer>"); + assertJsonNullableMethod(javaFileAssert, BigDecimal.class, "numberMinMaxNullable", "JsonNullable<@DecimalMin(\"1\") @DecimalMax(\"10\") BigDecimal>"); + assertJsonNullableMethod(javaFileAssert, BigDecimal.class, "numberMinNullable", "JsonNullable<@DecimalMin(\"1\") BigDecimal>"); + assertJsonNullableMethod(javaFileAssert, BigDecimal.class, "numberMaxNullable", "JsonNullable<@DecimalMax(\"10\") BigDecimal>"); + + } + + @Test + public void testModelsWithOptionalAndNoneJsonNullable() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/issue_14765.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.setOpenApiNullable(false); + codegen.setUseOptional(true); + codegen.setUseSpringBoot3(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + generator.opts(input).generate(); + + + JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Animal.java")) + .hasImports("jakarta.validation.Valid") + .hasImports("jakarta.validation.constraints") + + .hasProperty("name") + .withType( "String" ) + .toType() + .hasProperty("age") + .withType( "Integer" ) + .toType() + .hasProperty("alias") + .withType( "String" ) + .toType() + .hasProperty("color") + .withType( "String" ) + .toType() + .hasProperty("names") + .withType( "List" ) + .toType() + .hasProperty("colors") + .withType( "List" ) + .toType() + .hasProperty("stringPattern") + .withType( "String" ) + .toType() + .hasProperty("stringMaxMinLength") + .withType( "String" ) + .toType() + .hasProperty("stringMinLength") + .withType( "String" ) + .toType() + .hasProperty("stringMaxLength") + .withType( "String" ) + .toType() + .hasProperty("stringEmail") + .withType( "String" ) + .toType() + .hasProperty("intMinMax") + .withType( "Integer" ) + .toType() + .hasProperty("intMin") + .withType( "Integer" ) + .toType() + .hasProperty("intMax") + .withType( "Integer" ) + .toType() + .hasProperty("numberMinMax") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMin") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMax") + .withType( "BigDecimal" ) + .toType() + .hasProperty("stringDefault") + .withType( "String" ) + .toType() + .fileContains("stringDefault = \"ABC\"") + .hasProperty("zebra") + .withType( "Zebra" ) + .toType() + + .hasProperty("stringPatternNullable") + .withType( "String" ) + .toType() + .hasProperty("stringMaxMinLengthNullable") + .withType( "String" ) + .toType() + .hasProperty("stringMinLengthNullable") + .withType( "String" ) + .toType() + .hasProperty("stringMaxLengthNullable") + .withType( "String" ) + .toType() + .hasProperty("intMinMaxNullable") + .withType( "Integer" ) + .toType() + .hasProperty("intMinNullable") + .withType( "Integer" ) + .toType() + .hasProperty("intMaxNullable") + .withType( "Integer" ) + .toType() + .hasProperty("numberMinMaxNullable") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMinNullable") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMaxNullable") + .withType( "BigDecimal" ) + .toType() + .hasProperty("stringDefaultNullable") + .withType( "String" ) + .toType() + .fileContains("stringDefaultNullable = null;") + + .assertMethod("name") + .hasReturnType("Animal") + .bodyContainsLines("this.name = name;", "return this;") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setName") + .hasReturnType("void") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getName") + .hasReturnType("String") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("age") + .hasReturnType("Animal") + .bodyContainsLines("this.age = age;", "return this;") + .hasParameter("age") + .withType("Integer") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setAge") + .hasReturnType("void") + .hasParameter("age") + .withType("Integer") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getAge") + .hasReturnType("Integer") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("colors") + .hasReturnType("Animal") + .bodyContainsLines("this.colors = colors;", "return this;") + .hasParameter("colors") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setColors") + .hasReturnType("void") + .hasParameter("colors") + .withType("List") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getColors") + .hasReturnType("List") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("names") + .hasReturnType("Animal") + .bodyContainsLines("this.names = names;", "return this;") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setNames") + .hasReturnType("void") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getNames") + .hasReturnType("List") + .doesNotHaveParameters() + .toFileAssert(); + + assertMethod(javaFileAssert, String.class, "alias"); + assertMethod(javaFileAssert, String.class, "color"); + + assertMethod(javaFileAssert, String.class, "stringPattern"); + assertMethod(javaFileAssert, String.class, "stringMaxMinLength"); + assertMethod(javaFileAssert, String.class, "stringMinLength"); + assertMethod(javaFileAssert, String.class, "stringMaxLength"); + assertMethod(javaFileAssert, String.class, "stringEmail"); + assertMethod(javaFileAssert, Integer.class, "intMinMax"); + assertMethod(javaFileAssert, Integer.class, "intMin"); + assertMethod(javaFileAssert, Integer.class, "intMax"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinMax"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMin"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMax"); + assertMethod(javaFileAssert, "Zebra", "zebra"); + + assertMethod(javaFileAssert, String.class, "stringPatternNullable"); + assertMethod(javaFileAssert, String.class, "stringMaxMinLengthNullable"); + assertMethod(javaFileAssert, String.class, "stringMinLengthNullable"); + assertMethod(javaFileAssert, String.class, "stringMaxLengthNullable"); + assertMethod(javaFileAssert, String.class, "stringEmailNullable"); + assertMethod(javaFileAssert, Integer.class, "intMinMaxNullable"); + assertMethod(javaFileAssert, Integer.class, "intMinNullable"); + assertMethod(javaFileAssert, Integer.class, "intMaxNullable"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinMaxNullable"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinNullable"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMaxNullable"); + + } + + @Test + public void testModelsWithNoneOptionalAndNoneOpenApiNullable() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/issue_14765.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.setOpenApiNullable(false); + codegen.setUseOptional(false); + codegen.setUseSpringBoot3(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + generator.opts(input).generate(); + + + JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Animal.java")) + .hasImports("jakarta.validation.Valid") + .hasImports("jakarta.validation.constraints") + + .hasProperty("name") + .withType( "String" ) + .toType() + .hasProperty("age") + .withType( "Integer" ) + .toType() + .hasProperty("alias") + .withType( "String" ) + .toType() + .hasProperty("color") + .withType( "String" ) + .toType() + .hasProperty("names") + .withType( "List" ) + .toType() + .hasProperty("colors") + .withType( "List" ) + .toType() + .hasProperty("stringPattern") + .withType( "String" ) + .toType() + .hasProperty("stringMaxMinLength") + .withType( "String" ) + .toType() + .hasProperty("stringMinLength") + .withType( "String" ) + .toType() + .hasProperty("stringMaxLength") + .withType( "String" ) + .toType() + .hasProperty("stringEmail") + .withType( "String" ) + .toType() + .hasProperty("intMinMax") + .withType( "Integer" ) + .toType() + .hasProperty("intMin") + .withType( "Integer" ) + .toType() + .hasProperty("intMax") + .withType( "Integer" ) + .toType() + .hasProperty("numberMinMax") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMin") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMax") + .withType( "BigDecimal" ) + .toType() + .hasProperty("stringDefault") + .withType( "String" ) + .toType() + .fileContains("stringDefault = \"ABC\"") + .hasProperty("zebra") + .withType( "Zebra" ) + .toType() + + .hasProperty("stringPatternNullable") + .withType( "String" ) + .toType() + .hasProperty("stringMaxMinLengthNullable") + .withType( "String" ) + .toType() + .hasProperty("stringMinLengthNullable") + .withType( "String" ) + .toType() + .hasProperty("stringMaxLengthNullable") + .withType( "String" ) + .toType() + .hasProperty("intMinMaxNullable") + .withType( "Integer" ) + .toType() + .hasProperty("intMinNullable") + .withType( "Integer" ) + .toType() + .hasProperty("intMaxNullable") + .withType( "Integer" ) + .toType() + .hasProperty("numberMinMaxNullable") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMinNullable") + .withType( "BigDecimal" ) + .toType() + .hasProperty("numberMaxNullable") + .withType( "BigDecimal" ) + .toType() + .hasProperty("stringDefaultNullable") + .withType( "String" ) + .toType() + .fileContains("stringDefaultNullable = null;") + + .assertMethod("name") + .hasReturnType("Animal") + .bodyContainsLines("this.name = name;", "return this;") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setName") + .hasReturnType("void") + .hasParameter("name") + .withType("String") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getName") + .hasReturnType("String") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("age") + .hasReturnType("Animal") + .bodyContainsLines("this.age = age;", "return this;") + .hasParameter("age") + .withType("Integer") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setAge") + .hasReturnType("void") + .hasParameter("age") + .withType("Integer") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getAge") + .hasReturnType("Integer") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("colors") + .hasReturnType("Animal") + .bodyContainsLines("this.colors = colors;", "return this;") + .hasParameter("colors") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setColors") + .hasReturnType("void") + .hasParameter("colors") + .withType("List") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getColors") + .hasReturnType("List") + .doesNotHaveParameters() + .toFileAssert() + + .assertMethod("names") + .hasReturnType("Animal") + .bodyContainsLines("this.names = names;", "return this;") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("setNames") + .hasReturnType("void") + .hasParameter("names") + .withType("List") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("getNames") + .hasReturnType("List") + .doesNotHaveParameters() + .toFileAssert(); + + assertMethod(javaFileAssert, String.class, "alias"); + assertMethod(javaFileAssert, String.class, "color"); + + assertMethod(javaFileAssert, String.class, "stringPattern"); + assertMethod(javaFileAssert, String.class, "stringMaxMinLength"); + assertMethod(javaFileAssert, String.class, "stringMinLength"); + assertMethod(javaFileAssert, String.class, "stringMaxLength"); + assertMethod(javaFileAssert, String.class, "stringEmail"); + assertMethod(javaFileAssert, Integer.class, "intMinMax"); + assertMethod(javaFileAssert, Integer.class, "intMin"); + assertMethod(javaFileAssert, Integer.class, "intMax"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinMax"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMin"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMax"); + assertMethod(javaFileAssert, "Zebra", "zebra"); + + assertMethod(javaFileAssert, String.class, "stringPatternNullable"); + assertMethod(javaFileAssert, String.class, "stringMaxMinLengthNullable"); + assertMethod(javaFileAssert, String.class, "stringMinLengthNullable"); + assertMethod(javaFileAssert, String.class, "stringMaxLengthNullable"); + assertMethod(javaFileAssert, String.class, "stringEmailNullable"); + assertMethod(javaFileAssert, Integer.class, "intMinMaxNullable"); + assertMethod(javaFileAssert, Integer.class, "intMinNullable"); + assertMethod(javaFileAssert, Integer.class, "intMaxNullable"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinMaxNullable"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMinNullable"); + assertMethod(javaFileAssert, BigDecimal.class, "numberMaxNullable"); + + } + + private void assertOptionalMethod(JavaFileAssert javaFileAssert, Class type, String expectedName, String getterReturnType){ + assertOptionalMethod(javaFileAssert, type.getSimpleName(), expectedName, getterReturnType); + } + + private void assertOptionalMethod(JavaFileAssert javaFileAssert, String type, String expectedName, String getterReturnType){ + assertWrapperMethod(javaFileAssert, "Optional", type, expectedName, getterReturnType); + } + + private void assertJsonNullableMethod(JavaFileAssert javaFileAssert, Class type, String expectedName, String getterReturnType){ + assertJsonNullableMethod(javaFileAssert, type.getSimpleName(), expectedName, getterReturnType); + } + + private void assertJsonNullableMethod(JavaFileAssert javaFileAssert, String type, String expectedName, String getterReturnType){ + assertWrapperMethod(javaFileAssert, "JsonNullable", type, expectedName, getterReturnType); + } + + private void assertWrapperMethod(JavaFileAssert javaFileAssert, String wrapperType, String type, String expectedName, String getterReturnType){ + String methodName = StringUtils.capitalize(expectedName); + javaFileAssert.assertMethod(expectedName) + .hasReturnType("Animal") + .bodyContainsLines("this."+expectedName+" = "+wrapperType+".of("+expectedName+");", "return this;") + .hasParameter(expectedName) + .withType(type) + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("set"+methodName) + .hasReturnType("void") + .hasParameter(expectedName) + .withType(wrapperType+"<"+type+">") + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("get"+methodName) + .hasReturnType(getterReturnType) + .doesNotHaveParameters() + .toFileAssert(); + } + + private void assertMethod(JavaFileAssert javaFileAssert, String type, String expectedName){ + String methodName = StringUtils.capitalize(expectedName); + javaFileAssert.assertMethod(expectedName) + .hasReturnType("Animal") + .bodyContainsLines("this."+expectedName+" = "+ expectedName + ";", "return this;") + .hasParameter(expectedName) + .withType(type) + .toMethod() + .toFileAssert() + // Setter method assertions + .assertMethod("set"+methodName) + .hasReturnType("void") + .hasParameter(expectedName) + .withType(type) + .toMethod() + .toFileAssert() + // Getter method assertions + .assertMethod("get"+methodName) + .hasReturnType(type) + .doesNotHaveParameters() + .toFileAssert(); + } + + private void assertMethod(JavaFileAssert javaFileAssert, Class type, String expectedName){ + assertMethod(javaFileAssert,type.getSimpleName(), expectedName); + } + + @Test public void multiLineOperationDescription() throws IOException { Map additionalProperties = new HashMap<>(); diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_14765.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_14765.yaml new file mode 100644 index 000000000000..cb1cfb180b9f --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/issue_14765.yaml @@ -0,0 +1,166 @@ +openapi: 3.0.0 +servers: + - url: 'localhost:8080' +info: + version: 1.0.0 + title: OpenAPI Zoo + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +paths: + /zebras: + get: + operationId: getZebras + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Animal' + +components: + schemas: + Zebra: + required: + - name + - age + type: object + properties: + name: + type: string + example: 'Marty' + age: + type: integer + example: 15 + nullable: true + Animal: + required: + - name + - age + type: object + properties: + name: + type: string + example: 'Marty' + age: + type: integer + example: 15 + nullable: true + alias: + type: string + nullable: true + description: 'The stripy one' + example: 'Stripy' + color: + type: string + description: 'The color' + example: 'red' + + names: + type: array + items: + type: string + colors: + type: array + nullable: true + items: + type: string + + stringPattern: + type: string + pattern: "[a-z]" + stringMaxMinLength: + type: string + minLength: 1 + maxLength: 10 + stringMinLength: + type: string + minLength: 1 + stringMaxLength: + type: string + maxLength: 1 + stringEmail: + type: string + format: email + intMinMax: + type: integer + minimum: 1 + maximum: 10 + intMin: + type: integer + minimum: 1 + intMax: + type: integer + maximum: 10 + numberMinMax: + type: number + minimum: 1 + maximum: 10 + numberMin: + type: number + minimum: 1 + numberMax: + type: number + maximum: 10 + stringDefault: + type: string + maxLength: 1 + default: "ABC" + zebra: + $ref: '#/components/schemas/Zebra' + + stringPatternNullable: + nullable: true + type: string + pattern: "[a-z]" + stringMaxMinLengthNullable: + nullable: true + type: string + minLength: 1 + maxLength: 10 + stringMinLengthNullable: + nullable: true + type: string + minLength: 1 + stringMaxLengthNullable: + nullable: true + type: string + maxLength: 1 + stringEmailNullable: + nullable: true + type: string + format: email + intMinMaxNullable: + nullable: true + type: integer + minimum: 1 + maximum: 10 + intMinNullable: + nullable: true + type: integer + minimum: 1 + intMaxNullable: + nullable: true + type: integer + maximum: 10 + numberMinMaxNullable: + nullable: true + type: number + minimum: 1 + maximum: 10 + numberMinNullable: + nullable: true + type: number + minimum: 1 + numberMaxNullable: + nullable: true + type: number + maximum: 10 + stringDefaultNullable: + type: string + nullable: true + maxLength: 1 + default: "ABC" diff --git a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Category.java b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Category.java index b24ec01be79c..58d36477cf71 100644 --- a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Category.java +++ b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Category.java @@ -20,12 +20,12 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Category { - private Long id; + private Optional id = Optional.empty(); - private String name; + private Optional<@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") String> name = Optional.empty(); public Category id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -35,16 +35,16 @@ public Category id(Long id) { */ @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Category name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -52,13 +52,13 @@ public Category name(String name) { * Get name * @return name */ - @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @JsonProperty("name") - public String getName() { + public Optional<@Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") String> getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } diff --git a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/ModelApiResponse.java index 0bf61b71b160..922c22a484ff 100644 --- a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -22,14 +22,14 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ModelApiResponse { - private Integer code; + private Optional code = Optional.empty(); - private String type; + private Optional type = Optional.empty(); - private String message; + private Optional message = Optional.empty(); public ModelApiResponse code(Integer code) { - this.code = code; + this.code = Optional.of(code); return this; } @@ -39,16 +39,16 @@ public ModelApiResponse code(Integer code) { */ @JsonProperty("code") - public Integer getCode() { + public Optional getCode() { return code; } - public void setCode(Integer code) { + public void setCode(Optional code) { this.code = code; } public ModelApiResponse type(String type) { - this.type = type; + this.type = Optional.of(type); return this; } @@ -58,16 +58,16 @@ public ModelApiResponse type(String type) { */ @JsonProperty("type") - public String getType() { + public Optional getType() { return type; } - public void setType(String type) { + public void setType(Optional type) { this.type = type; } public ModelApiResponse message(String message) { - this.message = message; + this.message = Optional.of(message); return this; } @@ -77,11 +77,11 @@ public ModelApiResponse message(String message) { */ @JsonProperty("message") - public String getMessage() { + public Optional getMessage() { return message; } - public void setMessage(String message) { + public void setMessage(Optional message) { this.message = message; } diff --git a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Order.java b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Order.java index 16f368d9fe47..53096900e253 100644 --- a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Order.java +++ b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Order.java @@ -23,14 +23,14 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Order { - private Long id; + private Optional id = Optional.empty(); - private Long petId; + private Optional petId = Optional.empty(); - private Integer quantity; + private Optional quantity = Optional.empty(); @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private OffsetDateTime shipDate; + private Optional shipDate = Optional.empty(); /** * Order Status @@ -69,12 +69,12 @@ public static StatusEnum fromValue(String value) { } } - private StatusEnum status; + private Optional status = Optional.empty(); - private Boolean complete = false; + private Optional complete = Optional.of(false); public Order id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -84,16 +84,16 @@ public Order id(Long id) { */ @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Order petId(Long petId) { - this.petId = petId; + this.petId = Optional.of(petId); return this; } @@ -103,16 +103,16 @@ public Order petId(Long petId) { */ @JsonProperty("petId") - public Long getPetId() { + public Optional getPetId() { return petId; } - public void setPetId(Long petId) { + public void setPetId(Optional petId) { this.petId = petId; } public Order quantity(Integer quantity) { - this.quantity = quantity; + this.quantity = Optional.of(quantity); return this; } @@ -122,16 +122,16 @@ public Order quantity(Integer quantity) { */ @JsonProperty("quantity") - public Integer getQuantity() { + public Optional getQuantity() { return quantity; } - public void setQuantity(Integer quantity) { + public void setQuantity(Optional quantity) { this.quantity = quantity; } public Order shipDate(OffsetDateTime shipDate) { - this.shipDate = shipDate; + this.shipDate = Optional.of(shipDate); return this; } @@ -141,16 +141,16 @@ public Order shipDate(OffsetDateTime shipDate) { */ @Valid @JsonProperty("shipDate") - public OffsetDateTime getShipDate() { + public Optional getShipDate() { return shipDate; } - public void setShipDate(OffsetDateTime shipDate) { + public void setShipDate(Optional shipDate) { this.shipDate = shipDate; } public Order status(StatusEnum status) { - this.status = status; + this.status = Optional.of(status); return this; } @@ -160,16 +160,16 @@ public Order status(StatusEnum status) { */ @JsonProperty("status") - public StatusEnum getStatus() { + public Optional getStatus() { return status; } - public void setStatus(StatusEnum status) { + public void setStatus(Optional status) { this.status = status; } public Order complete(Boolean complete) { - this.complete = complete; + this.complete = Optional.of(complete); return this; } @@ -179,11 +179,11 @@ public Order complete(Boolean complete) { */ @JsonProperty("complete") - public Boolean getComplete() { + public Optional getComplete() { return complete; } - public void setComplete(Boolean complete) { + public void setComplete(Optional complete) { this.complete = complete; } diff --git a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Pet.java b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Pet.java index b80b957cba16..8d7bb11fc161 100644 --- a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Pet.java +++ b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Pet.java @@ -26,9 +26,9 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Pet { - private Long id; + private Optional id = Optional.empty(); - private Category category; + private Optional category = Optional.empty(); private String name; @@ -76,7 +76,7 @@ public static StatusEnum fromValue(String value) { } @Deprecated - private StatusEnum status; + private Optional status = Optional.empty(); public Pet() { super(); @@ -91,7 +91,7 @@ public Pet(String name, List photoUrls) { } public Pet id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -101,16 +101,16 @@ public Pet id(Long id) { */ @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Pet category(Category category) { - this.category = category; + this.category = Optional.of(category); return this; } @@ -120,11 +120,11 @@ public Pet category(Category category) { */ @Valid @JsonProperty("category") - public Category getCategory() { + public Optional getCategory() { return category; } - public void setCategory(Category category) { + public void setCategory(Optional category) { this.category = category; } @@ -202,7 +202,7 @@ public void setTags(List<@Valid Tag> tags) { } public Pet status(StatusEnum status) { - this.status = status; + this.status = Optional.of(status); return this; } @@ -214,7 +214,7 @@ public Pet status(StatusEnum status) { @JsonProperty("status") @Deprecated - public StatusEnum getStatus() { + public Optional getStatus() { return status; } @@ -222,7 +222,7 @@ public StatusEnum getStatus() { * @deprecated */ @Deprecated - public void setStatus(StatusEnum status) { + public void setStatus(Optional status) { this.status = status; } diff --git a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Tag.java b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Tag.java index 1fe5ae4afdc8..f5ea2f8743a6 100644 --- a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Tag.java +++ b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/Tag.java @@ -20,12 +20,12 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Tag { - private Long id; + private Optional id = Optional.empty(); - private String name; + private Optional name = Optional.empty(); public Tag id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -35,16 +35,16 @@ public Tag id(Long id) { */ @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Tag name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -54,11 +54,11 @@ public Tag name(String name) { */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } diff --git a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/User.java b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/User.java index 8145125bfede..6deefb0b8f42 100644 --- a/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/User.java +++ b/samples/openapi3/client/petstore/spring-cloud-3-with-optional/src/main/java/org/openapitools/model/User.java @@ -20,24 +20,24 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class User { - private Long id; + private Optional id = Optional.empty(); - private String username; + private Optional username = Optional.empty(); - private String firstName; + private Optional firstName = Optional.empty(); - private String lastName; + private Optional lastName = Optional.empty(); - private String email; + private Optional email = Optional.empty(); - private String password; + private Optional password = Optional.empty(); - private String phone; + private Optional phone = Optional.empty(); - private Integer userStatus; + private Optional userStatus = Optional.empty(); public User id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -47,16 +47,16 @@ public User id(Long id) { */ @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public User username(String username) { - this.username = username; + this.username = Optional.of(username); return this; } @@ -66,16 +66,16 @@ public User username(String username) { */ @JsonProperty("username") - public String getUsername() { + public Optional getUsername() { return username; } - public void setUsername(String username) { + public void setUsername(Optional username) { this.username = username; } public User firstName(String firstName) { - this.firstName = firstName; + this.firstName = Optional.of(firstName); return this; } @@ -85,16 +85,16 @@ public User firstName(String firstName) { */ @JsonProperty("firstName") - public String getFirstName() { + public Optional getFirstName() { return firstName; } - public void setFirstName(String firstName) { + public void setFirstName(Optional firstName) { this.firstName = firstName; } public User lastName(String lastName) { - this.lastName = lastName; + this.lastName = Optional.of(lastName); return this; } @@ -104,16 +104,16 @@ public User lastName(String lastName) { */ @JsonProperty("lastName") - public String getLastName() { + public Optional getLastName() { return lastName; } - public void setLastName(String lastName) { + public void setLastName(Optional lastName) { this.lastName = lastName; } public User email(String email) { - this.email = email; + this.email = Optional.of(email); return this; } @@ -123,16 +123,16 @@ public User email(String email) { */ @JsonProperty("email") - public String getEmail() { + public Optional getEmail() { return email; } - public void setEmail(String email) { + public void setEmail(Optional email) { this.email = email; } public User password(String password) { - this.password = password; + this.password = Optional.of(password); return this; } @@ -142,16 +142,16 @@ public User password(String password) { */ @JsonProperty("password") - public String getPassword() { + public Optional getPassword() { return password; } - public void setPassword(String password) { + public void setPassword(Optional password) { this.password = password; } public User phone(String phone) { - this.phone = phone; + this.phone = Optional.of(phone); return this; } @@ -161,16 +161,16 @@ public User phone(String phone) { */ @JsonProperty("phone") - public String getPhone() { + public Optional getPhone() { return phone; } - public void setPhone(String phone) { + public void setPhone(Optional phone) { this.phone = phone; } public User userStatus(Integer userStatus) { - this.userStatus = userStatus; + this.userStatus = Optional.of(userStatus); return this; } @@ -180,11 +180,11 @@ public User userStatus(Integer userStatus) { */ @JsonProperty("userStatus") - public Integer getUserStatus() { + public Optional getUserStatus() { return userStatus; } - public void setUserStatus(Integer userStatus) { + public void setUserStatus(Optional userStatus) { this.userStatus = userStatus; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java index bd218422f919..ce5edf05f3a3 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java @@ -26,10 +26,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesAnyType { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesAnyType name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -40,11 +40,11 @@ public AdditionalPropertiesAnyType name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java index 548dad9a0401..a50265d5e8b1 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesArray.java @@ -27,10 +27,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesArray { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesArray name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -41,11 +41,11 @@ public AdditionalPropertiesArray name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java index 7eff631b3864..71b8012aa8c5 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java @@ -26,10 +26,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesBoolean { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesBoolean name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -40,11 +40,11 @@ public AdditionalPropertiesBoolean name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index 4a668d53474f..b5b0b66c10ec 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -53,11 +53,11 @@ public class AdditionalPropertiesClass { @Valid private Map> mapMapAnytype = new HashMap<>(); - private Object anytype1; + private Optional anytype1 = Optional.empty(); private JsonNullable anytype2 = JsonNullable.undefined(); - private Object anytype3; + private Optional anytype3 = Optional.empty(); public AdditionalPropertiesClass mapString(Map mapString) { this.mapString = mapString; @@ -284,7 +284,7 @@ public void setMapMapAnytype(Map> mapMapAnytype) { } public AdditionalPropertiesClass anytype1(Object anytype1) { - this.anytype1 = anytype1; + this.anytype1 = Optional.of(anytype1); return this; } @@ -295,11 +295,11 @@ public AdditionalPropertiesClass anytype1(Object anytype1) { @ApiModelProperty(value = "") @JsonProperty("anytype_1") - public Object getAnytype1() { + public Optional getAnytype1() { return anytype1; } - public void setAnytype1(Object anytype1) { + public void setAnytype1(Optional anytype1) { this.anytype1 = anytype1; } @@ -324,7 +324,7 @@ public void setAnytype2(JsonNullable anytype2) { } public AdditionalPropertiesClass anytype3(Object anytype3) { - this.anytype3 = anytype3; + this.anytype3 = Optional.of(anytype3); return this; } @@ -335,11 +335,11 @@ public AdditionalPropertiesClass anytype3(Object anytype3) { @ApiModelProperty(value = "") @JsonProperty("anytype_3") - public Object getAnytype3() { + public Optional getAnytype3() { return anytype3; } - public void setAnytype3(Object anytype3) { + public void setAnytype3(Optional anytype3) { this.anytype3 = anytype3; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java index 53a7354098c5..028535c51faf 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java @@ -26,10 +26,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesInteger { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesInteger name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -40,11 +40,11 @@ public AdditionalPropertiesInteger name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java index d9c197156a88..76fecc687bf7 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java @@ -27,10 +27,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesNumber { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesNumber name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -41,11 +41,11 @@ public AdditionalPropertiesNumber name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java index a0b695f115ad..791ae228623e 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesObject.java @@ -27,10 +27,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesObject { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesObject name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -41,11 +41,11 @@ public AdditionalPropertiesObject name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java index 2ef5cd4f06bd..20d7a455eefe 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/AdditionalPropertiesString.java @@ -26,10 +26,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AdditionalPropertiesString { - private String name; + private Optional name = Optional.empty(); public AdditionalPropertiesString name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -40,11 +40,11 @@ public AdditionalPropertiesString name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } /** diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java index 5916ecd79f9e..7646c8831244 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Animal.java @@ -38,7 +38,7 @@ public class Animal { private String className; - private String color = "red"; + private Optional color = Optional.of("red"); public Animal() { super(); @@ -72,7 +72,7 @@ public void setClassName(String className) { } public Animal color(String color) { - this.color = color; + this.color = Optional.of(color); return this; } @@ -83,11 +83,11 @@ public Animal color(String color) { @ApiModelProperty(value = "") @JsonProperty("color") - public String getColor() { + public Optional getColor() { return color; } - public void setColor(String color) { + public void setColor(Optional color) { this.color = color; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java index 5a0f52ce89f6..96ead30a3d4a 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/BigCat.java @@ -67,7 +67,7 @@ public static KindEnum fromValue(String value) { } } - private KindEnum kind; + private Optional kind = Optional.empty(); public BigCat() { super(); @@ -81,7 +81,7 @@ public BigCat(String className) { } public BigCat kind(KindEnum kind) { - this.kind = kind; + this.kind = Optional.of(kind); return this; } @@ -92,11 +92,11 @@ public BigCat kind(KindEnum kind) { @ApiModelProperty(value = "") @JsonProperty("kind") - public KindEnum getKind() { + public Optional getKind() { return kind; } - public void setKind(KindEnum kind) { + public void setKind(Optional kind) { this.kind = kind; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java index feb0d643c5e5..5549c8966ea0 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Capitalization.java @@ -22,20 +22,20 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Capitalization { - private String smallCamel; + private Optional smallCamel = Optional.empty(); - private String capitalCamel; + private Optional capitalCamel = Optional.empty(); - private String smallSnake; + private Optional smallSnake = Optional.empty(); - private String capitalSnake; + private Optional capitalSnake = Optional.empty(); - private String scAETHFlowPoints; + private Optional scAETHFlowPoints = Optional.empty(); - private String ATT_NAME; + private Optional ATT_NAME = Optional.empty(); public Capitalization smallCamel(String smallCamel) { - this.smallCamel = smallCamel; + this.smallCamel = Optional.of(smallCamel); return this; } @@ -46,16 +46,16 @@ public Capitalization smallCamel(String smallCamel) { @ApiModelProperty(value = "") @JsonProperty("smallCamel") - public String getSmallCamel() { + public Optional getSmallCamel() { return smallCamel; } - public void setSmallCamel(String smallCamel) { + public void setSmallCamel(Optional smallCamel) { this.smallCamel = smallCamel; } public Capitalization capitalCamel(String capitalCamel) { - this.capitalCamel = capitalCamel; + this.capitalCamel = Optional.of(capitalCamel); return this; } @@ -66,16 +66,16 @@ public Capitalization capitalCamel(String capitalCamel) { @ApiModelProperty(value = "") @JsonProperty("CapitalCamel") - public String getCapitalCamel() { + public Optional getCapitalCamel() { return capitalCamel; } - public void setCapitalCamel(String capitalCamel) { + public void setCapitalCamel(Optional capitalCamel) { this.capitalCamel = capitalCamel; } public Capitalization smallSnake(String smallSnake) { - this.smallSnake = smallSnake; + this.smallSnake = Optional.of(smallSnake); return this; } @@ -86,16 +86,16 @@ public Capitalization smallSnake(String smallSnake) { @ApiModelProperty(value = "") @JsonProperty("small_Snake") - public String getSmallSnake() { + public Optional getSmallSnake() { return smallSnake; } - public void setSmallSnake(String smallSnake) { + public void setSmallSnake(Optional smallSnake) { this.smallSnake = smallSnake; } public Capitalization capitalSnake(String capitalSnake) { - this.capitalSnake = capitalSnake; + this.capitalSnake = Optional.of(capitalSnake); return this; } @@ -106,16 +106,16 @@ public Capitalization capitalSnake(String capitalSnake) { @ApiModelProperty(value = "") @JsonProperty("Capital_Snake") - public String getCapitalSnake() { + public Optional getCapitalSnake() { return capitalSnake; } - public void setCapitalSnake(String capitalSnake) { + public void setCapitalSnake(Optional capitalSnake) { this.capitalSnake = capitalSnake; } public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { - this.scAETHFlowPoints = scAETHFlowPoints; + this.scAETHFlowPoints = Optional.of(scAETHFlowPoints); return this; } @@ -126,16 +126,16 @@ public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { @ApiModelProperty(value = "") @JsonProperty("SCA_ETH_Flow_Points") - public String getScAETHFlowPoints() { + public Optional getScAETHFlowPoints() { return scAETHFlowPoints; } - public void setScAETHFlowPoints(String scAETHFlowPoints) { + public void setScAETHFlowPoints(Optional scAETHFlowPoints) { this.scAETHFlowPoints = scAETHFlowPoints; } public Capitalization ATT_NAME(String ATT_NAME) { - this.ATT_NAME = ATT_NAME; + this.ATT_NAME = Optional.of(ATT_NAME); return this; } @@ -146,11 +146,11 @@ public Capitalization ATT_NAME(String ATT_NAME) { @ApiModelProperty(value = "Name of the pet ") @JsonProperty("ATT_NAME") - public String getATTNAME() { + public Optional getATTNAME() { return ATT_NAME; } - public void setATTNAME(String ATT_NAME) { + public void setATTNAME(Optional ATT_NAME) { this.ATT_NAME = ATT_NAME; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java index e44f574d69b4..8474ef1cbd36 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Cat.java @@ -35,7 +35,7 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Cat extends Animal { - private Boolean declawed; + private Optional declawed = Optional.empty(); public Cat() { super(); @@ -49,7 +49,7 @@ public Cat(String className) { } public Cat declawed(Boolean declawed) { - this.declawed = declawed; + this.declawed = Optional.of(declawed); return this; } @@ -60,11 +60,11 @@ public Cat declawed(Boolean declawed) { @ApiModelProperty(value = "") @JsonProperty("declawed") - public Boolean getDeclawed() { + public Optional getDeclawed() { return declawed; } - public void setDeclawed(Boolean declawed) { + public void setDeclawed(Optional declawed) { this.declawed = declawed; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java index 18c9bee66c00..a2af14bc5199 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Category.java @@ -22,7 +22,7 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Category { - private Long id; + private Optional id = Optional.empty(); private String name = "default-name"; @@ -38,7 +38,7 @@ public Category(String name) { } public Category id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -49,11 +49,11 @@ public Category id(Long id) { @ApiModelProperty(value = "") @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java index 49094e267a20..3fc1f3a2274e 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -30,10 +30,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ChildWithNullable extends ParentWithNullable { - private String otherProperty; + private Optional otherProperty = Optional.empty(); public ChildWithNullable otherProperty(String otherProperty) { - this.otherProperty = otherProperty; + this.otherProperty = Optional.of(otherProperty); return this; } @@ -44,11 +44,11 @@ public ChildWithNullable otherProperty(String otherProperty) { @ApiModelProperty(value = "") @JsonProperty("otherProperty") - public String getOtherProperty() { + public Optional getOtherProperty() { return otherProperty; } - public void setOtherProperty(String otherProperty) { + public void setOtherProperty(Optional otherProperty) { this.otherProperty = otherProperty; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java index 2c511abe3ecb..1534abdaa28f 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ClassModel.java @@ -23,10 +23,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ClassModel { - private String propertyClass; + private Optional propertyClass = Optional.empty(); public ClassModel propertyClass(String propertyClass) { - this.propertyClass = propertyClass; + this.propertyClass = Optional.of(propertyClass); return this; } @@ -37,11 +37,11 @@ public ClassModel propertyClass(String propertyClass) { @ApiModelProperty(value = "") @JsonProperty("_class") - public String getPropertyClass() { + public Optional getPropertyClass() { return propertyClass; } - public void setPropertyClass(String propertyClass) { + public void setPropertyClass(Optional propertyClass) { this.propertyClass = propertyClass; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java index a6bfdf58db7f..e1cea9ab3372 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Client.java @@ -22,10 +22,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Client { - private String client; + private Optional client = Optional.empty(); public Client client(String client) { - this.client = client; + this.client = Optional.of(client); return this; } @@ -36,11 +36,11 @@ public Client client(String client) { @ApiModelProperty(value = "") @JsonProperty("client") - public String getClient() { + public Optional getClient() { return client; } - public void setClient(String client) { + public void setClient(Optional client) { this.client = client; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java index 278b2aee4c15..866f5148e546 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Dog.java @@ -27,7 +27,7 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Dog extends Animal { - private String breed; + private Optional breed = Optional.empty(); public Dog() { super(); @@ -41,7 +41,7 @@ public Dog(String className) { } public Dog breed(String breed) { - this.breed = breed; + this.breed = Optional.of(breed); return this; } @@ -52,11 +52,11 @@ public Dog breed(String breed) { @ApiModelProperty(value = "") @JsonProperty("breed") - public String getBreed() { + public Optional getBreed() { return breed; } - public void setBreed(String breed) { + public void setBreed(Optional breed) { this.breed = breed; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java index 0479937750d1..47392d12be50 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumArrays.java @@ -61,7 +61,7 @@ public static JustSymbolEnum fromValue(String value) { } } - private JustSymbolEnum justSymbol; + private Optional justSymbol = Optional.empty(); /** * Gets or Sets arrayEnum @@ -102,7 +102,7 @@ public static ArrayEnumEnum fromValue(String value) { private List arrayEnum; public EnumArrays justSymbol(JustSymbolEnum justSymbol) { - this.justSymbol = justSymbol; + this.justSymbol = Optional.of(justSymbol); return this; } @@ -113,11 +113,11 @@ public EnumArrays justSymbol(JustSymbolEnum justSymbol) { @ApiModelProperty(value = "") @JsonProperty("just_symbol") - public JustSymbolEnum getJustSymbol() { + public Optional getJustSymbol() { return justSymbol; } - public void setJustSymbol(JustSymbolEnum justSymbol) { + public void setJustSymbol(Optional justSymbol) { this.justSymbol = justSymbol; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java index 427020a13a25..06ecf24f8cdc 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/EnumTest.java @@ -63,7 +63,7 @@ public static EnumStringEnum fromValue(String value) { } } - private EnumStringEnum enumString; + private Optional enumString = Optional.empty(); /** * Gets or Sets enumStringRequired @@ -139,7 +139,7 @@ public static EnumIntegerEnum fromValue(Integer value) { } } - private EnumIntegerEnum enumInteger; + private Optional enumInteger = Optional.empty(); /** * Gets or Sets enumNumber @@ -176,9 +176,9 @@ public static EnumNumberEnum fromValue(Double value) { } } - private EnumNumberEnum enumNumber; + private Optional enumNumber = Optional.empty(); - private OuterEnum outerEnum; + private Optional outerEnum = Optional.empty(); public EnumTest() { super(); @@ -192,7 +192,7 @@ public EnumTest(EnumStringRequiredEnum enumStringRequired) { } public EnumTest enumString(EnumStringEnum enumString) { - this.enumString = enumString; + this.enumString = Optional.of(enumString); return this; } @@ -203,11 +203,11 @@ public EnumTest enumString(EnumStringEnum enumString) { @ApiModelProperty(value = "") @JsonProperty("enum_string") - public EnumStringEnum getEnumString() { + public Optional getEnumString() { return enumString; } - public void setEnumString(EnumStringEnum enumString) { + public void setEnumString(Optional enumString) { this.enumString = enumString; } @@ -232,7 +232,7 @@ public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) { } public EnumTest enumInteger(EnumIntegerEnum enumInteger) { - this.enumInteger = enumInteger; + this.enumInteger = Optional.of(enumInteger); return this; } @@ -243,16 +243,16 @@ public EnumTest enumInteger(EnumIntegerEnum enumInteger) { @ApiModelProperty(value = "") @JsonProperty("enum_integer") - public EnumIntegerEnum getEnumInteger() { + public Optional getEnumInteger() { return enumInteger; } - public void setEnumInteger(EnumIntegerEnum enumInteger) { + public void setEnumInteger(Optional enumInteger) { this.enumInteger = enumInteger; } public EnumTest enumNumber(EnumNumberEnum enumNumber) { - this.enumNumber = enumNumber; + this.enumNumber = Optional.of(enumNumber); return this; } @@ -263,16 +263,16 @@ public EnumTest enumNumber(EnumNumberEnum enumNumber) { @ApiModelProperty(value = "") @JsonProperty("enum_number") - public EnumNumberEnum getEnumNumber() { + public Optional getEnumNumber() { return enumNumber; } - public void setEnumNumber(EnumNumberEnum enumNumber) { + public void setEnumNumber(Optional enumNumber) { this.enumNumber = enumNumber; } public EnumTest outerEnum(OuterEnum outerEnum) { - this.outerEnum = outerEnum; + this.outerEnum = Optional.of(outerEnum); return this; } @@ -283,11 +283,11 @@ public EnumTest outerEnum(OuterEnum outerEnum) { @Valid @ApiModelProperty(value = "") @JsonProperty("outerEnum") - public OuterEnum getOuterEnum() { + public Optional getOuterEnum() { return outerEnum; } - public void setOuterEnum(OuterEnum outerEnum) { + public void setOuterEnum(Optional outerEnum) { this.outerEnum = outerEnum; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/File.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/File.java index fedeea1c6389..a7dddddbe16e 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/File.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/File.java @@ -23,10 +23,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class File { - private String sourceURI; + private Optional sourceURI = Optional.empty(); public File sourceURI(String sourceURI) { - this.sourceURI = sourceURI; + this.sourceURI = Optional.of(sourceURI); return this; } @@ -37,11 +37,11 @@ public File sourceURI(String sourceURI) { @ApiModelProperty(value = "Test capitalization") @JsonProperty("sourceURI") - public String getSourceURI() { + public Optional getSourceURI() { return sourceURI; } - public void setSourceURI(String sourceURI) { + public void setSourceURI(Optional sourceURI) { this.sourceURI = sourceURI; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java index bc7f7e2fa979..a7b77af60778 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FileSchemaTestClass.java @@ -26,13 +26,13 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class FileSchemaTestClass { - private File file; + private Optional file = Optional.empty(); @Valid private List<@Valid File> files; public FileSchemaTestClass file(File file) { - this.file = file; + this.file = Optional.of(file); return this; } @@ -43,11 +43,11 @@ public FileSchemaTestClass file(File file) { @Valid @ApiModelProperty(value = "") @JsonProperty("file") - public File getFile() { + public Optional getFile() { return file; } - public void setFile(File file) { + public void setFile(Optional file) { this.file = file; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java index 9adba59cfbea..7fbc7fc6d3ac 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/FormatTest.java @@ -30,35 +30,35 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class FormatTest { - private Integer integer; + private Optional<@Min(10) @Max(100) Integer> integer = Optional.empty(); - private Integer int32; + private Optional<@Min(20) @Max(200) Integer> int32 = Optional.empty(); - private Long int64; + private Optional int64 = Optional.empty(); private BigDecimal number; - private Float _float; + private Optional<@DecimalMin("54.3") @DecimalMax("987.6") Float> _float = Optional.empty(); - private Double _double; + private Optional<@DecimalMin("67.8") @DecimalMax("123.4") Double> _double = Optional.empty(); - private String string; + private Optional<@Pattern(regexp = "/[a-z]/i") String> string = Optional.empty(); private byte[] _byte; - private org.springframework.core.io.Resource binary; + private Optional binary = Optional.empty(); @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) private LocalDate date; @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private OffsetDateTime dateTime; + private Optional dateTime = Optional.empty(); - private UUID uuid; + private Optional uuid = Optional.empty(); private String password; - private BigDecimal bigDecimal; + private Optional bigDecimal = Optional.empty(); public FormatTest() { super(); @@ -75,7 +75,7 @@ public FormatTest(BigDecimal number, byte[] _byte, LocalDate date, String passwo } public FormatTest integer(Integer integer) { - this.integer = integer; + this.integer = Optional.of(integer); return this; } @@ -85,19 +85,19 @@ public FormatTest integer(Integer integer) { * maximum: 100 * @return integer */ - @Min(10) @Max(100) + @ApiModelProperty(value = "") @JsonProperty("integer") - public Integer getInteger() { + public Optional<@Min(10) @Max(100) Integer> getInteger() { return integer; } - public void setInteger(Integer integer) { + public void setInteger(Optional integer) { this.integer = integer; } public FormatTest int32(Integer int32) { - this.int32 = int32; + this.int32 = Optional.of(int32); return this; } @@ -107,19 +107,19 @@ public FormatTest int32(Integer int32) { * maximum: 200 * @return int32 */ - @Min(20) @Max(200) + @ApiModelProperty(value = "") @JsonProperty("int32") - public Integer getInt32() { + public Optional<@Min(20) @Max(200) Integer> getInt32() { return int32; } - public void setInt32(Integer int32) { + public void setInt32(Optional int32) { this.int32 = int32; } public FormatTest int64(Long int64) { - this.int64 = int64; + this.int64 = Optional.of(int64); return this; } @@ -130,11 +130,11 @@ public FormatTest int64(Long int64) { @ApiModelProperty(value = "") @JsonProperty("int64") - public Long getInt64() { + public Optional getInt64() { return int64; } - public void setInt64(Long int64) { + public void setInt64(Optional int64) { this.int64 = int64; } @@ -161,7 +161,7 @@ public void setNumber(BigDecimal number) { } public FormatTest _float(Float _float) { - this._float = _float; + this._float = Optional.of(_float); return this; } @@ -171,19 +171,19 @@ public FormatTest _float(Float _float) { * maximum: 987.6 * @return _float */ - @DecimalMin("54.3") @DecimalMax("987.6") + @ApiModelProperty(value = "") @JsonProperty("float") - public Float getFloat() { + public Optional<@DecimalMin("54.3") @DecimalMax("987.6") Float> getFloat() { return _float; } - public void setFloat(Float _float) { + public void setFloat(Optional _float) { this._float = _float; } public FormatTest _double(Double _double) { - this._double = _double; + this._double = Optional.of(_double); return this; } @@ -193,19 +193,19 @@ public FormatTest _double(Double _double) { * maximum: 123.4 * @return _double */ - @DecimalMin("67.8") @DecimalMax("123.4") + @ApiModelProperty(value = "") @JsonProperty("double") - public Double getDouble() { + public Optional<@DecimalMin("67.8") @DecimalMax("123.4") Double> getDouble() { return _double; } - public void setDouble(Double _double) { + public void setDouble(Optional _double) { this._double = _double; } public FormatTest string(String string) { - this.string = string; + this.string = Optional.of(string); return this; } @@ -213,14 +213,14 @@ public FormatTest string(String string) { * Get string * @return string */ - @Pattern(regexp = "/[a-z]/i") + @ApiModelProperty(value = "") @JsonProperty("string") - public String getString() { + public Optional<@Pattern(regexp = "/[a-z]/i") String> getString() { return string; } - public void setString(String string) { + public void setString(Optional string) { this.string = string; } @@ -245,7 +245,7 @@ public void setByte(byte[] _byte) { } public FormatTest binary(org.springframework.core.io.Resource binary) { - this.binary = binary; + this.binary = Optional.of(binary); return this; } @@ -256,11 +256,11 @@ public FormatTest binary(org.springframework.core.io.Resource binary) { @Valid @ApiModelProperty(value = "") @JsonProperty("binary") - public org.springframework.core.io.Resource getBinary() { + public Optional getBinary() { return binary; } - public void setBinary(org.springframework.core.io.Resource binary) { + public void setBinary(Optional binary) { this.binary = binary; } @@ -285,7 +285,7 @@ public void setDate(LocalDate date) { } public FormatTest dateTime(OffsetDateTime dateTime) { - this.dateTime = dateTime; + this.dateTime = Optional.of(dateTime); return this; } @@ -296,16 +296,16 @@ public FormatTest dateTime(OffsetDateTime dateTime) { @Valid @ApiModelProperty(value = "") @JsonProperty("dateTime") - public OffsetDateTime getDateTime() { + public Optional getDateTime() { return dateTime; } - public void setDateTime(OffsetDateTime dateTime) { + public void setDateTime(Optional dateTime) { this.dateTime = dateTime; } public FormatTest uuid(UUID uuid) { - this.uuid = uuid; + this.uuid = Optional.of(uuid); return this; } @@ -316,11 +316,11 @@ public FormatTest uuid(UUID uuid) { @Valid @ApiModelProperty(example = "72f98069-206d-4f12-9f12-3d1e525a8e84", value = "") @JsonProperty("uuid") - public UUID getUuid() { + public Optional getUuid() { return uuid; } - public void setUuid(UUID uuid) { + public void setUuid(Optional uuid) { this.uuid = uuid; } @@ -345,7 +345,7 @@ public void setPassword(String password) { } public FormatTest bigDecimal(BigDecimal bigDecimal) { - this.bigDecimal = bigDecimal; + this.bigDecimal = Optional.of(bigDecimal); return this; } @@ -356,11 +356,11 @@ public FormatTest bigDecimal(BigDecimal bigDecimal) { @Valid @ApiModelProperty(value = "") @JsonProperty("BigDecimal") - public BigDecimal getBigDecimal() { + public Optional getBigDecimal() { return bigDecimal; } - public void setBigDecimal(BigDecimal bigDecimal) { + public void setBigDecimal(Optional bigDecimal) { this.bigDecimal = bigDecimal; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java index 21a424459798..5fe7575c4449 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/HasOnlyReadOnly.java @@ -24,12 +24,12 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class HasOnlyReadOnly { - private String bar; + private Optional bar = Optional.empty(); - private String foo; + private Optional foo = Optional.empty(); public HasOnlyReadOnly bar(String bar) { - this.bar = bar; + this.bar = Optional.of(bar); return this; } @@ -40,16 +40,16 @@ public HasOnlyReadOnly bar(String bar) { @ApiModelProperty(readOnly = true, value = "") @JsonProperty("bar") - public String getBar() { + public Optional getBar() { return bar; } - public void setBar(String bar) { + public void setBar(Optional bar) { this.bar = bar; } public HasOnlyReadOnly foo(String foo) { - this.foo = foo; + this.foo = Optional.of(foo); return this; } @@ -60,11 +60,11 @@ public HasOnlyReadOnly foo(String foo) { @ApiModelProperty(readOnly = true, value = "") @JsonProperty("foo") - public String getFoo() { + public Optional getFoo() { return foo; } - public void setFoo(String foo) { + public void setFoo(Optional foo) { this.foo = foo; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java index 075d281eb4bc..9495232ee3e0 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -28,16 +28,16 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class MixedPropertiesAndAdditionalPropertiesClass { - private UUID uuid; + private Optional uuid = Optional.empty(); @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private OffsetDateTime dateTime; + private Optional dateTime = Optional.empty(); @Valid private Map map = new HashMap<>(); public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { - this.uuid = uuid; + this.uuid = Optional.of(uuid); return this; } @@ -48,16 +48,16 @@ public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { @Valid @ApiModelProperty(value = "") @JsonProperty("uuid") - public UUID getUuid() { + public Optional getUuid() { return uuid; } - public void setUuid(UUID uuid) { + public void setUuid(Optional uuid) { this.uuid = uuid; } public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { - this.dateTime = dateTime; + this.dateTime = Optional.of(dateTime); return this; } @@ -68,11 +68,11 @@ public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateT @Valid @ApiModelProperty(value = "") @JsonProperty("dateTime") - public OffsetDateTime getDateTime() { + public Optional getDateTime() { return dateTime; } - public void setDateTime(OffsetDateTime dateTime) { + public void setDateTime(Optional dateTime) { this.dateTime = dateTime; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java index 193231f85457..2580ba9e9bdd 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Model200Response.java @@ -25,12 +25,12 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Model200Response { - private Integer name; + private Optional name = Optional.empty(); - private String propertyClass; + private Optional propertyClass = Optional.empty(); public Model200Response name(Integer name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -41,16 +41,16 @@ public Model200Response name(Integer name) { @ApiModelProperty(value = "") @JsonProperty("name") - public Integer getName() { + public Optional getName() { return name; } - public void setName(Integer name) { + public void setName(Optional name) { this.name = name; } public Model200Response propertyClass(String propertyClass) { - this.propertyClass = propertyClass; + this.propertyClass = Optional.of(propertyClass); return this; } @@ -61,11 +61,11 @@ public Model200Response propertyClass(String propertyClass) { @ApiModelProperty(value = "") @JsonProperty("class") - public String getPropertyClass() { + public Optional getPropertyClass() { return propertyClass; } - public void setPropertyClass(String propertyClass) { + public void setPropertyClass(Optional propertyClass) { this.propertyClass = propertyClass; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java index 693e1669879c..912e53baac50 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -24,14 +24,14 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ModelApiResponse { - private Integer code; + private Optional code = Optional.empty(); - private String type; + private Optional type = Optional.empty(); - private String message; + private Optional message = Optional.empty(); public ModelApiResponse code(Integer code) { - this.code = code; + this.code = Optional.of(code); return this; } @@ -42,16 +42,16 @@ public ModelApiResponse code(Integer code) { @ApiModelProperty(value = "") @JsonProperty("code") - public Integer getCode() { + public Optional getCode() { return code; } - public void setCode(Integer code) { + public void setCode(Optional code) { this.code = code; } public ModelApiResponse type(String type) { - this.type = type; + this.type = Optional.of(type); return this; } @@ -62,16 +62,16 @@ public ModelApiResponse type(String type) { @ApiModelProperty(value = "") @JsonProperty("type") - public String getType() { + public Optional getType() { return type; } - public void setType(String type) { + public void setType(Optional type) { this.type = type; } public ModelApiResponse message(String message) { - this.message = message; + this.message = Optional.of(message); return this; } @@ -82,11 +82,11 @@ public ModelApiResponse message(String message) { @ApiModelProperty(value = "") @JsonProperty("message") - public String getMessage() { + public Optional getMessage() { return message; } - public void setMessage(String message) { + public void setMessage(Optional message) { this.message = message; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelList.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelList.java index 7853f3d408a0..8b6c4972d1cb 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelList.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelList.java @@ -24,10 +24,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ModelList { - private String _123list; + private Optional _123list = Optional.empty(); public ModelList _123list(String _123list) { - this._123list = _123list; + this._123list = Optional.of(_123list); return this; } @@ -38,11 +38,11 @@ public ModelList _123list(String _123list) { @ApiModelProperty(value = "") @JsonProperty("123-list") - public String get123list() { + public Optional get123list() { return _123list; } - public void set123list(String _123list) { + public void set123list(Optional _123list) { this._123list = _123list; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java index b6f106cea222..56d05cff4e64 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ModelReturn.java @@ -25,10 +25,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ModelReturn { - private Integer _return; + private Optional _return = Optional.empty(); public ModelReturn _return(Integer _return) { - this._return = _return; + this._return = Optional.of(_return); return this; } @@ -39,11 +39,11 @@ public ModelReturn _return(Integer _return) { @ApiModelProperty(value = "") @JsonProperty("return") - public Integer getReturn() { + public Optional getReturn() { return _return; } - public void setReturn(Integer _return) { + public void setReturn(Optional _return) { this._return = _return; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java index 72cdb4dbd1f8..c5b02de8b561 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Name.java @@ -25,11 +25,11 @@ public class Name { private Integer name; - private Integer snakeCase; + private Optional snakeCase = Optional.empty(); - private String property; + private Optional property = Optional.empty(); - private Integer _123number; + private Optional _123number = Optional.empty(); public Name() { super(); @@ -63,7 +63,7 @@ public void setName(Integer name) { } public Name snakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; + this.snakeCase = Optional.of(snakeCase); return this; } @@ -74,16 +74,16 @@ public Name snakeCase(Integer snakeCase) { @ApiModelProperty(readOnly = true, value = "") @JsonProperty("snake_case") - public Integer getSnakeCase() { + public Optional getSnakeCase() { return snakeCase; } - public void setSnakeCase(Integer snakeCase) { + public void setSnakeCase(Optional snakeCase) { this.snakeCase = snakeCase; } public Name property(String property) { - this.property = property; + this.property = Optional.of(property); return this; } @@ -94,16 +94,16 @@ public Name property(String property) { @ApiModelProperty(value = "") @JsonProperty("property") - public String getProperty() { + public Optional getProperty() { return property; } - public void setProperty(String property) { + public void setProperty(Optional property) { this.property = property; } public Name _123number(Integer _123number) { - this._123number = _123number; + this._123number = Optional.of(_123number); return this; } @@ -114,11 +114,11 @@ public Name _123number(Integer _123number) { @ApiModelProperty(readOnly = true, value = "") @JsonProperty("123Number") - public Integer get123number() { + public Optional get123number() { return _123number; } - public void set123number(Integer _123number) { + public void set123number(Optional _123number) { this._123number = _123number; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java index 1e3f9e15421d..72a9cb3e32b6 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NumberOnly.java @@ -23,10 +23,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class NumberOnly { - private BigDecimal justNumber; + private Optional justNumber = Optional.empty(); public NumberOnly justNumber(BigDecimal justNumber) { - this.justNumber = justNumber; + this.justNumber = Optional.of(justNumber); return this; } @@ -37,11 +37,11 @@ public NumberOnly justNumber(BigDecimal justNumber) { @Valid @ApiModelProperty(value = "") @JsonProperty("JustNumber") - public BigDecimal getJustNumber() { + public Optional getJustNumber() { return justNumber; } - public void setJustNumber(BigDecimal justNumber) { + public void setJustNumber(Optional justNumber) { this.justNumber = justNumber; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java index b24c70c07808..4db8c1d64104 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Order.java @@ -25,14 +25,14 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Order { - private Long id; + private Optional id = Optional.empty(); - private Long petId; + private Optional petId = Optional.empty(); - private Integer quantity; + private Optional quantity = Optional.empty(); @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private OffsetDateTime shipDate; + private Optional shipDate = Optional.empty(); /** * Order Status @@ -71,12 +71,12 @@ public static StatusEnum fromValue(String value) { } } - private StatusEnum status; + private Optional status = Optional.empty(); - private Boolean complete = false; + private Optional complete = Optional.of(false); public Order id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -87,16 +87,16 @@ public Order id(Long id) { @ApiModelProperty(value = "") @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Order petId(Long petId) { - this.petId = petId; + this.petId = Optional.of(petId); return this; } @@ -107,16 +107,16 @@ public Order petId(Long petId) { @ApiModelProperty(value = "") @JsonProperty("petId") - public Long getPetId() { + public Optional getPetId() { return petId; } - public void setPetId(Long petId) { + public void setPetId(Optional petId) { this.petId = petId; } public Order quantity(Integer quantity) { - this.quantity = quantity; + this.quantity = Optional.of(quantity); return this; } @@ -127,16 +127,16 @@ public Order quantity(Integer quantity) { @ApiModelProperty(value = "") @JsonProperty("quantity") - public Integer getQuantity() { + public Optional getQuantity() { return quantity; } - public void setQuantity(Integer quantity) { + public void setQuantity(Optional quantity) { this.quantity = quantity; } public Order shipDate(OffsetDateTime shipDate) { - this.shipDate = shipDate; + this.shipDate = Optional.of(shipDate); return this; } @@ -147,16 +147,16 @@ public Order shipDate(OffsetDateTime shipDate) { @Valid @ApiModelProperty(value = "") @JsonProperty("shipDate") - public OffsetDateTime getShipDate() { + public Optional getShipDate() { return shipDate; } - public void setShipDate(OffsetDateTime shipDate) { + public void setShipDate(Optional shipDate) { this.shipDate = shipDate; } public Order status(StatusEnum status) { - this.status = status; + this.status = Optional.of(status); return this; } @@ -167,16 +167,16 @@ public Order status(StatusEnum status) { @ApiModelProperty(value = "Order Status") @JsonProperty("status") - public StatusEnum getStatus() { + public Optional getStatus() { return status; } - public void setStatus(StatusEnum status) { + public void setStatus(Optional status) { this.status = status; } public Order complete(Boolean complete) { - this.complete = complete; + this.complete = Optional.of(complete); return this; } @@ -187,11 +187,11 @@ public Order complete(Boolean complete) { @ApiModelProperty(value = "") @JsonProperty("complete") - public Boolean getComplete() { + public Optional getComplete() { return complete; } - public void setComplete(Boolean complete) { + public void setComplete(Optional complete) { this.complete = complete; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java index ade2b9150190..e75ef1c3c084 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/OuterComposite.java @@ -23,14 +23,14 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class OuterComposite { - private BigDecimal myNumber; + private Optional myNumber = Optional.empty(); - private String myString; + private Optional myString = Optional.empty(); - private Boolean myBoolean; + private Optional myBoolean = Optional.empty(); public OuterComposite myNumber(BigDecimal myNumber) { - this.myNumber = myNumber; + this.myNumber = Optional.of(myNumber); return this; } @@ -41,16 +41,16 @@ public OuterComposite myNumber(BigDecimal myNumber) { @Valid @ApiModelProperty(value = "") @JsonProperty("my_number") - public BigDecimal getMyNumber() { + public Optional getMyNumber() { return myNumber; } - public void setMyNumber(BigDecimal myNumber) { + public void setMyNumber(Optional myNumber) { this.myNumber = myNumber; } public OuterComposite myString(String myString) { - this.myString = myString; + this.myString = Optional.of(myString); return this; } @@ -61,16 +61,16 @@ public OuterComposite myString(String myString) { @ApiModelProperty(value = "") @JsonProperty("my_string") - public String getMyString() { + public Optional getMyString() { return myString; } - public void setMyString(String myString) { + public void setMyString(Optional myString) { this.myString = myString; } public OuterComposite myBoolean(Boolean myBoolean) { - this.myBoolean = myBoolean; + this.myBoolean = Optional.of(myBoolean); return this; } @@ -81,11 +81,11 @@ public OuterComposite myBoolean(Boolean myBoolean) { @ApiModelProperty(value = "") @JsonProperty("my_boolean") - public Boolean getMyBoolean() { + public Optional getMyBoolean() { return myBoolean; } - public void setMyBoolean(Boolean myBoolean) { + public void setMyBoolean(Optional myBoolean) { this.myBoolean = myBoolean; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java index 88477c887c25..392f917f3743 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -71,12 +71,12 @@ public static TypeEnum fromValue(String value) { } } - private TypeEnum type; + private Optional type = Optional.empty(); private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { - this.type = type; + this.type = Optional.of(type); return this; } @@ -87,11 +87,11 @@ public ParentWithNullable type(TypeEnum type) { @ApiModelProperty(value = "") @JsonProperty("type") - public TypeEnum getType() { + public Optional getType() { return type; } - public void setType(TypeEnum type) { + public void setType(Optional type) { this.type = type; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java index 203d6bf1d543..4a7cd4eefcbd 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Pet.java @@ -31,9 +31,9 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Pet { - private Long id; + private Optional id = Optional.empty(); - private Category category; + private Optional category = Optional.empty(); private String name; @@ -81,7 +81,7 @@ public static StatusEnum fromValue(String value) { } @Deprecated - private StatusEnum status; + private Optional status = Optional.empty(); public Pet() { super(); @@ -96,7 +96,7 @@ public Pet(String name, Set photoUrls) { } public Pet id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -107,16 +107,16 @@ public Pet id(Long id) { @ApiModelProperty(value = "") @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Pet category(Category category) { - this.category = category; + this.category = Optional.of(category); return this; } @@ -127,11 +127,11 @@ public Pet category(Category category) { @Valid @ApiModelProperty(value = "") @JsonProperty("category") - public Category getCategory() { + public Optional getCategory() { return category; } - public void setCategory(Category category) { + public void setCategory(Optional category) { this.category = category; } @@ -213,7 +213,7 @@ public void setTags(List<@Valid Tag> tags) { } public Pet status(StatusEnum status) { - this.status = status; + this.status = Optional.of(status); return this; } @@ -226,7 +226,7 @@ public Pet status(StatusEnum status) { @ApiModelProperty(value = "pet status in the store") @JsonProperty("status") @Deprecated - public StatusEnum getStatus() { + public Optional getStatus() { return status; } @@ -234,7 +234,7 @@ public StatusEnum getStatus() { * @deprecated */ @Deprecated - public void setStatus(StatusEnum status) { + public void setStatus(Optional status) { this.status = status; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java index 3eb0ebe069c1..5c5979e73ee1 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ReadOnlyFirst.java @@ -22,12 +22,12 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ReadOnlyFirst { - private String bar; + private Optional bar = Optional.empty(); - private String baz; + private Optional baz = Optional.empty(); public ReadOnlyFirst bar(String bar) { - this.bar = bar; + this.bar = Optional.of(bar); return this; } @@ -38,16 +38,16 @@ public ReadOnlyFirst bar(String bar) { @ApiModelProperty(readOnly = true, value = "") @JsonProperty("bar") - public String getBar() { + public Optional getBar() { return bar; } - public void setBar(String bar) { + public void setBar(Optional bar) { this.bar = bar; } public ReadOnlyFirst baz(String baz) { - this.baz = baz; + this.baz = Optional.of(baz); return this; } @@ -58,11 +58,11 @@ public ReadOnlyFirst baz(String baz) { @ApiModelProperty(value = "") @JsonProperty("baz") - public String getBaz() { + public Optional getBaz() { return baz; } - public void setBaz(String baz) { + public void setBaz(Optional baz) { this.baz = baz; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java index 187960e94e4b..9205db8e8227 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java @@ -22,16 +22,16 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class ResponseObjectWithDifferentFieldNames { - private String normalPropertyName; + private Optional normalPropertyName = Optional.empty(); - private String UPPER_CASE_PROPERTY_SNAKE; + private Optional UPPER_CASE_PROPERTY_SNAKE = Optional.empty(); - private String lowerCasePropertyDashes; + private Optional lowerCasePropertyDashes = Optional.empty(); - private String propertyNameWithSpaces; + private Optional propertyNameWithSpaces = Optional.empty(); public ResponseObjectWithDifferentFieldNames normalPropertyName(String normalPropertyName) { - this.normalPropertyName = normalPropertyName; + this.normalPropertyName = Optional.of(normalPropertyName); return this; } @@ -42,16 +42,16 @@ public ResponseObjectWithDifferentFieldNames normalPropertyName(String normalPro @ApiModelProperty(value = "") @JsonProperty("normalPropertyName") - public String getNormalPropertyName() { + public Optional getNormalPropertyName() { return normalPropertyName; } - public void setNormalPropertyName(String normalPropertyName) { + public void setNormalPropertyName(Optional normalPropertyName) { this.normalPropertyName = normalPropertyName; } public ResponseObjectWithDifferentFieldNames UPPER_CASE_PROPERTY_SNAKE(String UPPER_CASE_PROPERTY_SNAKE) { - this.UPPER_CASE_PROPERTY_SNAKE = UPPER_CASE_PROPERTY_SNAKE; + this.UPPER_CASE_PROPERTY_SNAKE = Optional.of(UPPER_CASE_PROPERTY_SNAKE); return this; } @@ -62,16 +62,16 @@ public ResponseObjectWithDifferentFieldNames UPPER_CASE_PROPERTY_SNAKE(String UP @ApiModelProperty(value = "") @JsonProperty("UPPER_CASE_PROPERTY_SNAKE") - public String getUPPERCASEPROPERTYSNAKE() { + public Optional getUPPERCASEPROPERTYSNAKE() { return UPPER_CASE_PROPERTY_SNAKE; } - public void setUPPERCASEPROPERTYSNAKE(String UPPER_CASE_PROPERTY_SNAKE) { + public void setUPPERCASEPROPERTYSNAKE(Optional UPPER_CASE_PROPERTY_SNAKE) { this.UPPER_CASE_PROPERTY_SNAKE = UPPER_CASE_PROPERTY_SNAKE; } public ResponseObjectWithDifferentFieldNames lowerCasePropertyDashes(String lowerCasePropertyDashes) { - this.lowerCasePropertyDashes = lowerCasePropertyDashes; + this.lowerCasePropertyDashes = Optional.of(lowerCasePropertyDashes); return this; } @@ -82,16 +82,16 @@ public ResponseObjectWithDifferentFieldNames lowerCasePropertyDashes(String lowe @ApiModelProperty(value = "") @JsonProperty("lower-case-property-dashes") - public String getLowerCasePropertyDashes() { + public Optional getLowerCasePropertyDashes() { return lowerCasePropertyDashes; } - public void setLowerCasePropertyDashes(String lowerCasePropertyDashes) { + public void setLowerCasePropertyDashes(Optional lowerCasePropertyDashes) { this.lowerCasePropertyDashes = lowerCasePropertyDashes; } public ResponseObjectWithDifferentFieldNames propertyNameWithSpaces(String propertyNameWithSpaces) { - this.propertyNameWithSpaces = propertyNameWithSpaces; + this.propertyNameWithSpaces = Optional.of(propertyNameWithSpaces); return this; } @@ -102,11 +102,11 @@ public ResponseObjectWithDifferentFieldNames propertyNameWithSpaces(String prope @ApiModelProperty(value = "") @JsonProperty("property name with spaces") - public String getPropertyNameWithSpaces() { + public Optional getPropertyNameWithSpaces() { return propertyNameWithSpaces; } - public void setPropertyNameWithSpaces(String propertyNameWithSpaces) { + public void setPropertyNameWithSpaces(Optional propertyNameWithSpaces) { this.propertyNameWithSpaces = propertyNameWithSpaces; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java index bf67444d3cb7..3b500f2983bc 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/SpecialModelName.java @@ -24,10 +24,10 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class SpecialModelName { - private Long $specialPropertyName; + private Optional $specialPropertyName = Optional.empty(); public SpecialModelName $specialPropertyName(Long $specialPropertyName) { - this.$specialPropertyName = $specialPropertyName; + this.$specialPropertyName = Optional.of($specialPropertyName); return this; } @@ -38,11 +38,11 @@ public class SpecialModelName { @ApiModelProperty(value = "") @JsonProperty("$special[property.name]") - public Long get$SpecialPropertyName() { + public Optional get$SpecialPropertyName() { return $specialPropertyName; } - public void set$SpecialPropertyName(Long $specialPropertyName) { + public void set$SpecialPropertyName(Optional $specialPropertyName) { this.$specialPropertyName = $specialPropertyName; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java index 527e777278e2..5256d11d3f8f 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/Tag.java @@ -22,12 +22,12 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class Tag { - private Long id; + private Optional id = Optional.empty(); - private String name; + private Optional name = Optional.empty(); public Tag id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -38,16 +38,16 @@ public Tag id(Long id) { @ApiModelProperty(value = "") @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public Tag name(String name) { - this.name = name; + this.name = Optional.of(name); return this; } @@ -58,11 +58,11 @@ public Tag name(String name) { @ApiModelProperty(value = "") @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } - public void setName(String name) { + public void setName(Optional name) { this.name = name; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java index 36d29ba307d0..4b38c1bc4cc0 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/User.java @@ -22,24 +22,24 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class User { - private Long id; + private Optional id = Optional.empty(); - private String username; + private Optional username = Optional.empty(); - private String firstName; + private Optional firstName = Optional.empty(); - private String lastName; + private Optional lastName = Optional.empty(); - private String email; + private Optional email = Optional.empty(); - private String password; + private Optional password = Optional.empty(); - private String phone; + private Optional phone = Optional.empty(); - private Integer userStatus; + private Optional userStatus = Optional.empty(); public User id(Long id) { - this.id = id; + this.id = Optional.of(id); return this; } @@ -50,16 +50,16 @@ public User id(Long id) { @ApiModelProperty(value = "") @JsonProperty("id") - public Long getId() { + public Optional getId() { return id; } - public void setId(Long id) { + public void setId(Optional id) { this.id = id; } public User username(String username) { - this.username = username; + this.username = Optional.of(username); return this; } @@ -70,16 +70,16 @@ public User username(String username) { @ApiModelProperty(value = "") @JsonProperty("username") - public String getUsername() { + public Optional getUsername() { return username; } - public void setUsername(String username) { + public void setUsername(Optional username) { this.username = username; } public User firstName(String firstName) { - this.firstName = firstName; + this.firstName = Optional.of(firstName); return this; } @@ -90,16 +90,16 @@ public User firstName(String firstName) { @ApiModelProperty(value = "") @JsonProperty("firstName") - public String getFirstName() { + public Optional getFirstName() { return firstName; } - public void setFirstName(String firstName) { + public void setFirstName(Optional firstName) { this.firstName = firstName; } public User lastName(String lastName) { - this.lastName = lastName; + this.lastName = Optional.of(lastName); return this; } @@ -110,16 +110,16 @@ public User lastName(String lastName) { @ApiModelProperty(value = "") @JsonProperty("lastName") - public String getLastName() { + public Optional getLastName() { return lastName; } - public void setLastName(String lastName) { + public void setLastName(Optional lastName) { this.lastName = lastName; } public User email(String email) { - this.email = email; + this.email = Optional.of(email); return this; } @@ -130,16 +130,16 @@ public User email(String email) { @ApiModelProperty(value = "") @JsonProperty("email") - public String getEmail() { + public Optional getEmail() { return email; } - public void setEmail(String email) { + public void setEmail(Optional email) { this.email = email; } public User password(String password) { - this.password = password; + this.password = Optional.of(password); return this; } @@ -150,16 +150,16 @@ public User password(String password) { @ApiModelProperty(value = "") @JsonProperty("password") - public String getPassword() { + public Optional getPassword() { return password; } - public void setPassword(String password) { + public void setPassword(Optional password) { this.password = password; } public User phone(String phone) { - this.phone = phone; + this.phone = Optional.of(phone); return this; } @@ -170,16 +170,16 @@ public User phone(String phone) { @ApiModelProperty(value = "") @JsonProperty("phone") - public String getPhone() { + public Optional getPhone() { return phone; } - public void setPhone(String phone) { + public void setPhone(Optional phone) { this.phone = phone; } public User userStatus(Integer userStatus) { - this.userStatus = userStatus; + this.userStatus = Optional.of(userStatus); return this; } @@ -190,11 +190,11 @@ public User userStatus(Integer userStatus) { @ApiModelProperty(value = "User Status") @JsonProperty("userStatus") - public Integer getUserStatus() { + public Optional getUserStatus() { return userStatus; } - public void setUserStatus(Integer userStatus) { + public void setUserStatus(Optional userStatus) { this.userStatus = userStatus; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java index 592030bb8800..a73719c8528b 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/XmlItem.java @@ -26,24 +26,24 @@ @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class XmlItem { - private String attributeString; + private Optional attributeString = Optional.empty(); - private BigDecimal attributeNumber; + private Optional attributeNumber = Optional.empty(); - private Integer attributeInteger; + private Optional attributeInteger = Optional.empty(); - private Boolean attributeBoolean; + private Optional attributeBoolean = Optional.empty(); @Valid private List wrappedArray; - private String nameString; + private Optional nameString = Optional.empty(); - private BigDecimal nameNumber; + private Optional nameNumber = Optional.empty(); - private Integer nameInteger; + private Optional nameInteger = Optional.empty(); - private Boolean nameBoolean; + private Optional nameBoolean = Optional.empty(); @Valid private List nameArray; @@ -51,13 +51,13 @@ public class XmlItem { @Valid private List nameWrappedArray; - private String prefixString; + private Optional prefixString = Optional.empty(); - private BigDecimal prefixNumber; + private Optional prefixNumber = Optional.empty(); - private Integer prefixInteger; + private Optional prefixInteger = Optional.empty(); - private Boolean prefixBoolean; + private Optional prefixBoolean = Optional.empty(); @Valid private List prefixArray; @@ -65,13 +65,13 @@ public class XmlItem { @Valid private List prefixWrappedArray; - private String namespaceString; + private Optional namespaceString = Optional.empty(); - private BigDecimal namespaceNumber; + private Optional namespaceNumber = Optional.empty(); - private Integer namespaceInteger; + private Optional namespaceInteger = Optional.empty(); - private Boolean namespaceBoolean; + private Optional namespaceBoolean = Optional.empty(); @Valid private List namespaceArray; @@ -79,13 +79,13 @@ public class XmlItem { @Valid private List namespaceWrappedArray; - private String prefixNsString; + private Optional prefixNsString = Optional.empty(); - private BigDecimal prefixNsNumber; + private Optional prefixNsNumber = Optional.empty(); - private Integer prefixNsInteger; + private Optional prefixNsInteger = Optional.empty(); - private Boolean prefixNsBoolean; + private Optional prefixNsBoolean = Optional.empty(); @Valid private List prefixNsArray; @@ -94,7 +94,7 @@ public class XmlItem { private List prefixNsWrappedArray; public XmlItem attributeString(String attributeString) { - this.attributeString = attributeString; + this.attributeString = Optional.of(attributeString); return this; } @@ -105,16 +105,16 @@ public XmlItem attributeString(String attributeString) { @ApiModelProperty(example = "string", value = "") @JsonProperty("attribute_string") - public String getAttributeString() { + public Optional getAttributeString() { return attributeString; } - public void setAttributeString(String attributeString) { + public void setAttributeString(Optional attributeString) { this.attributeString = attributeString; } public XmlItem attributeNumber(BigDecimal attributeNumber) { - this.attributeNumber = attributeNumber; + this.attributeNumber = Optional.of(attributeNumber); return this; } @@ -125,16 +125,16 @@ public XmlItem attributeNumber(BigDecimal attributeNumber) { @Valid @ApiModelProperty(example = "1.234", value = "") @JsonProperty("attribute_number") - public BigDecimal getAttributeNumber() { + public Optional getAttributeNumber() { return attributeNumber; } - public void setAttributeNumber(BigDecimal attributeNumber) { + public void setAttributeNumber(Optional attributeNumber) { this.attributeNumber = attributeNumber; } public XmlItem attributeInteger(Integer attributeInteger) { - this.attributeInteger = attributeInteger; + this.attributeInteger = Optional.of(attributeInteger); return this; } @@ -145,16 +145,16 @@ public XmlItem attributeInteger(Integer attributeInteger) { @ApiModelProperty(example = "-2", value = "") @JsonProperty("attribute_integer") - public Integer getAttributeInteger() { + public Optional getAttributeInteger() { return attributeInteger; } - public void setAttributeInteger(Integer attributeInteger) { + public void setAttributeInteger(Optional attributeInteger) { this.attributeInteger = attributeInteger; } public XmlItem attributeBoolean(Boolean attributeBoolean) { - this.attributeBoolean = attributeBoolean; + this.attributeBoolean = Optional.of(attributeBoolean); return this; } @@ -165,11 +165,11 @@ public XmlItem attributeBoolean(Boolean attributeBoolean) { @ApiModelProperty(example = "true", value = "") @JsonProperty("attribute_boolean") - public Boolean getAttributeBoolean() { + public Optional getAttributeBoolean() { return attributeBoolean; } - public void setAttributeBoolean(Boolean attributeBoolean) { + public void setAttributeBoolean(Optional attributeBoolean) { this.attributeBoolean = attributeBoolean; } @@ -202,7 +202,7 @@ public void setWrappedArray(List wrappedArray) { } public XmlItem nameString(String nameString) { - this.nameString = nameString; + this.nameString = Optional.of(nameString); return this; } @@ -213,16 +213,16 @@ public XmlItem nameString(String nameString) { @ApiModelProperty(example = "string", value = "") @JsonProperty("name_string") - public String getNameString() { + public Optional getNameString() { return nameString; } - public void setNameString(String nameString) { + public void setNameString(Optional nameString) { this.nameString = nameString; } public XmlItem nameNumber(BigDecimal nameNumber) { - this.nameNumber = nameNumber; + this.nameNumber = Optional.of(nameNumber); return this; } @@ -233,16 +233,16 @@ public XmlItem nameNumber(BigDecimal nameNumber) { @Valid @ApiModelProperty(example = "1.234", value = "") @JsonProperty("name_number") - public BigDecimal getNameNumber() { + public Optional getNameNumber() { return nameNumber; } - public void setNameNumber(BigDecimal nameNumber) { + public void setNameNumber(Optional nameNumber) { this.nameNumber = nameNumber; } public XmlItem nameInteger(Integer nameInteger) { - this.nameInteger = nameInteger; + this.nameInteger = Optional.of(nameInteger); return this; } @@ -253,16 +253,16 @@ public XmlItem nameInteger(Integer nameInteger) { @ApiModelProperty(example = "-2", value = "") @JsonProperty("name_integer") - public Integer getNameInteger() { + public Optional getNameInteger() { return nameInteger; } - public void setNameInteger(Integer nameInteger) { + public void setNameInteger(Optional nameInteger) { this.nameInteger = nameInteger; } public XmlItem nameBoolean(Boolean nameBoolean) { - this.nameBoolean = nameBoolean; + this.nameBoolean = Optional.of(nameBoolean); return this; } @@ -273,11 +273,11 @@ public XmlItem nameBoolean(Boolean nameBoolean) { @ApiModelProperty(example = "true", value = "") @JsonProperty("name_boolean") - public Boolean getNameBoolean() { + public Optional getNameBoolean() { return nameBoolean; } - public void setNameBoolean(Boolean nameBoolean) { + public void setNameBoolean(Optional nameBoolean) { this.nameBoolean = nameBoolean; } @@ -338,7 +338,7 @@ public void setNameWrappedArray(List nameWrappedArray) { } public XmlItem prefixString(String prefixString) { - this.prefixString = prefixString; + this.prefixString = Optional.of(prefixString); return this; } @@ -349,16 +349,16 @@ public XmlItem prefixString(String prefixString) { @ApiModelProperty(example = "string", value = "") @JsonProperty("prefix_string") - public String getPrefixString() { + public Optional getPrefixString() { return prefixString; } - public void setPrefixString(String prefixString) { + public void setPrefixString(Optional prefixString) { this.prefixString = prefixString; } public XmlItem prefixNumber(BigDecimal prefixNumber) { - this.prefixNumber = prefixNumber; + this.prefixNumber = Optional.of(prefixNumber); return this; } @@ -369,16 +369,16 @@ public XmlItem prefixNumber(BigDecimal prefixNumber) { @Valid @ApiModelProperty(example = "1.234", value = "") @JsonProperty("prefix_number") - public BigDecimal getPrefixNumber() { + public Optional getPrefixNumber() { return prefixNumber; } - public void setPrefixNumber(BigDecimal prefixNumber) { + public void setPrefixNumber(Optional prefixNumber) { this.prefixNumber = prefixNumber; } public XmlItem prefixInteger(Integer prefixInteger) { - this.prefixInteger = prefixInteger; + this.prefixInteger = Optional.of(prefixInteger); return this; } @@ -389,16 +389,16 @@ public XmlItem prefixInteger(Integer prefixInteger) { @ApiModelProperty(example = "-2", value = "") @JsonProperty("prefix_integer") - public Integer getPrefixInteger() { + public Optional getPrefixInteger() { return prefixInteger; } - public void setPrefixInteger(Integer prefixInteger) { + public void setPrefixInteger(Optional prefixInteger) { this.prefixInteger = prefixInteger; } public XmlItem prefixBoolean(Boolean prefixBoolean) { - this.prefixBoolean = prefixBoolean; + this.prefixBoolean = Optional.of(prefixBoolean); return this; } @@ -409,11 +409,11 @@ public XmlItem prefixBoolean(Boolean prefixBoolean) { @ApiModelProperty(example = "true", value = "") @JsonProperty("prefix_boolean") - public Boolean getPrefixBoolean() { + public Optional getPrefixBoolean() { return prefixBoolean; } - public void setPrefixBoolean(Boolean prefixBoolean) { + public void setPrefixBoolean(Optional prefixBoolean) { this.prefixBoolean = prefixBoolean; } @@ -474,7 +474,7 @@ public void setPrefixWrappedArray(List prefixWrappedArray) { } public XmlItem namespaceString(String namespaceString) { - this.namespaceString = namespaceString; + this.namespaceString = Optional.of(namespaceString); return this; } @@ -485,16 +485,16 @@ public XmlItem namespaceString(String namespaceString) { @ApiModelProperty(example = "string", value = "") @JsonProperty("namespace_string") - public String getNamespaceString() { + public Optional getNamespaceString() { return namespaceString; } - public void setNamespaceString(String namespaceString) { + public void setNamespaceString(Optional namespaceString) { this.namespaceString = namespaceString; } public XmlItem namespaceNumber(BigDecimal namespaceNumber) { - this.namespaceNumber = namespaceNumber; + this.namespaceNumber = Optional.of(namespaceNumber); return this; } @@ -505,16 +505,16 @@ public XmlItem namespaceNumber(BigDecimal namespaceNumber) { @Valid @ApiModelProperty(example = "1.234", value = "") @JsonProperty("namespace_number") - public BigDecimal getNamespaceNumber() { + public Optional getNamespaceNumber() { return namespaceNumber; } - public void setNamespaceNumber(BigDecimal namespaceNumber) { + public void setNamespaceNumber(Optional namespaceNumber) { this.namespaceNumber = namespaceNumber; } public XmlItem namespaceInteger(Integer namespaceInteger) { - this.namespaceInteger = namespaceInteger; + this.namespaceInteger = Optional.of(namespaceInteger); return this; } @@ -525,16 +525,16 @@ public XmlItem namespaceInteger(Integer namespaceInteger) { @ApiModelProperty(example = "-2", value = "") @JsonProperty("namespace_integer") - public Integer getNamespaceInteger() { + public Optional getNamespaceInteger() { return namespaceInteger; } - public void setNamespaceInteger(Integer namespaceInteger) { + public void setNamespaceInteger(Optional namespaceInteger) { this.namespaceInteger = namespaceInteger; } public XmlItem namespaceBoolean(Boolean namespaceBoolean) { - this.namespaceBoolean = namespaceBoolean; + this.namespaceBoolean = Optional.of(namespaceBoolean); return this; } @@ -545,11 +545,11 @@ public XmlItem namespaceBoolean(Boolean namespaceBoolean) { @ApiModelProperty(example = "true", value = "") @JsonProperty("namespace_boolean") - public Boolean getNamespaceBoolean() { + public Optional getNamespaceBoolean() { return namespaceBoolean; } - public void setNamespaceBoolean(Boolean namespaceBoolean) { + public void setNamespaceBoolean(Optional namespaceBoolean) { this.namespaceBoolean = namespaceBoolean; } @@ -610,7 +610,7 @@ public void setNamespaceWrappedArray(List namespaceWrappedArray) { } public XmlItem prefixNsString(String prefixNsString) { - this.prefixNsString = prefixNsString; + this.prefixNsString = Optional.of(prefixNsString); return this; } @@ -621,16 +621,16 @@ public XmlItem prefixNsString(String prefixNsString) { @ApiModelProperty(example = "string", value = "") @JsonProperty("prefix_ns_string") - public String getPrefixNsString() { + public Optional getPrefixNsString() { return prefixNsString; } - public void setPrefixNsString(String prefixNsString) { + public void setPrefixNsString(Optional prefixNsString) { this.prefixNsString = prefixNsString; } public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { - this.prefixNsNumber = prefixNsNumber; + this.prefixNsNumber = Optional.of(prefixNsNumber); return this; } @@ -641,16 +641,16 @@ public XmlItem prefixNsNumber(BigDecimal prefixNsNumber) { @Valid @ApiModelProperty(example = "1.234", value = "") @JsonProperty("prefix_ns_number") - public BigDecimal getPrefixNsNumber() { + public Optional getPrefixNsNumber() { return prefixNsNumber; } - public void setPrefixNsNumber(BigDecimal prefixNsNumber) { + public void setPrefixNsNumber(Optional prefixNsNumber) { this.prefixNsNumber = prefixNsNumber; } public XmlItem prefixNsInteger(Integer prefixNsInteger) { - this.prefixNsInteger = prefixNsInteger; + this.prefixNsInteger = Optional.of(prefixNsInteger); return this; } @@ -661,16 +661,16 @@ public XmlItem prefixNsInteger(Integer prefixNsInteger) { @ApiModelProperty(example = "-2", value = "") @JsonProperty("prefix_ns_integer") - public Integer getPrefixNsInteger() { + public Optional getPrefixNsInteger() { return prefixNsInteger; } - public void setPrefixNsInteger(Integer prefixNsInteger) { + public void setPrefixNsInteger(Optional prefixNsInteger) { this.prefixNsInteger = prefixNsInteger; } public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { - this.prefixNsBoolean = prefixNsBoolean; + this.prefixNsBoolean = Optional.of(prefixNsBoolean); return this; } @@ -681,11 +681,11 @@ public XmlItem prefixNsBoolean(Boolean prefixNsBoolean) { @ApiModelProperty(example = "true", value = "") @JsonProperty("prefix_ns_boolean") - public Boolean getPrefixNsBoolean() { + public Optional getPrefixNsBoolean() { return prefixNsBoolean; } - public void setPrefixNsBoolean(Boolean prefixNsBoolean) { + public void setPrefixNsBoolean(Optional prefixNsBoolean) { this.prefixNsBoolean = prefixNsBoolean; }