From 14e2781018d79a36912a7ae45c7709682106c5b9 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 19 Aug 2026 15:38:28 +0800 Subject: [PATCH 1/3] update parser to newer version (#24731) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6955a0ef6bce..0a3c88144628 100644 --- a/pom.xml +++ b/pom.xml @@ -1287,7 +1287,7 @@ 2.4 3.1.12.2 io.swagger.parser.v3 - 2.1.45 + 2.1.46 7.10.2 1.34 3.4.3 From b980d34e37175bd4327de4dd895aae0696ce533f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eirik=20Brandtz=C3=A6g?= Date: Wed, 19 Aug 2026 09:41:13 +0200 Subject: [PATCH 2/3] [dart] Do not convert `format: date` to UTC before formatting (#24706) * fix(dart): do not convert format: date fields to UTC before formatting _dateFormatter is DateFormat('yyyy-MM-dd'), which formats the y/m/d the DateTime already carries and performs no timezone conversion. Calling toUtc() first therefore does nothing except roll the clock back past midnight in UTC+X zones, so the formatter prints the previous day. Combined with mapDateTime parsing the bare wire value "2026-09-12" as local midnight, the round trip in Europe/Oslo is "2026-09-12" -> "2026-09-11". It is stable in UTC, which is why this went unnoticed. Removing toUtc() is safe in both directions: toUtc() returns this when the DateTime is already UTC, so UTC callers are unaffected, and local callers stop being shifted. The neighbouring isDateTime branch keeps toUtc() - an instant needs a zone, a calendar date does not. dart-dio already models this correctly with its own Date class. fix #24703 * test(dart): cover all four format: date branches The first test only exercised the plain, no-pattern branch, so three of the four changed template lines were unguarded. Adding a patterned date to the fixture plus a second test that generates with useOptional=true pins all four: plain / no pattern requiredDate, optionalDate plain / pattern patternedDate Optional / no pattern optionalDate (useOptional=true) Optional / pattern patternedDate (useOptional=true) Replace the blanket assertFileNotContains(".toUtc()") with assertions on the specific emitted lines. The blanket one would break if an unrelated date-time property were ever added to the shared fixture. Also correct the comment: toUtc() shifts the date in both directions, back a day east of UTC and forward a day west of it, not only backwards. --- .../native/native_class.mustache | 8 ++-- .../codegen/dart/DartClientCodegenTest.java | 45 +++++++++++++++++++ .../dart-native-deserialization-bugs.yaml | 15 +++++++ .../lib/model/format_test.dart | 2 +- .../lib/model/nullable_class.dart | 2 +- 5 files changed, 66 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache index ecae5ef6e026..73b3e486cf88 100644 --- a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache @@ -82,10 +82,10 @@ class {{{classname}}} { {{#pattern}} json[r'{{{baseName}}}'] = value == null ? null : (_isEpochMarker(r'{{{pattern}}}') ? value.millisecondsSinceEpoch - : _dateFormatter.format(value.toUtc())); + : _dateFormatter.format(value)); {{/pattern}} {{^pattern}} - json[r'{{{baseName}}}'] = value == null ? null : _dateFormatter.format(value.toUtc()); + json[r'{{{baseName}}}'] = value == null ? null : _dateFormatter.format(value); {{/pattern}} {{/isDate}} {{^isDateTime}} @@ -120,10 +120,10 @@ class {{{classname}}} { {{#pattern}} json[r'{{{baseName}}}'] = _isEpochMarker(r'{{{pattern}}}') ? this.{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.millisecondsSinceEpoch - : _dateFormatter.format(this.{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc()); + : _dateFormatter.format(this.{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}); {{/pattern}} {{^pattern}} - json[r'{{{baseName}}}'] = _dateFormatter.format(this.{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc()); + json[r'{{{baseName}}}'] = _dateFormatter.format(this.{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}); {{/pattern}} {{/isDate}} {{^isDateTime}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java index 357f6a9a72f5..2215908d3d65 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/dart/DartClientCodegenTest.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Map; public class DartClientCodegenTest { @@ -101,6 +102,10 @@ public void testEnumPropertyWithQuotes() { } private List generateDartNativeFromSpec(String specPath) throws Exception { + return generateDartNativeFromSpec(specPath, Map.of()); + } + + private List generateDartNativeFromSpec(String specPath, Map additionalProperties) throws Exception { File output = Files.createTempDirectory("dart-native-test").toFile(); output.deleteOnExit(); @@ -108,6 +113,7 @@ private List generateDartNativeFromSpec(String specPath) throws Exception .setGeneratorName("dart") .setInputSpec(specPath) .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + additionalProperties.forEach(configurator::addAdditionalProperty); ClientOptInput opts = configurator.toClientOptInput(); DefaultGenerator generator = new DefaultGenerator(); @@ -199,4 +205,43 @@ public void testNullableNestedComplexArraysPreserveNullEntries() throws Exceptio TestUtils.assertFileContains(modelFile.toPath(), "e == null ? null : NullableRequiredModel.listFromJson(e)"); } + + // DateFormat('yyyy-MM-dd') does no timezone conversion, it just formats the y/m/d the + // DateTime already carries. So toUtc() only shifts the value across a day boundary and + // the date comes out off by one - back a day east of UTC, forward a day west of it. + @Test(description = "format: date must not be converted to UTC before formatting") + public void testDateOnlyFieldsAreNotConvertedToUtc() throws Exception { + List files = generateDartNativeFromSpec( + "src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml"); + + File modelFile = files.stream() + .filter(f -> f.getName().equals("date_only_model.dart")) + .findFirst() + .orElseThrow(() -> new AssertionError("date_only_model.dart not found in generated files")); + + TestUtils.assertFileContains(modelFile.toPath(), + "json[r'requiredDate'] = _dateFormatter.format(this.requiredDate);"); + TestUtils.assertFileContains(modelFile.toPath(), + "json[r'optionalDate'] = _dateFormatter.format(this.optionalDate!);"); + // A pattern routes it through the _isEpochMarker ternary, non-epoch side formats the same way + TestUtils.assertFileContains(modelFile.toPath(), + ": _dateFormatter.format(this.patternedDate!);"); + } + + @Test(description = "format: date must not be converted to UTC in the Optional path either") + public void testDateOnlyFieldsAreNotConvertedToUtcWithUseOptional() throws Exception { + List files = generateDartNativeFromSpec( + "src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml", + Map.of("useOptional", true)); + + File modelFile = files.stream() + .filter(f -> f.getName().equals("date_only_model.dart")) + .findFirst() + .orElseThrow(() -> new AssertionError("date_only_model.dart not found in generated files")); + + TestUtils.assertFileContains(modelFile.toPath(), + "json[r'optionalDate'] = value == null ? null : _dateFormatter.format(value);"); + TestUtils.assertFileContains(modelFile.toPath(), + ": _dateFormatter.format(value));"); + } } diff --git a/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml b/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml index 53f2172adee4..218af8dfe017 100644 --- a/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/dart/dart-native-deserialization-bugs.yaml @@ -47,3 +47,18 @@ components: nullable: true items: $ref: '#/components/schemas/NullableRequiredModel' + DateOnlyModel: + type: object + required: + - requiredDate + properties: + requiredDate: + type: string + format: date + optionalDate: + type: string + format: date + patternedDate: + type: string + format: date + pattern: '^\d{4}-\d{2}-\d{2}$' diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart index 5c22fff27825..3a5506f6d561 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart @@ -233,7 +233,7 @@ class FormatTest { } else { json[r'binary'] = null; } - json[r'date'] = _dateFormatter.format(this.date.toUtc()); + json[r'date'] = _dateFormatter.format(this.date); if (this.dateTime != null) { json[r'dateTime'] = this.dateTime!.toUtc().toIso8601String(); } else { diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart index 7dc16ebaf5bc..8742cbe2ccd8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart @@ -108,7 +108,7 @@ class NullableClass { json[r'string_prop'] = null; } if (this.dateProp != null) { - json[r'date_prop'] = _dateFormatter.format(this.dateProp!.toUtc()); + json[r'date_prop'] = _dateFormatter.format(this.dateProp!); } else { json[r'date_prop'] = null; } From 2767397f8c61dcb777b96cd9b13f518fe5d2ca4f Mon Sep 17 00:00:00 2001 From: jpfinne Date: Wed, 19 Aug 2026 12:22:23 +0200 Subject: [PATCH 3/3] [JAVA] [Spring] JSpecify, fix nullable + required field (#24711) * Java/Spring handling of required+nullable in models * Java/Spring handling of required+nullable in models * Remove @NotNull under jspecify * merge master * merge master * new files generated * keep formatting, regenerate samples * regenerate samples * Keep @NotNull for JsonInclude field * Fix cubic findings * fix missing description * Fix failing removeAnnotationsWithExclusion * Fix cubic finding * Schema nullable=true generation Make JSonNullable<> field = null for nullable+required * Rollback: @NotNull should not be present for required+nullable + openapiNullable * Fix a NPE in add and put item * Add @Present comment --- .../languages/AbstractJavaCodegen.java | 62 ++- .../codegen/languages/JavaClientCodegen.java | 4 +- .../Java/libraries/feign/pojo.mustache | 4 +- .../Java/libraries/jersey2/pojo.mustache | 6 +- .../Java/libraries/jersey3/pojo.mustache | 6 +- .../Java/libraries/native/pojo.mustache | 6 +- .../Java/libraries/okhttp-gson/pojo.mustache | 2 +- .../Java/libraries/restclient/pojo.mustache | 6 +- .../Java/libraries/resttemplate/pojo.mustache | 6 +- .../Java/libraries/webclient/pojo.mustache | 6 +- .../Java/nullableArgument_builder.mustache | 2 +- .../Java/nullable_var_annotations.mustache | 2 +- .../src/main/resources/Java/pojo.mustache | 6 +- .../JavaSpring/beanValidation.mustache | 2 +- .../resources/JavaSpring/notNull.mustache | 1 + .../nullableAnnotation_jspecify.mustache | 2 +- .../nullableArgument_builder.mustache | 2 +- .../nullableArgument_chainSetter.mustache | 1 + .../nullableArgument_constructor.mustache | 1 + .../main/resources/JavaSpring/pojo.mustache | 14 +- .../codegen/java/JavaClientCodegenTest.java | 40 +- .../java/spring/SpringCodegenTest.java | 57 ++- .../src/test/resources/3_0/java/jspecify.yaml | 74 +++- .../client/model/DefaultValue.java | 4 +- .../client/model/DefaultValue.java | 4 +- .../client/model/DefaultValue.java | 4 +- .../client/model/DefaultValue.java | 4 +- .../client/model/DefaultValue.java | 4 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../.openapi-generator/FILES | 6 + .../java/native-jackson3-jspecify/README.md | 7 +- .../native-jackson3-jspecify/api/openapi.yaml | 83 ++++ .../native-jackson3-jspecify/docs/FileApi.md | 18 +- .../docs/FileContent.md | 24 ++ .../docs/RequiredAndNullable.md | 17 + .../docs/RequiredAndNullableApi.md | 140 +++++++ .../org/openapitools/client/api/FileApi.java | 41 +- .../client/api/RequiredAndNullableApi.java | 289 ++++++++++++++ .../client/model/FileContent.java | 294 ++++++++++++++ .../client/model/RequiredAndNullable.java | 372 ++++++++++++++++++ .../api/RequiredAndNullableApiTest.java | 54 +++ .../client/model/FileContentTest.java | 56 +++ .../client/model/RequiredAndNullableTest.java | 73 ++++ .../client/model/NullableClass.java | 8 +- .../.openapi-generator/FILES | 6 + .../README.md | 6 +- .../api/openapi.yaml | 83 ++++ .../docs/FileApi.md | 9 +- .../docs/FileContent.md | 24 ++ .../docs/RequiredAndNullable.md | 17 + .../docs/RequiredAndNullableApi.md | 73 ++++ .../org/openapitools/client/api/FileApi.java | 20 +- .../client/api/RequiredAndNullableApi.java | 121 ++++++ .../client/model/FileContent.java | 247 ++++++++++++ .../org/openapitools/client/model/Foo.java | 2 +- .../client/model/RequiredAndNullable.java | 328 +++++++++++++++ .../api/RequiredAndNullableApiTest.java | 48 +++ .../client/model/FileContentTest.java | 55 +++ .../client/model/RequiredAndNullableTest.java | 72 ++++ .../.openapi-generator/FILES | 6 + .../README.md | 6 +- .../api/openapi.yaml | 83 ++++ .../docs/FileApi.md | 9 +- .../docs/FileContent.md | 24 ++ .../docs/RequiredAndNullable.md | 17 + .../docs/RequiredAndNullableApi.md | 73 ++++ .../org/openapitools/client/api/FileApi.java | 20 +- .../client/api/RequiredAndNullableApi.java | 121 ++++++ .../client/model/FileContent.java | 247 ++++++++++++ .../client/model/RequiredAndNullable.java | 328 +++++++++++++++ .../api/RequiredAndNullableApiTest.java | 48 +++ .../client/model/FileContentTest.java | 55 +++ .../client/model/RequiredAndNullableTest.java | 72 ++++ .../openapitools/client/model/EnumTest.java | 2 +- .../client/model/HealthCheckResult.java | 2 +- .../client/model/NullableClass.java | 28 +- .../client/model/ParentWithNullable.java | 2 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../.openapi-generator/FILES | 6 + .../README.md | 6 +- .../api/openapi.yaml | 83 ++++ .../docs/FileApi.md | 9 +- .../docs/FileContent.md | 24 ++ .../docs/RequiredAndNullable.md | 17 + .../docs/RequiredAndNullableApi.md | 73 ++++ .../org/openapitools/client/api/FileApi.java | 20 +- .../client/api/RequiredAndNullableApi.java | 113 ++++++ .../client/model/FileContent.java | 247 ++++++++++++ .../client/model/RequiredAndNullable.java | 328 +++++++++++++++ .../api/RequiredAndNullableApiTest.java | 54 +++ .../client/model/FileContentTest.java | 55 +++ .../client/model/RequiredAndNullableTest.java | 72 ++++ .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../.openapi-generator/FILES | 6 + .../README.md | 6 +- .../api/openapi.yaml | 83 ++++ .../docs/FileApi.md | 9 +- .../docs/FileContent.md | 24 ++ .../docs/RequiredAndNullable.md | 17 + .../docs/RequiredAndNullableApi.md | 73 ++++ .../org/openapitools/client/api/FileApi.java | 18 +- .../client/api/RequiredAndNullableApi.java | 123 ++++++ .../client/model/FileContent.java | 246 ++++++++++++ .../client/model/RequiredAndNullable.java | 327 +++++++++++++++ .../api/RequiredAndNullableApiTest.java | 50 +++ .../client/model/FileContentTest.java | 55 +++ .../client/model/RequiredAndNullableTest.java | 72 ++++ .../openapitools/client/model/EnumTest.java | 2 +- .../client/model/HealthCheckResult.java | 2 +- .../client/model/NullableClass.java | 28 +- .../client/model/ParentWithNullable.java | 2 +- .../client/model/NullableClass.java | 8 +- .../client/model/NullableClass.java | 8 +- .../main/java/org/openapitools/model/Pet.java | 4 +- .../model/ContainerDefaultValueDto.java | 8 +- .../model/NullableMapPropertyDto.java | 2 +- .../model/ContainerDefaultValueDto.java | 8 +- .../model/NullableMapPropertyDto.java | 2 +- .../model/ContainerDefaultValue.java | 8 +- .../model/NullableMapProperty.java | 2 +- .../model/ContainerDefaultValue.java | 8 +- .../model/NullableMapProperty.java | 2 +- .../model/ContainerDefaultValue.java | 8 +- .../model/NullableMapProperty.java | 2 +- .../model/ContainerDefaultValueDto.java | 2 +- .../model/ContainerDefaultValue.java | 8 +- .../model/NullableMapProperty.java | 2 +- .../model/ContainerDefaultValueDto.java | 8 +- .../model/NullableMapPropertyDto.java | 2 +- .../client/model/NullableClass.java | 8 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../.openapi-generator/FILES | 3 + .../java/org/openapitools/api/FileApi.java | 19 +- .../api/RequiredAndNullableApi.java | 83 ++++ .../org/openapitools/model/FileContent.java | 274 +++++++++++++ .../main/java/org/openapitools/model/Foo.java | 12 +- .../model/RequiredAndNullable.java | 334 ++++++++++++++++ .../.openapi-generator/FILES | 3 + .../java/org/openapitools/api/FileApi.java | 19 +- .../api/RequiredAndNullableApi.java | 83 ++++ .../org/openapitools/model/FileContent.java | 274 +++++++++++++ .../main/java/org/openapitools/model/Foo.java | 12 +- .../model/RequiredAndNullable.java | 334 ++++++++++++++++ .../.openapi-generator/FILES | 3 + .../java/org/openapitools/api/FileApi.java | 19 +- .../api/RequiredAndNullableApi.java | 83 ++++ .../org/openapitools/model/FileContent.java | 281 +++++++++++++ .../main/java/org/openapitools/model/Foo.java | 10 +- .../model/RequiredAndNullable.java | 319 +++++++++++++++ .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/ObjectWithUniqueItems.java | 8 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 8 +- .../model/NullableMapProperty.java | 2 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClassDto.java | 2 +- .../model/ContainerDefaultValueDto.java | 14 +- .../model/NullableMapPropertyDto.java | 4 +- .../model/ParentWithNullableDto.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../org/openapitools/model/NullableModel.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../model/NullableMapProperty.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/AdditionalPropertiesClass.java | 2 +- .../model/ContainerDefaultValue.java | 14 +- .../virtualan/model/NullableMapProperty.java | 4 +- .../virtualan/model/ParentWithNullable.java | 2 +- .../org/openapitools/model/EnumTestDto.java | 2 +- .../model/HealthCheckResultDto.java | 2 +- .../openapitools/model/NullableClassDto.java | 28 +- .../model/ParentWithNullableDto.java | 2 +- .../model/AdditionalPropertiesClassDto.java | 2 +- .../model/ContainerDefaultValueDto.java | 14 +- .../model/NullableMapPropertyDto.java | 4 +- .../model/ParentWithNullableDto.java | 2 +- 233 files changed, 8591 insertions(+), 524 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/JavaSpring/notNull.mustache create mode 100644 modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_chainSetter.mustache create mode 100644 modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_constructor.mustache create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/docs/FileContent.md create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullable.md create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullableApi.md create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java create mode 100644 samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileContent.md create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullable.md create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullableApi.md create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/FileContent.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/RequiredAndNullable.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/FileContentTest.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileContent.md create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java create mode 100644 samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileContent.md create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java create mode 100644 samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileContent.md create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java create mode 100644 samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/RequiredAndNullableApi.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/FileContent.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/RequiredAndNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/RequiredAndNullableApi.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/FileContent.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/RequiredAndNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/RequiredAndNullableApi.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/FileContent.java create mode 100644 samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/RequiredAndNullable.java diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 826ae72230cf..554f98183fc7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -225,6 +225,8 @@ protected enum ENUM_PROPERTY_NAMING_TYPE {MACRO_CASE, legacy, original} @Setter protected boolean useJspecify; protected JSpecifyNullableLambda jSpecifyNullableLambda; + protected RemoveAnnotationLambda removeAnnotationLambda; + @Getter @Setter protected boolean useDeductionForOneOfInterfaces = false; @@ -706,9 +708,8 @@ public void processOpts() { } writer.write(content); }); - additionalProperties.put("removeAnnotations", (Mustache.Lambda) (fragment, writer) -> { - writer.write(removeAnnotations(fragment.execute())); - }); + this.removeAnnotationLambda = new RemoveAnnotationLambda(); + additionalProperties.put("removeAnnotations", removeAnnotationLambda); additionalProperties.put("sanitizeDataType", (Mustache.Lambda) (fragment, writer) -> { writer.write(sanitizeDataType(fragment.execute())); }); @@ -881,6 +882,8 @@ protected void applyJspecify() { (sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "package-info.java")); } + // simplify mustache template for jspecify. @Nullable is kept + this.removeAnnotationLambda.keepAnnotation("@Nullable"); } @Override @@ -2076,6 +2079,7 @@ public void postProcessResponseWithProperty(CodegenResponse response, CodegenPro *

* For example: *

    + *
  • {@code @jakarta.annotation.Nullable String} -> {@code String}
  • *
  • {@code @Min(0) @Max(10)Integer} -> {@code Integer}
  • *
  • {@code @Pattern(regexp = "^[a-z]$")String>} -> {@code String}
  • *
  • {@code List<@Pattern(regexp = "^[a-z]$")String>}" -> "{@code List}"
  • @@ -2087,7 +2091,38 @@ public void postProcessResponseWithProperty(CodegenResponse response, CodegenPro */ public String removeAnnotations(String dataType) { if (dataType != null && dataType.contains("@")) { - return dataType.replaceAll("(?:(?i)@[a-z0-9]*+([(].*[)]|\\s*))*+", ""); + return dataType.replaceAll("(?:(?i)@[a-z0-9\\.]*+([(].*[)]|\\s*))*+", ""); + } + return dataType; + } + + /** + * Remove annotations from the given data type string except annotationToKeep. + *

    + * For example: + *

      + *
    • {@code @Nullable @Min(0) @Max(10)Integer} -> {@code @Nullable Integer}
    • + *
    • {@code @Nullable List<@Valid Pet>}" -> "{@code @Nullable List}"
    • + *
    + * + * @param dataType the data type string + * @param annotationToKeep annotation to keep. For example @Nullable + * @return the data type string without annotations. + */ + public String removeAnnotationsWithExclusion(String dataType, String annotationToKeep) { + if (dataType != null && dataType.contains("@")) { + if (annotationToKeep == null) { + return dataType.replaceAll("(?:(?i)@[a-z0-9\\.]*+([(].*[)]|\\s*))*+", ""); + } + annotationToKeep += " "; + boolean annotationPresent = dataType.indexOf(annotationToKeep) >=0; + if (annotationPresent) { + dataType = dataType.replace( annotationToKeep, "%%"); + } + dataType = dataType.replaceAll("(?:(?i)@[a-z0-9\\.]*+([(].*[)]|\\s*))*+", ""); + if (annotationPresent) { + dataType = dataType.replace("%%", annotationToKeep); + } } return dataType; } @@ -2876,7 +2911,7 @@ private int getLastIndex(String dataType) { /** * for Jspecify, remove @Nullable before the datatype and set keptNullable to true if done. */ - class JSpecifyNullableLambda implements Mustache.Lambda { + protected class JSpecifyNullableLambda implements Mustache.Lambda { private String nullableAnnotation = "@Nullable"; // remember @Nullable annotation value when jspecify is used. private String keptNullable = null; @@ -2926,4 +2961,21 @@ protected void addNullableImportForOperation(CodegenOperation codegenOperation) .findAny() .ifPresent(param -> codegenOperation.imports.add("Nullable")); } + + /** + * Simplify the removeAnnotations lambda for custom removal. + */ + protected class RemoveAnnotationLambda implements Mustache.Lambda { + + private String keep; + + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + writer.write(removeAnnotationsWithExclusion(fragment.execute(), keep)); + } + + public void keepAnnotation(String keep) { + this.keep = keep; + } + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index 4a252d8f796a..6f6cb0af8471 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -17,6 +17,7 @@ package org.openapitools.codegen.languages; +import com.samskivert.mustache.Mustache; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.servers.Server; @@ -1411,8 +1412,9 @@ protected void applyJspecify() { (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "package-info.java")); } + String nullableAnnotation = "@" + additionalProperties.get(JAVAX_PACKAGE) + ".annotation.Nullable"; // nullable_var_annotations.mustache generates nullable annotations as @{{javaxPackage}}.annotation.Nullable // override the default pattern for the "find and replace" - jSpecifyNullableLambda.setNullableAnnotation("@" + additionalProperties.get(JAVAX_PACKAGE) + ".annotation.Nullable"); + jSpecifyNullableLambda.setNullableAnnotation(nullableAnnotation); } } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/pojo.mustache index 6552166eaecf..dd8bdc7d0371 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/pojo.mustache @@ -125,7 +125,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -148,7 +148,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pojo.mustache index b14cc844cb56..4c6f9bf697e4 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pojo.mustache @@ -135,7 +135,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -158,7 +158,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -209,7 +209,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pojo.mustache index b14cc844cb56..4c6f9bf697e4 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/pojo.mustache @@ -135,7 +135,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -158,7 +158,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -209,7 +209,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache index 36d2f52f0ede..7994cc2d1181 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache @@ -126,7 +126,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -149,7 +149,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -200,7 +200,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache index 05b7d68369f6..0224febae000 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache @@ -171,7 +171,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/pojo.mustache index d507b60ec467..c720bbd89223 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/pojo.mustache @@ -151,7 +151,7 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -174,7 +174,7 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -230,7 +230,7 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pojo.mustache index 7ec14493ef56..b45c6b5007b1 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pojo.mustache @@ -151,7 +151,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -174,7 +174,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -230,7 +230,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pojo.mustache index 4ffe46114fa6..95d6986ff4c6 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pojo.mustache @@ -151,7 +151,7 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -174,7 +174,7 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -230,7 +230,7 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/Java/nullableArgument_builder.mustache b/modules/openapi-generator/src/main/resources/Java/nullableArgument_builder.mustache index de9d3628ca94..f42c447f5c80 100644 --- a/modules/openapi-generator/src/main/resources/Java/nullableArgument_builder.mustache +++ b/modules/openapi-generator/src/main/resources/Java/nullableArgument_builder.mustache @@ -1 +1 @@ -{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{#removeAnnotations}}{{{datatypeWithEnum}}}{{/removeAnnotations}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{#removeAnnotations}}{{{datatypeWithEnum}}}{{/removeAnnotations}}{{/useJspecify}} \ No newline at end of file +{{#removeAnnotations}}{{>nullableArgumentWithEnum}}{{/removeAnnotations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/Java/nullable_var_annotations.mustache b/modules/openapi-generator/src/main/resources/Java/nullable_var_annotations.mustache index 4f6f6f13dbe1..7b13c89bca91 100644 --- a/modules/openapi-generator/src/main/resources/Java/nullable_var_annotations.mustache +++ b/modules/openapi-generator/src/main/resources/Java/nullable_var_annotations.mustache @@ -1 +1 @@ -{{^useJspecify}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable{{/isNullable}}{{^isNullable}}@{{javaxPackage}}.annotation.Nonnull{{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable{{/required}}{{/useJspecify}}{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{/lambda.jSpecifyNullable}}{{/useJspecify}} \ No newline at end of file +{{#lambda.jSpecifyNullable}}{{^useJspecify}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable{{/isNullable}}{{^isNullable}}@{{javaxPackage}}.annotation.Nonnull{{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable{{/required}}{{/useJspecify}}{{#useJspecify}}{{#required}}{{#isNullable}}@{{javaxPackage}}.annotation.Nullable {{/isNullable}}{{/required}}{{^required}}@{{javaxPackage}}.annotation.Nullable {{/required}}{{/useJspecify}}{{/lambda.jSpecifyNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/Java/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/pojo.mustache index 2c1ff7e32cf3..14d2228aa97d 100644 --- a/modules/openapi-generator/src/main/resources/Java/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/pojo.mustache @@ -154,7 +154,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); } try { @@ -177,7 +177,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#vendorExtensions.x-is-jackson-optional-nullable}} - if (this.{{name}} == null || !this.{{name}}.isPresent()) { + if (this.{{name}} == null || !this.{{name}}.isPresent() || this.{{name}}.get() == null) { this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); } try { @@ -233,7 +233,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") {{/swagger1AnnotationLibrary}} {{#swagger2AnnotationLibrary}} - @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}"{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/beanValidation.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/beanValidation.mustache index 0aed4a92d734..325a13688611 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}}{{^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 +{{>notNull}}{{#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/notNull.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/notNull.mustache new file mode 100644 index 000000000000..590235a968a5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/notNull.mustache @@ -0,0 +1 @@ +{{#required}}{{^isReadOnly}}{{#isNullable}}{{#openApiNullable}}/* @Present */ {{/openApiNullable}}{{/isNullable}}{{^isNullable}}@NotNull {{/isNullable}}{{/isReadOnly}}{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/nullableAnnotation_jspecify.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/nullableAnnotation_jspecify.mustache index 225d7f0ff62c..c7624e180091 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/nullableAnnotation_jspecify.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/nullableAnnotation_jspecify.mustache @@ -1 +1 @@ -{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}{{^useOptional}}{{#openApiNullable}}{{^isNullable}}@Nullable {{/isNullable}}{{/openApiNullable}}{{^openApiNullable}}@Nullable {{/openApiNullable}}{{/useOptional}}{{/required}}{{/lambda.jSpecifyNullable}}{{/useJspecify}} \ No newline at end of file +{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{#required}}{{#isNullable}}{{^openApiNullable}}@Nullable {{/openApiNullable}}{{/isNullable}}{{/required}}{{^required}}{{^useOptional}}{{#openApiNullable}}{{^isNullable}}@Nullable {{/isNullable}}{{/openApiNullable}}{{^openApiNullable}}@Nullable {{/openApiNullable}}{{/useOptional}}{{/required}}{{/lambda.jSpecifyNullable}}{{/useJspecify}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_builder.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_builder.mustache index e42e412e8730..4327e45d9e2a 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_builder.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_builder.mustache @@ -1 +1 @@ -{{#useJspecify}}{{^required}}{{#lambda.jSpecifyNullable}}{{^useOptional}}@Nullable {{/useOptional}}{{#useOptional}}{{#optionalAcceptNullable}}@Nullable {{/optionalAcceptNullable}}{{/useOptional}}{{/lambda.jSpecifyNullable}}{{/required}}{{#lambda.jSpecifyDatatype}}{{#removeAnnotations}}{{{datatypeWithEnum}}}{{/removeAnnotations}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{#removeAnnotations}}{{{datatypeWithEnum}}}{{/removeAnnotations}}{{/useJspecify}} \ No newline at end of file +{{#removeAnnotations}}{{>nullableArgument_chainSetter}}{{/removeAnnotations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_chainSetter.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_chainSetter.mustache new file mode 100644 index 000000000000..a199e52ba86c --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_chainSetter.mustache @@ -0,0 +1 @@ +{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{#required}}{{#isNullable}}@Nullable {{/isNullable}}{{/required}}{{^required}}{{^useOptional}}@Nullable {{/useOptional}}{{#useOptional}}{{#optionalAcceptNullable}}@Nullable {{/optionalAcceptNullable}}{{/useOptional}}{{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{>nullableAnnotation_default}}{{{datatypeWithEnum}}}{{/useJspecify}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_constructor.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_constructor.mustache new file mode 100644 index 000000000000..a001ec18760d --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/nullableArgument_constructor.mustache @@ -0,0 +1 @@ +{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{#required}}{{#isNullable}}@Nullable {{/isNullable}}{{/required}}{{^required}}@Nullable {{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{>nullableAnnotation}}{{{datatypeWithEnum}}}{{/useJspecify}} \ 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 47b1fd30dae0..99dc720a635d 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache @@ -112,7 +112,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}} /** * Constructor with only required parameters{{#generateConstructorWithAllArgs}}{{^vendorExtensions.x-java-all-args-constructor}} and all parameters{{/vendorExtensions.x-java-all-args-constructor}}{{/generateConstructorWithAllArgs}} */ - public {{classname}}({{#requiredVars}}{{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}{{/requiredVars}}) { + public {{classname}}({{#requiredVars}}{{>nullableArgument_constructor}} {{name}}{{^-last}}, {{/-last}}{{/requiredVars}}) { {{#parent}} super({{#parentRequiredVars}}{{name}}{{^-last}}, {{/-last}}{{/parentRequiredVars}}); {{/parent}} @@ -135,7 +135,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}} /** * Constructor with all args parameters */ - public {{classname}}({{#vendorExtensions.x-java-all-args-constructor-vars}}{{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}@Nullable {{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{>nullableAnnotation}}{{{datatypeWithEnum}}}{{/useJspecify}} {{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-java-all-args-constructor-vars}}) { + public {{classname}}({{#vendorExtensions.x-java-all-args-constructor-vars}}{{>nullableArgument_constructor}} {{name}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-java-all-args-constructor-vars}}) { {{#parent}} super({{#parentVars}}{{name}}{{^-last}}, {{/-last}}{{/parentVars}}); {{/parent}} @@ -154,7 +154,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}} {{^lombok.Data}} {{! begin feature: fluent setter methods }} - public {{classname}} {{name}}({{#useJspecify}}{{#lambda.jSpecifyNullable}}{{^required}}{{^useOptional}}@Nullable {{/useOptional}}{{#useOptional}}{{#optionalAcceptNullable}}@Nullable {{/optionalAcceptNullable}}{{/useOptional}}{{/required}}{{/lambda.jSpecifyNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{/useJspecify}}{{^useJspecify}}{{>nullableAnnotation_default}}{{{datatypeWithEnum}}}{{/useJspecify}} {{name}}) { + public {{classname}} {{name}}({{>nullableArgument_chainSetter}} {{name}}) { {{#openApiNullable}} this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional.of{{#optionalAcceptNullable}}Nullable{{/optionalAcceptNullable}}({{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{name}}{{#isNullable}}){{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}){{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}; {{/openApiNullable}} @@ -167,7 +167,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}} public {{classname}} add{{nameInPascalCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { {{#openApiNullable}} - if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) { + if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent() || this.{{name}}.get() == null{{/isNullable}}) { this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}{{#isNullable}}){{/isNullable}}; } this.{{name}}{{#isNullable}}.get(){{/isNullable}}.add({{name}}Item); @@ -185,7 +185,7 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}} public {{classname}} put{{nameInPascalCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { {{#openApiNullable}} - if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) { + if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent() || this.{{name}}.get() == null{{/isNullable}}) { this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}HashMap{{/uniqueItems}}<>(){{/defaultValue}}{{#isNullable}}){{/isNullable}}; } this.{{name}}{{#isNullable}}.get(){{/isNullable}}.put(key, {{name}}Item); @@ -228,10 +228,10 @@ public {{>sealed}}class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}} {{>beanValidation}}{{! prevent indent}} {{/useBeanValidation}} {{^useBeanValidation}} - {{#required}}@NotNull{{/required}} + {{#lambda.trim}}{{>notNull}}{{/lambda.trim}} {{/useBeanValidation}} {{#swagger2AnnotationLibrary}} - @Schema(name = "{{{baseName}}}"{{#isReadOnly}}, accessMode = Schema.AccessMode.READ_ONLY{{/isReadOnly}}{{#example}}, example = "{{{.}}}"{{/example}}{{#description}}, description = "{{{.}}}"{{/description}}{{#deprecated}}, deprecated = true{{/deprecated}}, requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}) + @Schema(name = "{{{baseName}}}"{{#isReadOnly}}, accessMode = Schema.AccessMode.READ_ONLY{{/isReadOnly}}{{#example}}, example = "{{{.}}}"{{/example}}{{#description}}, description = "{{{.}}}"{{/description}}{{#deprecated}}, deprecated = true{{/deprecated}}, requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}{{#isNullable}}, nullable = true{{/isNullable}}) {{/swagger2AnnotationLibrary}} {{#swagger1AnnotationLibrary}} @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index bd2a9ed544c9..b3940c9078ba 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -4697,27 +4697,28 @@ public void testRestClientMultipartFormParamsGuardAgainstEmptyLists() { @DataProvider(name = "jspecifyLibraries") public Object[][] jspecifyLibraries() { return new Object[][]{ - {"restclient", false, true}, - {"restclient", true, false}, - {"webclient", false, true}, - {"webclient", true, false}, - {"resttemplate", false, true}, - {"resttemplate", true, true}, - {"native", false, true} + {"restclient", 3, true}, + {"restclient", 4, false}, + {"webclient", 3, true}, + {"webclient", 4, false}, + {"resttemplate", 3, true}, + {"resttemplate", 4, true}, + {"native", 3, true} }; } @Test(dataProvider = "jspecifyLibraries") - public void testJspecify(String library, boolean useSpringBoot4, boolean hasJspecifyDependency) throws IOException { + public void testJspecify(String library, int springBootVersion, boolean hasJspecifyDependency) throws IOException { final Map files = generateFromContract("src/test/resources/3_0/java/jspecify.yaml", library, Map.of(USE_JSPECIFY, true, "containerDefaultToNull", true, - USE_SPRING_BOOT4, useSpringBoot4, + USE_SPRING_BOOT4, springBootVersion == 4, JavaClientCodegen.OPENAPI_NULLABLE, false, GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, true, GENERATE_BUILDERS, true, - USE_ABSTRACTION_FOR_FILES, true - ), + USE_ABSTRACTION_FOR_FILES, true, + ANNOTATION_LIBRARY, "swagger2" + ), codegenConfigurator -> codegenConfigurator .setValidateSpec(false) @@ -4760,6 +4761,16 @@ public void testJspecify(String library, boolean useSpringBoot4, boolean hasJspe .fileContains( "public Foo(@JsonProperty(JSON_PROPERTY_DT) java.time.@Nullable Instant dt, @JsonProperty(JSON_PROPERTY_NULLABLE_DT) java.time.@Nullable Instant nullableDt, @JsonProperty(JSON_PROPERTY_BINARY) @Nullable File binary, @JsonProperty(JSON_PROPERTY_NULLABLE_BINARY) @Nullable File nullableBinary, @JsonProperty(JSON_PROPERTY_LIST_OF_DT) @Nullable List listOfDt, @JsonProperty(JSON_PROPERTY_LIST_MIN_INTEMS) @Nullable List listMinIntems, @JsonProperty(JSON_PROPERTY_NULLABLE_LIST_MIN_INTEMS) @Nullable List nullableListMinIntems, @JsonProperty(JSON_PROPERTY_REQUIRED_DT) java.time.Instant requiredDt, @JsonProperty(JSON_PROPERTY_NUMBER) java.math.@Nullable BigDecimal number, @JsonProperty(JSON_PROPERTY_NULLABLE_NUMBER) java.math.@Nullable BigDecimal nullableNumber, @JsonProperty(JSON_PROPERTY_COLOR) @Nullable String color, @JsonProperty(JSON_PROPERTY_REQUIRED_COLOR) String requiredColor, @JsonProperty(JSON_PROPERTY_NULLABLE_COLOR) @Nullable String nullableColor) {"); } + JavaFileAssert.assertThat(files.get("RequiredAndNullable.java")) + .fileContains( + "void setStr(@Nullable String str)", + "RequiredAndNullable str(@Nullable String str)", + "@Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = \"\", nullable = true)"); + JavaFileAssert.assertThat(files.get("FileContent.java")) + .fileContains( + "private @Nullable VirusScanEnum virusScan", + "FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan)" + ); if (!RESTTEMPLATE.equals(library)) { JavaFileAssert.assertThat(files.get("FooApi.java")) .fileContains("fooDtParamGet(java.time.@Nullable Instant dtParam, java.time.@Nullable Instant dtQuery, java.time.@Nullable Instant dtCookie, @Nullable String color)"); @@ -4778,14 +4789,15 @@ public void testJspecify(String library, boolean useSpringBoot4, boolean hasJspe } @Test(dataProvider = "jspecifyLibraries") - public void testJspecify_openapiNullable(String library, boolean useSpringBoot4, boolean hasJspecifyDependency) throws IOException { + public void testJspecify_openapiNullable(String library, int springBootVersion, boolean hasJspecifyDependency) throws IOException { final Map files = generateFromContract("src/test/resources/3_0/java/jspecify.yaml", library, Map.of(USE_JSPECIFY, true, "containerDefaultToNull", true, - USE_SPRING_BOOT4, useSpringBoot4, + USE_SPRING_BOOT4, springBootVersion == 4, JavaClientCodegen.OPENAPI_NULLABLE, true, GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, true, - GENERATE_BUILDERS, true + GENERATE_BUILDERS, true, + ANNOTATION_LIBRARY, "swagger2" ), codegenConfigurator -> codegenConfigurator 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 e5c1ad926aa6..d959fdcb607a 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 @@ -7143,6 +7143,7 @@ public void testJspecify(String library, int springBootVersion) throws IOExcepti SpringCodegen.OPENAPI_NULLABLE, false, USE_BEANVALIDATION, true, GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, true, + GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS, true, INTERFACE_ONLY, false, GENERATE_BUILDERS, true, springVersionProperty, springBootVersion > 2 @@ -7179,7 +7180,10 @@ public void testJspecify(String library, int springBootVersion) throws IOExcepti "Foo.Builder dt(java.time.@Nullable Instant dt)", "Foo.Builder requiredDt(java.time.Instant requiredDt)", "Foo.Builder nullableNumber(@Nullable BigDecimal nullableNumber)" - ); + ).fileDoesNotContain( + "javax.annotation.Nullable", + "jakarta.annotation.Nullable") + .assertMethod("getRequiredDt").assertMethodAnnotations().containsWithName("NotNull").containsWithName("Valid"); JavaFileAssert.assertThat(files.get("FooApi.java")) .assertTypeAnnotations().doesImportAnnotation("org.jspecify.annotations.Nullable").toType() .fileContains( @@ -7188,6 +7192,25 @@ public void testJspecify(String library, int springBootVersion) throws IOExcepti "java.time.@Nullable Instant dtCookie", " @RequestParam(value = \"color\", required = false, defaultValue = \"red\") String color" ); + JavaFileAssert.assertThat(files.get("RequiredAndNullable.java")) + .fileContains( + "private @Nullable String str = null;", + "private @Nullable List _list;", + "RequiredAndNullable(@Nullable String str, org.springframework.core.io.@Nullable Resource file, @Nullable String color, String onlyRequired, @Nullable List _list)", + "@Nullable String getStr()", + "void setStr(@Nullable String str)", + "RequiredAndNullable str(@Nullable String str)", + "RequiredAndNullable.Builder str(@Nullable String str)" + ) + .assertMethod("getStr").assertMethodAnnotations().doesNotContainWithName("NotNull"); + if (!library.equals(SPRING_HTTP_INTERFACE)) { + // SPRING_HTTP_INTERFACE does not support @Schema generation (yet) + JavaFileAssert.assertThat(files.get("RequiredAndNullable.java")) + .fileContains( + "@Schema(name = \"str\", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true)"); + } + JavaFileAssert.assertThat(files.get("FileContent.java")) + .fileContains("VirusScanEnum getVirusScan()"); JavaFileAssert.assertThat(files.get("api/package-info.java")) .fileContains("@org.jspecify.annotations.NullMarked"); JavaFileAssert.assertThat(files.get("model/package-info.java")) @@ -7210,6 +7233,7 @@ public void testJspecify_openapiNullable(String library, int springBootVersion) CONTAINER_DEFAULT_TO_NULL, true, USE_BEANVALIDATION, true, GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, true, + GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS, true, CodegenConstants.OPENAPI_NULLABLE, true, INTERFACE_ONLY, false, GENERATE_BUILDERS, true, @@ -7246,7 +7270,10 @@ public void testJspecify_openapiNullable(String library, int springBootVersion) "Foo.Builder requiredDt(java.time.Instant requiredDt)", "Foo.Builder nullableNumber(@Nullable BigDecimal nullableNumber)", "Foo.Builder nullableNumber(JsonNullable nullableNumber)" - ); + ).fileDoesNotContain( + "javax.annotation.Nullable", + "jakarta.annotation.Nullable") + .assertMethod("getRequiredDt").assertMethodAnnotations().containsWithName("NotNull").containsWithName("Valid"); JavaFileAssert.assertThat(files.get("FooApi.java")) .assertTypeAnnotations().doesImportAnnotation("org.jspecify.annotations.Nullable").toType() .fileContains( @@ -7254,6 +7281,17 @@ public void testJspecify_openapiNullable(String library, int springBootVersion) "java.time.@Nullable Instant dtQuery", "java.time.@Nullable Instant dtCookie" ); + JavaFileAssert.assertThat(files.get("RequiredAndNullable.java")) + .fileContains( + "private JsonNullable str = JsonNullable.undefined();", + "private JsonNullable> _list = JsonNullable.>undefined();", + "RequiredAndNullable(@Nullable String str, org.springframework.core.io.@Nullable Resource file, @Nullable String color, String onlyRequired, @Nullable List _list)", + "JsonNullable getStr()", + "void setStr(JsonNullable str)", + "RequiredAndNullable str(@Nullable String str)", + "RequiredAndNullable.Builder str(@Nullable String str)", + " /* @Present */" + ).assertMethod("getStr").assertMethodAnnotations().doesNotContainWithName("NotNull"); JavaFileAssert.assertThat(files.get("api/package-info.java")) .fileContains("@org.jspecify.annotations.NullMarked"); JavaFileAssert.assertThat(files.get("model/package-info.java")) @@ -7287,6 +7325,7 @@ public void testJspecify_useOptional(String library, int springBootVersion, bool CONTAINER_DEFAULT_TO_NULL, true, USE_BEANVALIDATION, true, GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, true, + GENERATE_CONSTRUCTOR_WITH_REQUIRED_ARGS, true, SpringCodegen.USE_OPTIONAL, true, OPTIONAL_ACCEPT_NULLABLE, optionalAcceptNullable, INTERFACE_ONLY, false, @@ -7319,7 +7358,10 @@ public void testJspecify_useOptional(String library, int springBootVersion, bool "public Foo(java.time.@Nullable Instant dt, java.time.@Nullable Instant nullableDt, org.springframework.core.io.@Nullable Resource binary, org.springframework.core.io.@Nullable Resource nullableBinary, @Nullable List listOfDt, @Nullable List listMinIntems, @Nullable List nullableListMinIntems, java.time.Instant requiredDt, @Nullable BigDecimal number, @Nullable BigDecimal nullableNumber, @Nullable String color, String requiredColor, @Nullable String nullableColor) {", "Foo.Builder requiredDt(java.time.Instant requiredDt)", "Foo.Builder nullableNumber(JsonNullable nullableNumber)" - ); + ).fileDoesNotContain( + "javax.annotation.Nullable", + "jakarta.annotation.Nullable") + .assertMethod("getRequiredDt").assertMethodAnnotations().containsWithName("NotNull").containsWithName("Valid"); if (optionalAcceptNullable) { fooAssert.fileContains( "Foo dt(java.time.@Nullable Instant dt) {\n this.dt = Optional.ofNullable(dt);", @@ -7336,6 +7378,15 @@ public void testJspecify_useOptional(String library, int springBootVersion, bool "Optional dtQuery", "Optional dtCookie" ); + JavaFileAssert.assertThat(files.get("RequiredAndNullable.java")) + .fileContains( + "private JsonNullable str = JsonNullable.undefined();", + "RequiredAndNullable(@Nullable String str, org.springframework.core.io.@Nullable Resource file, @Nullable String color, String onlyRequired, @Nullable List _list)", + "JsonNullable getStr()", + "void setStr(JsonNullable str)", + "RequiredAndNullable str(@Nullable String str)", + "RequiredAndNullable.Builder str(@Nullable String str)" + ).assertMethod("getStr").assertMethodAnnotations().doesNotContainWithName("NotNull"); JavaFileAssert.assertThat(files.get("api/package-info.java")) .fileContains("@org.jspecify.annotations.NullMarked"); JavaFileAssert.assertThat(files.get("model/package-info.java")) diff --git a/modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml b/modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml index 99a4de1af48c..4d166384f1ad 100644 --- a/modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml @@ -4,6 +4,8 @@ info: title: jspecify version: 1.0.0 tags: + - name: requiredAndNullable + description: requiredAndNullable - name: foo description: foo - name: upload @@ -45,6 +47,24 @@ paths: application/json: schema: $ref: '#/components/schemas/Foo' + /requiredAndNullable: + post: + tags: + - requiredAndNullable + requestBody: + required: true + description: bodyWithRequiredAndNullableAttributes + content: + application/json: + schema: + $ref: '#/components/schemas/RequiredAndNullable' + responses: + default: + description: response + content: + application/json: + schema: + $ref: '#/components/schemas/RequiredAndNullable' /upload: post: tags: @@ -94,7 +114,10 @@ paths: responses: '200': description: ok - + content: + application/json: + schema: + $ref: '#/components/schemas/FileContent' components: schemas: Foo: @@ -152,7 +175,48 @@ components: type: string default: red nullable: true - - - - + RequiredAndNullable: + type: object + required: + - str + - file + - color + - onlyRequired + - list + properties: + str: + nullable: true + type: string + file: + nullable: true + type: string + format: binary + color: + type: string + default: red + nullable: true + onlyRequired: + # NON nullable + type: string + list: + type: array + nullable: true + items: + type: string + FileContent: + type: object + required: + - name + properties: + name: + type: string + readOnly: true + size: + type: integer + readOnly: true + virusScan: + type: string + readOnly: true + enum: + - clean + - detected diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java index f1bde487d331..9187ba549dbc 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -293,7 +293,7 @@ public DefaultValue arrayStringNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) { + if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent() || this.arrayStringNullable.get() == null) { this.arrayStringNullable = JsonNullable.>of(new ArrayList<>()); } try { @@ -338,7 +338,7 @@ public DefaultValue arrayStringExtensionNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringExtensionNullableItem(String arrayStringExtensionNullableItem) { - if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent()) { + if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent() || this.arrayStringExtensionNullable.get() == null) { this.arrayStringExtensionNullable = JsonNullable.>of(new ArrayList<>()); } try { diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java index 3ef093b628b3..785dfa821858 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -286,7 +286,7 @@ public DefaultValue arrayStringNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) { + if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent() || this.arrayStringNullable.get() == null) { this.arrayStringNullable = JsonNullable.>of(new ArrayList<>()); } try { @@ -330,7 +330,7 @@ public DefaultValue arrayStringExtensionNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringExtensionNullableItem(String arrayStringExtensionNullableItem) { - if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent()) { + if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent() || this.arrayStringExtensionNullable.get() == null) { this.arrayStringExtensionNullable = JsonNullable.>of(new ArrayList<>()); } try { diff --git a/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DefaultValue.java index a9d8e94e3ef7..73a13cf4bb17 100644 --- a/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -291,7 +291,7 @@ public DefaultValue arrayStringNullable(@jakarta.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -336,7 +336,7 @@ public DefaultValue arrayStringExtensionNullable(@jakarta.annotation.Nullable Li } public DefaultValue addArrayStringExtensionNullableItem(String arrayStringExtensionNullableItem) { - if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent()) { + if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent() || this.arrayStringExtensionNullable.get() == null) { this.arrayStringExtensionNullable = JsonNullable.>of(new ArrayList<>()); } try { diff --git a/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/model/DefaultValue.java index af5ff83400cc..a39e748782ad 100644 --- a/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -290,7 +290,7 @@ public DefaultValue arrayStringNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) { + if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent() || this.arrayStringNullable.get() == null) { this.arrayStringNullable = JsonNullable.>of(new ArrayList<>()); } try { @@ -335,7 +335,7 @@ public DefaultValue arrayStringExtensionNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringExtensionNullableItem(String arrayStringExtensionNullableItem) { - if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent()) { + if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent() || this.arrayStringExtensionNullable.get() == null) { this.arrayStringExtensionNullable = JsonNullable.>of(new ArrayList<>()); } try { diff --git a/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/model/DefaultValue.java index a25c25ef60fe..1cd4856963c5 100644 --- a/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -291,7 +291,7 @@ public DefaultValue arrayStringNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) { + if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent() || this.arrayStringNullable.get() == null) { this.arrayStringNullable = JsonNullable.>of(new ArrayList<>()); } try { @@ -336,7 +336,7 @@ public DefaultValue arrayStringExtensionNullable(@javax.annotation.Nullable List } public DefaultValue addArrayStringExtensionNullableItem(String arrayStringExtensionNullableItem) { - if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent()) { + if (this.arrayStringExtensionNullable == null || !this.arrayStringExtensionNullable.isPresent() || this.arrayStringExtensionNullable.get() == null) { this.arrayStringExtensionNullable = JsonNullable.>of(new ArrayList<>()); } try { diff --git a/samples/client/petstore/java/apache-httpclient-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/apache-httpclient-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java index 7fc9fa102da5..ef4b78a8f79a 100644 --- a/samples/client/petstore/java/apache-httpclient-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/apache-httpclient-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java @@ -319,7 +319,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -364,7 +364,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -442,7 +442,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -487,7 +487,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java index 9d6883690dee..0a4f4ab52ae5 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java @@ -320,7 +320,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -365,7 +365,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -443,7 +443,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -488,7 +488,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/feign-hc5/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/feign-hc5/src/main/java/org/openapitools/client/model/NullableClass.java index 7b7b56d9ba9d..dd85b49235bd 100644 --- a/samples/client/petstore/java/feign-hc5/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/feign-hc5/src/main/java/org/openapitools/client/model/NullableClass.java @@ -310,7 +310,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -356,7 +356,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -436,7 +436,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -482,7 +482,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/NullableClass.java index 7b7b56d9ba9d..dd85b49235bd 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/NullableClass.java @@ -310,7 +310,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -356,7 +356,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -436,7 +436,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -482,7 +482,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/jersey3-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/jersey3-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java index e6fb45eef3ec..c0da02d667fa 100644 --- a/samples/client/petstore/java/jersey3-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/jersey3-jackson3/src/main/java/org/openapitools/client/model/NullableClass.java @@ -317,7 +317,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -363,7 +363,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -443,7 +443,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -489,7 +489,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/NullableClass.java index 16526b1f6127..4152edc03094 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/NullableClass.java @@ -318,7 +318,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -364,7 +364,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -444,7 +444,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -490,7 +490,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java index b85b8b99e0d5..96a4e9964643 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java @@ -302,7 +302,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -346,7 +346,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -422,7 +422,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -466,7 +466,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/native-jackson3-jspecify/.openapi-generator/FILES b/samples/client/petstore/java/native-jackson3-jspecify/.openapi-generator/FILES index b6ae45415018..b169aa1ef064 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/.openapi-generator/FILES +++ b/samples/client/petstore/java/native-jackson3-jspecify/.openapi-generator/FILES @@ -6,8 +6,11 @@ api/openapi.yaml build.gradle build.sbt docs/FileApi.md +docs/FileContent.md docs/Foo.md docs/FooApi.md +docs/RequiredAndNullable.md +docs/RequiredAndNullableApi.md docs/UploadApi.md git_push.sh gradle.properties @@ -31,9 +34,12 @@ src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/FileApi.java src/main/java/org/openapitools/client/api/FooApi.java +src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java src/main/java/org/openapitools/client/api/UploadApi.java src/main/java/org/openapitools/client/api/package-info.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java +src/main/java/org/openapitools/client/model/FileContent.java src/main/java/org/openapitools/client/model/Foo.java +src/main/java/org/openapitools/client/model/RequiredAndNullable.java src/main/java/org/openapitools/client/model/package-info.java src/main/java/org/openapitools/client/package-info.java diff --git a/samples/client/petstore/java/native-jackson3-jspecify/README.md b/samples/client/petstore/java/native-jackson3-jspecify/README.md index 9692175454f4..ae7c8bb3bead 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/README.md +++ b/samples/client/petstore/java/native-jackson3-jspecify/README.md @@ -87,7 +87,8 @@ public class FileApiExample { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -110,6 +111,8 @@ Class | Method | HTTP request | Description *FileApi* | [**fileIdGetWithHttpInfo**](docs/FileApi.md#fileIdGetWithHttpInfo) | **GET** /file/{id} | *FooApi* | [**fooDtParamGet**](docs/FooApi.md#fooDtParamGet) | **GET** /foo/{dtParam} | *FooApi* | [**fooDtParamGetWithHttpInfo**](docs/FooApi.md#fooDtParamGetWithHttpInfo) | **GET** /foo/{dtParam} | +*RequiredAndNullableApi* | [**requiredAndNullablePost**](docs/RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | +*RequiredAndNullableApi* | [**requiredAndNullablePostWithHttpInfo**](docs/RequiredAndNullableApi.md#requiredAndNullablePostWithHttpInfo) | **POST** /requiredAndNullable | *UploadApi* | [**uploadFilesPost**](docs/UploadApi.md#uploadFilesPost) | **POST** /uploadFiles | *UploadApi* | [**uploadFilesPostWithHttpInfo**](docs/UploadApi.md#uploadFilesPostWithHttpInfo) | **POST** /uploadFiles | *UploadApi* | [**uploadPost**](docs/UploadApi.md#uploadPost) | **POST** /upload | @@ -118,7 +121,9 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [FileContent](docs/FileContent.md) - [Foo](docs/Foo.md) + - [RequiredAndNullable](docs/RequiredAndNullable.md) diff --git a/samples/client/petstore/java/native-jackson3-jspecify/api/openapi.yaml b/samples/client/petstore/java/native-jackson3-jspecify/api/openapi.yaml index b5f967c8460e..15c1f4176a50 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/api/openapi.yaml +++ b/samples/client/petstore/java/native-jackson3-jspecify/api/openapi.yaml @@ -6,6 +6,8 @@ info: servers: - url: / tags: +- description: requiredAndNullable + name: requiredAndNullable - description: foo name: foo - description: upload @@ -59,6 +61,27 @@ paths: - foo x-accepts: - application/json + /requiredAndNullable: + post: + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: bodyWithRequiredAndNullableAttributes + required: true + responses: + default: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: response + tags: + - requiredAndNullable + x-content-type: application/json + x-accepts: + - application/json /upload: post: requestBody: @@ -103,6 +126,10 @@ paths: style: simple responses: "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FileContent" description: ok tags: - file @@ -185,6 +212,62 @@ components: required: - requiredColor - requiredDt + RequiredAndNullable: + example: + str: str + file: "" + color: red + onlyRequired: onlyRequired + list: + - list + - list + properties: + str: + nullable: true + type: string + file: + format: binary + nullable: true + type: string + color: + default: red + nullable: true + type: string + onlyRequired: + type: string + list: + items: + type: string + nullable: true + type: array + required: + - color + - file + - list + - onlyRequired + - str + type: object + FileContent: + example: + name: name + size: 0 + virusScan: clean + properties: + name: + readOnly: true + type: string + size: + readOnly: true + type: integer + virusScan: + enum: + - clean + - detected + readOnly: true + type: string + required: + - name + type: object _upload_post_request: properties: file: diff --git a/samples/client/petstore/java/native-jackson3-jspecify/docs/FileApi.md b/samples/client/petstore/java/native-jackson3-jspecify/docs/FileApi.md index 74ab70ddac94..b9f81d353ef9 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/docs/FileApi.md +++ b/samples/client/petstore/java/native-jackson3-jspecify/docs/FileApi.md @@ -11,7 +11,7 @@ All URIs are relative to *http://localhost* ## fileIdGet -> void fileIdGet(id) +> FileContent fileIdGet(id) @@ -33,7 +33,8 @@ public class Example { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -54,8 +55,8 @@ public class Example { ### Return type +[**FileContent**](FileContent.md) -null (empty response body) ### Authorization @@ -64,7 +65,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | @@ -73,7 +74,7 @@ No authorization required ## fileIdGetWithHttpInfo -> ApiResponse fileIdGetWithHttpInfo(id) +> ApiResponse fileIdGetWithHttpInfo(id) @@ -96,9 +97,10 @@ public class Example { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - ApiResponse response = apiInstance.fileIdGetWithHttpInfo(id); + ApiResponse response = apiInstance.fileIdGetWithHttpInfo(id); System.out.println("Status code: " + response.getStatusCode()); System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -119,8 +121,8 @@ public class Example { ### Return type +ApiResponse<[**FileContent**](FileContent.md)> -ApiResponse ### Authorization @@ -129,7 +131,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | diff --git a/samples/client/petstore/java/native-jackson3-jspecify/docs/FileContent.md b/samples/client/petstore/java/native-jackson3-jspecify/docs/FileContent.md new file mode 100644 index 000000000000..5b6654a0bf18 --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/docs/FileContent.md @@ -0,0 +1,24 @@ + + +# FileContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [readonly] | +|**size** | **Integer** | | [optional] [readonly] | +|**virusScan** | [**VirusScanEnum**](#VirusScanEnum) | | [optional] [readonly] | + + + +## Enum: VirusScanEnum + +| Name | Value | +|---- | -----| +| CLEAN | "clean" | +| DETECTED | "detected" | + + + diff --git a/samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullable.md b/samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullable.md new file mode 100644 index 000000000000..ff4ade0f226d --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullable.md @@ -0,0 +1,17 @@ + + +# RequiredAndNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**str** | **String** | | | +|**_file** | **File** | | | +|**color** | **String** | | | +|**onlyRequired** | **String** | | | +|**_list** | **List<String>** | | | + + + diff --git a/samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullableApi.md b/samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullableApi.md new file mode 100644 index 000000000000..eaad2b9ed25c --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/docs/RequiredAndNullableApi.md @@ -0,0 +1,140 @@ +# RequiredAndNullableApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**requiredAndNullablePost**](RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | | +| [**requiredAndNullablePostWithHttpInfo**](RequiredAndNullableApi.md#requiredAndNullablePostWithHttpInfo) | **POST** /requiredAndNullable | | + + + +## requiredAndNullablePost + +> RequiredAndNullable requiredAndNullablePost(requiredAndNullable) + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.RequiredAndNullableApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + RequiredAndNullableApi apiInstance = new RequiredAndNullableApi(defaultClient); + RequiredAndNullable requiredAndNullable = new RequiredAndNullable(); // RequiredAndNullable | bodyWithRequiredAndNullableAttributes + try { + RequiredAndNullable result = apiInstance.requiredAndNullablePost(requiredAndNullable); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RequiredAndNullableApi#requiredAndNullablePost"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **requiredAndNullable** | [**RequiredAndNullable**](RequiredAndNullable.md)| bodyWithRequiredAndNullableAttributes | | + +### Return type + +[**RequiredAndNullable**](RequiredAndNullable.md) + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + +## requiredAndNullablePostWithHttpInfo + +> ApiResponse requiredAndNullablePostWithHttpInfo(requiredAndNullable) + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.RequiredAndNullableApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + RequiredAndNullableApi apiInstance = new RequiredAndNullableApi(defaultClient); + RequiredAndNullable requiredAndNullable = new RequiredAndNullable(); // RequiredAndNullable | bodyWithRequiredAndNullableAttributes + try { + ApiResponse response = apiInstance.requiredAndNullablePostWithHttpInfo(requiredAndNullable); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling RequiredAndNullableApi#requiredAndNullablePost"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **requiredAndNullable** | [**RequiredAndNullable**](RequiredAndNullable.md)| bodyWithRequiredAndNullableAttributes | | + +### Return type + +ApiResponse<[**RequiredAndNullable**](RequiredAndNullable.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java index 668625401764..e1fd88a5dbfe 100644 --- a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java @@ -18,6 +18,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.Pair; +import org.openapitools.client.model.FileContent; import tools.jackson.core.JacksonException; import tools.jackson.core.type.TypeReference; @@ -166,10 +167,11 @@ private File prepareDownloadFile(HttpResponse response) throws IOEx * * * @param id (required) + * @return FileContent * @throws ApiException if fails to make API call */ - public void fileIdGet(String id) throws ApiException { - fileIdGet(id, null); + public FileContent fileIdGet(String id) throws ApiException { + return fileIdGet(id, null); } /** @@ -177,20 +179,22 @@ public void fileIdGet(String id) throws ApiException { * * @param id (required) * @param headers Optional headers to include in the request + * @return FileContent * @throws ApiException if fails to make API call */ - public void fileIdGet(String id, Map headers) throws ApiException { - fileIdGetWithHttpInfo(id, headers); + public FileContent fileIdGet(String id, Map headers) throws ApiException { + ApiResponse localVarResponse = fileIdGetWithHttpInfo(id, headers); + return localVarResponse.getData(); } /** * * * @param id (required) - * @return ApiResponse<Void> + * @return ApiResponse<FileContent> * @throws ApiException if fails to make API call */ - public ApiResponse fileIdGetWithHttpInfo(String id) throws ApiException { + public ApiResponse fileIdGetWithHttpInfo(String id) throws ApiException { return fileIdGetWithHttpInfo(id, null); } @@ -199,10 +203,10 @@ public ApiResponse fileIdGetWithHttpInfo(String id) throws ApiException { * * @param id (required) * @param headers Optional headers to include in the request - * @return ApiResponse<Void> + * @return ApiResponse<FileContent> * @throws ApiException if fails to make API call */ - public ApiResponse fileIdGetWithHttpInfo(String id, Map headers) throws ApiException { + public ApiResponse fileIdGetWithHttpInfo(String id, Map headers) throws ApiException { HttpRequest.Builder localVarRequestBuilder = fileIdGetRequestBuilder(id, headers); try { HttpResponse localVarResponse = memberVarHttpClient.send( @@ -217,20 +221,31 @@ public ApiResponse fileIdGetWithHttpInfo(String id, Map he throw getApiException("fileIdGet", localVarResponse); } localVarResponseBody = ApiClient.getResponseBody(localVarResponse); - if (localVarResponseBody != null) { - localVarResponseBody.readAllBytes(); + if (localVarResponseBody == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); } - return new ApiResponse<>( + + + + String responseBody = new String(localVarResponseBody.readAllBytes()); + FileContent responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}); + + + return new ApiResponse( localVarResponse.statusCode(), localVarResponse.headers().map(), - null + responseValue ); } finally { if (localVarResponseBody != null) { localVarResponseBody.close(); } } - } catch (IOException e) { + } catch (IOException | JacksonException e) { throw new ApiException(e); } catch (InterruptedException e) { diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..ded956fa8c44 --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java @@ -0,0 +1,289 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.Pair; + +import org.openapitools.client.model.RequiredAndNullable; + +import tools.jackson.core.JacksonException; +import tools.jackson.core.type.TypeReference; +import tools.jackson.databind.ObjectMapper; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullableApi { + /** + * Utility class for extending HttpRequest.Builder functionality. + */ + private static class HttpRequestBuilderExtensions { + /** + * Adds additional headers to the provided HttpRequest.Builder. Useful for adding method/endpoint specific headers. + * + * @param builder the HttpRequest.Builder to which headers will be added + * @param headers a map of header names and values to add; may be null + * @return the same HttpRequest.Builder instance with the additional headers set + */ + static HttpRequest.Builder withAdditionalHeaders(HttpRequest.Builder builder, Map headers) { + if (headers != null) { + for (Map.Entry entry : headers.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + } + return builder; + } + } + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public RequiredAndNullableApi() { + this(Configuration.getDefaultApiClient()); + } + + public RequiredAndNullableApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + InputStream responseBody = ApiClient.getResponseBody(response); + String body = null; + try { + body = responseBody == null ? null : new String(responseBody.readAllBytes()); + } finally { + if (responseBody != null) { + responseBody.close(); + } + } + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Download file from the given response. + * + * @param response Response + * @return File + * @throws ApiException If fail to read file content from response and write to disk + */ + public File downloadFileFromResponse(HttpResponse response, InputStream responseBody) throws ApiException { + if (responseBody == null) { + throw new ApiException(new IOException("Response body is empty")); + } + try { + File file = prepareDownloadFile(response); + java.nio.file.Files.copy(responseBody, file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + *

    Prepare the file for download from the response.

    + * + * @param response a {@link java.net.http.HttpResponse} object. + * @return a {@link java.io.File} object. + * @throws java.io.IOException if any. + */ + private File prepareDownloadFile(HttpResponse response) throws IOException { + String filename = null; + java.util.Optional contentDisposition = response.headers().firstValue("Content-Disposition"); + if (contentDisposition.isPresent() && !"".equals(contentDisposition.get())) { + // Get filename from the Content-Disposition header. + java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + java.util.regex.Matcher matcher = pattern.matcher(contentDisposition.get()); + if (matcher.find()) + filename = matcher.group(1); + } + File file = null; + if (filename != null) { + java.nio.file.Path tempDir = java.nio.file.Files.createTempDirectory("swagger-gen-native"); + java.nio.file.Path filePath = java.nio.file.Files.createFile(tempDir.resolve(filename)); + file = filePath.toFile(); + tempDir.toFile().deleteOnExit(); // best effort cleanup + file.deleteOnExit(); // best effort cleanup + } else { + file = java.nio.file.Files.createTempFile("download-", "").toFile(); + file.deleteOnExit(); // best effort cleanup + } + return file; + } + + /** + * + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return RequiredAndNullable + * @throws ApiException if fails to make API call + */ + public RequiredAndNullable requiredAndNullablePost(RequiredAndNullable requiredAndNullable) throws ApiException { + return requiredAndNullablePost(requiredAndNullable, null); + } + + /** + * + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @param headers Optional headers to include in the request + * @return RequiredAndNullable + * @throws ApiException if fails to make API call + */ + public RequiredAndNullable requiredAndNullablePost(RequiredAndNullable requiredAndNullable, Map headers) throws ApiException { + ApiResponse localVarResponse = requiredAndNullablePostWithHttpInfo(requiredAndNullable, headers); + return localVarResponse.getData(); + } + + /** + * + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return ApiResponse<RequiredAndNullable> + * @throws ApiException if fails to make API call + */ + public ApiResponse requiredAndNullablePostWithHttpInfo(RequiredAndNullable requiredAndNullable) throws ApiException { + return requiredAndNullablePostWithHttpInfo(requiredAndNullable, null); + } + + /** + * + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @param headers Optional headers to include in the request + * @return ApiResponse<RequiredAndNullable> + * @throws ApiException if fails to make API call + */ + public ApiResponse requiredAndNullablePostWithHttpInfo(RequiredAndNullable requiredAndNullable, Map headers) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = requiredAndNullablePostRequestBuilder(requiredAndNullable, headers); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + InputStream localVarResponseBody = null; + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("requiredAndNullablePost", localVarResponse); + } + localVarResponseBody = ApiClient.getResponseBody(localVarResponse); + if (localVarResponseBody == null) { + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + + + String responseBody = new String(localVarResponseBody.readAllBytes()); + RequiredAndNullable responseValue = responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference() {}); + + + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseValue + ); + } finally { + if (localVarResponseBody != null) { + localVarResponseBody.close(); + } + } + } catch (IOException | JacksonException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder requiredAndNullablePostRequestBuilder(RequiredAndNullable requiredAndNullable, Map headers) throws ApiException { + // verify the required parameter 'requiredAndNullable' is set + if (requiredAndNullable == null) { + throw new ApiException(400, "Missing the required parameter 'requiredAndNullable' when calling requiredAndNullablePost"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/requiredAndNullable"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(requiredAndNullable); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (JacksonException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + // Add custom headers if provided + localVarRequestBuilder = HttpRequestBuilderExtensions.withAdditionalHeaders(localVarRequestBuilder, headers); + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + +} diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java new file mode 100644 index 000000000000..adbcdd81a78a --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java @@ -0,0 +1,294 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * FileContent + */ +@JsonPropertyOrder({ + FileContent.JSON_PROPERTY_NAME, + FileContent.JSON_PROPERTY_SIZE, + FileContent.JSON_PROPERTY_VIRUS_SCAN +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + public static final String JSON_PROPERTY_NAME = "name"; + + private String name; + + public static final String JSON_PROPERTY_SIZE = "size"; + + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN(String.valueOf("clean")), + + DETECTED(String.valueOf("detected")); + + private String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_VIRUS_SCAN = "virusScan"; + + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + } + + @JsonCreator + public FileContent( + @JsonProperty(JSON_PROPERTY_NAME) String name, + @JsonProperty(JSON_PROPERTY_SIZE) Integer size, + @JsonProperty(JSON_PROPERTY_VIRUS_SCAN) VirusScanEnum virusScan + ) { + this(); + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + /** + * Get name + * @return name + */ + + @JsonProperty(value = JSON_PROPERTY_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + + + + /** + * Get size + * @return size + */ + + @JsonProperty(value = JSON_PROPERTY_SIZE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public @Nullable Integer getSize() { + return size; + } + + + + + /** + * Get virusScan + * @return virusScan + */ + + @JsonProperty(value = JSON_PROPERTY_VIRUS_SCAN, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + + + + /** + * Return true if this FileContent object is equal to o. + */ + @Override + public boolean equals(Object o) { + return EqualsBuilder.reflectionEquals(this, o, false, null, true); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sname%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getName())))); + } + + // add `size` to the URL query string + if (getSize() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%ssize%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getSize())))); + } + + // add `virusScan` to the URL query string + if (getVirusScan() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%svirusScan%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getVirusScan())))); + } + + return joiner.toString(); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + public FileContent.Builder name(String name) { + this.instance.name = name; + return this; + } + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size = size; + return this; + } + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan = virusScan; + return this; + } + + + /** + * returns a built FileContent instance. + * + * The builder is not reusable. + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + return new FileContent.Builder() + .name(getName()) + .size(getSize()) + .virusScan(getVirusScan()); + } + +} + diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java new file mode 100644 index 000000000000..53202eaf7653 --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java @@ -0,0 +1,372 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +import org.openapitools.client.ApiClient; +/** + * RequiredAndNullable + */ +@JsonPropertyOrder({ + RequiredAndNullable.JSON_PROPERTY_STR, + RequiredAndNullable.JSON_PROPERTY_FILE, + RequiredAndNullable.JSON_PROPERTY_COLOR, + RequiredAndNullable.JSON_PROPERTY_ONLY_REQUIRED, + RequiredAndNullable.JSON_PROPERTY_LIST +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + public static final String JSON_PROPERTY_STR = "str"; + + private @Nullable String str; + + public static final String JSON_PROPERTY_FILE = "file"; + + private @Nullable File _file; + + public static final String JSON_PROPERTY_COLOR = "color"; + + private @Nullable String color = "red"; + + public static final String JSON_PROPERTY_ONLY_REQUIRED = "onlyRequired"; + + private String onlyRequired; + + public static final String JSON_PROPERTY_LIST = "list"; + + private @Nullable List _list; + + public RequiredAndNullable() { + } + + public RequiredAndNullable str(@Nullable String str) { + this.str = str; + return this; + } + + /** + * Get str + * @return str + */ + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public @Nullable String getStr() { + return str; + } + + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStr(@Nullable String str) { + this.str = str; + } + + + public RequiredAndNullable _file(@Nullable File _file) { + this._file = _file; + return this; + } + + /** + * Get _file + * @return _file + */ + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public @Nullable File getFile() { + return _file; + } + + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFile(@Nullable File _file) { + this._file = _file; + } + + + public RequiredAndNullable color(@Nullable String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public @Nullable String getColor() { + return color; + } + + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setColor(@Nullable String color) { + this.color = color; + } + + + public RequiredAndNullable onlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getOnlyRequired() { + return onlyRequired; + } + + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + + public RequiredAndNullable _list(@Nullable List _list) { + this._list = _list; + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null) { + this._list = new ArrayList<>(); + } + this._list.add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public @Nullable List getList() { + return _list; + } + + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setList(@Nullable List _list) { + this._list = _list; + } + + + /** + * Return true if this RequiredAndNullable object is equal to o. + */ + @Override + public boolean equals(Object o) { + return EqualsBuilder.reflectionEquals(this, o, false, null, true); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `str` to the URL query string + if (getStr() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sstr%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getStr())))); + } + + // add `file` to the URL query string + if (getFile() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sfile%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getFile())))); + } + + // add `color` to the URL query string + if (getColor() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%scolor%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getColor())))); + } + + // add `onlyRequired` to the URL query string + if (getOnlyRequired() != null) { + joiner.add(String.format(java.util.Locale.ROOT, "%sonlyRequired%s=%s", prefix, suffix, ApiClient.urlEncode(ApiClient.valueToString(getOnlyRequired())))); + } + + // add `list` to the URL query string + if (getList() != null) { + for (int i = 0; i < getList().size(); i++) { + joiner.add(String.format(java.util.Locale.ROOT, "%slist%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format(java.util.Locale.ROOT, "%s%d%s", containerPrefix, i, containerSuffix), + ApiClient.urlEncode(ApiClient.valueToString(getList().get(i))))); + } + } + + return joiner.toString(); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str = str; + return this; + } + public RequiredAndNullable.Builder _file(@Nullable File _file) { + this.instance._file = _file; + return this; + } + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color = color; + return this; + } + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired = onlyRequired; + return this; + } + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list = _list; + return this; + } + + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable. + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + return new RequiredAndNullable.Builder() + .str(getStr()) + ._file(getFile()) + .color(getColor()) + .onlyRequired(getOnlyRequired()) + ._list(getList()); + } + +} + diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java b/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java new file mode 100644 index 000000000000..e978305a1590 --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java @@ -0,0 +1,54 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.ApiException; +import org.openapitools.client.model.RequiredAndNullable; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + + +/** + * API tests for RequiredAndNullableApi + */ +@Disabled +public class RequiredAndNullableApiTest { + + private final RequiredAndNullableApi api = new RequiredAndNullableApi(); + + + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void requiredAndNullablePostTest() throws ApiException { + RequiredAndNullable requiredAndNullable = null; + RequiredAndNullable response = + api.requiredAndNullablePost(requiredAndNullable); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java b/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java new file mode 100644 index 000000000000..eafa2e0aaa1d --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java @@ -0,0 +1,56 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FileContent + */ +class FileContentTest { + private final FileContent model = new FileContent(); + + /** + * Model tests for FileContent + */ + @Test + void testFileContent() { + // TODO: test FileContent + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'size' + */ + @Test + void sizeTest() { + // TODO: test size + } + +} diff --git a/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java b/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java new file mode 100644 index 000000000000..15c3a3b980b5 --- /dev/null +++ b/samples/client/petstore/java/native-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java @@ -0,0 +1,73 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import java.util.Arrays; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RequiredAndNullable + */ +class RequiredAndNullableTest { + private final RequiredAndNullable model = new RequiredAndNullable(); + + /** + * Model tests for RequiredAndNullable + */ + @Test + void testRequiredAndNullable() { + // TODO: test RequiredAndNullable + } + + /** + * Test the property 'str' + */ + @Test + void strTest() { + // TODO: test str + } + + /** + * Test the property '_file' + */ + @Test + void _fileTest() { + // TODO: test _file + } + + /** + * Test the property 'color' + */ + @Test + void colorTest() { + // TODO: test color + } + + /** + * Test the property 'onlyRequired' + */ + @Test + void onlyRequiredTest() { + // TODO: test onlyRequired + } + +} diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java index e7440e03ef92..6569aaded6ce 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java @@ -304,7 +304,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -348,7 +348,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -424,7 +424,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -468,7 +468,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/.openapi-generator/FILES b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/.openapi-generator/FILES index 905482ebbf2c..a9762735bc0b 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/.openapi-generator/FILES +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/.openapi-generator/FILES @@ -6,8 +6,11 @@ api/openapi.yaml build.gradle build.sbt docs/FileApi.md +docs/FileContent.md docs/Foo.md docs/FooApi.md +docs/RequiredAndNullable.md +docs/RequiredAndNullableApi.md docs/UploadApi.md git_push.sh gradle.properties @@ -27,12 +30,15 @@ src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java src/main/java/org/openapitools/client/api/FileApi.java src/main/java/org/openapitools/client/api/FooApi.java +src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java src/main/java/org/openapitools/client/api/UploadApi.java src/main/java/org/openapitools/client/api/package-info.java src/main/java/org/openapitools/client/auth/ApiKeyAuth.java src/main/java/org/openapitools/client/auth/Authentication.java src/main/java/org/openapitools/client/auth/HttpBasicAuth.java src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +src/main/java/org/openapitools/client/model/FileContent.java src/main/java/org/openapitools/client/model/Foo.java +src/main/java/org/openapitools/client/model/RequiredAndNullable.java src/main/java/org/openapitools/client/model/package-info.java src/main/java/org/openapitools/client/package-info.java diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/README.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/README.md index 4d406688dd86..c8dcc331bcce 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/README.md +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/README.md @@ -95,7 +95,8 @@ public class FileApiExample { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (HttpStatusCodeException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getStatusCode().value()); @@ -116,13 +117,16 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *FileApi* | [**fileIdGet**](docs/FileApi.md#fileIdGet) | **GET** /file/{id} | *FooApi* | [**fooDtParamGet**](docs/FooApi.md#fooDtParamGet) | **GET** /foo/{dtParam} | +*RequiredAndNullableApi* | [**requiredAndNullablePost**](docs/RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | *UploadApi* | [**uploadFilesPost**](docs/UploadApi.md#uploadFilesPost) | **POST** /uploadFiles | *UploadApi* | [**uploadPost**](docs/UploadApi.md#uploadPost) | **POST** /upload | ## Documentation for Models + - [FileContent](docs/FileContent.md) - [Foo](docs/Foo.md) + - [RequiredAndNullable](docs/RequiredAndNullable.md) diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/api/openapi.yaml b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/api/openapi.yaml index b5f967c8460e..15c1f4176a50 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/api/openapi.yaml +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/api/openapi.yaml @@ -6,6 +6,8 @@ info: servers: - url: / tags: +- description: requiredAndNullable + name: requiredAndNullable - description: foo name: foo - description: upload @@ -59,6 +61,27 @@ paths: - foo x-accepts: - application/json + /requiredAndNullable: + post: + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: bodyWithRequiredAndNullableAttributes + required: true + responses: + default: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: response + tags: + - requiredAndNullable + x-content-type: application/json + x-accepts: + - application/json /upload: post: requestBody: @@ -103,6 +126,10 @@ paths: style: simple responses: "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FileContent" description: ok tags: - file @@ -185,6 +212,62 @@ components: required: - requiredColor - requiredDt + RequiredAndNullable: + example: + str: str + file: "" + color: red + onlyRequired: onlyRequired + list: + - list + - list + properties: + str: + nullable: true + type: string + file: + format: binary + nullable: true + type: string + color: + default: red + nullable: true + type: string + onlyRequired: + type: string + list: + items: + type: string + nullable: true + type: array + required: + - color + - file + - list + - onlyRequired + - str + type: object + FileContent: + example: + name: name + size: 0 + virusScan: clean + properties: + name: + readOnly: true + type: string + size: + readOnly: true + type: integer + virusScan: + enum: + - clean + - detected + readOnly: true + type: string + required: + - name + type: object _upload_post_request: properties: file: diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileApi.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileApi.md index 4e6607ae5a71..59683371bc55 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileApi.md +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileApi.md @@ -10,7 +10,7 @@ All URIs are relative to *http://localhost* ## fileIdGet -> fileIdGet(id) +> FileContent fileIdGet(id) @@ -32,7 +32,8 @@ public class Example { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -53,7 +54,7 @@ public class Example { ### Return type -null (empty response body) +[**FileContent**](FileContent.md) ### Authorization @@ -62,7 +63,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileContent.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileContent.md new file mode 100644 index 000000000000..5b6654a0bf18 --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/FileContent.md @@ -0,0 +1,24 @@ + + +# FileContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [readonly] | +|**size** | **Integer** | | [optional] [readonly] | +|**virusScan** | [**VirusScanEnum**](#VirusScanEnum) | | [optional] [readonly] | + + + +## Enum: VirusScanEnum + +| Name | Value | +|---- | -----| +| CLEAN | "clean" | +| DETECTED | "detected" | + + + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullable.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullable.md new file mode 100644 index 000000000000..ff4ade0f226d --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullable.md @@ -0,0 +1,17 @@ + + +# RequiredAndNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**str** | **String** | | | +|**_file** | **File** | | | +|**color** | **String** | | | +|**onlyRequired** | **String** | | | +|**_list** | **List<String>** | | | + + + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullableApi.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullableApi.md new file mode 100644 index 000000000000..ada434bf0b9e --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/docs/RequiredAndNullableApi.md @@ -0,0 +1,73 @@ +# RequiredAndNullableApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**requiredAndNullablePost**](RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | | + + + +## requiredAndNullablePost + +> RequiredAndNullable requiredAndNullablePost(requiredAndNullable) + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.RequiredAndNullableApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + RequiredAndNullableApi apiInstance = new RequiredAndNullableApi(defaultClient); + RequiredAndNullable requiredAndNullable = new RequiredAndNullable(); // RequiredAndNullable | bodyWithRequiredAndNullableAttributes + try { + RequiredAndNullable result = apiInstance.requiredAndNullablePost(requiredAndNullable); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RequiredAndNullableApi#requiredAndNullablePost"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **requiredAndNullable** | [**RequiredAndNullable**](RequiredAndNullable.md)| bodyWithRequiredAndNullableAttributes | | + +### Return type + +[**RequiredAndNullable**](RequiredAndNullable.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/FileApi.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/FileApi.java index 4f1bf741d207..a391a80e7577 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/FileApi.java +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/FileApi.java @@ -2,6 +2,7 @@ import org.openapitools.client.ApiClient; +import org.openapitools.client.model.FileContent; import java.util.HashMap; import java.util.List; @@ -48,6 +49,7 @@ public void setApiClient(ApiClient apiClient) { * *

    200 - ok * @param id The id parameter + * @return FileContent * @throws RestClientResponseException if an error occurs while attempting to invoke the API */ private ResponseSpec fileIdGetRequestCreation(String id) throws RestClientResponseException { @@ -66,14 +68,16 @@ private ResponseSpec fileIdGetRequestCreation(String id) throws RestClientRespon final MultiValueMap cookieParams = new LinkedMultiValueMap<>(); final MultiValueMap formParams = new LinkedMultiValueMap<>(); - final String[] localVarAccepts = { }; + final String[] localVarAccepts = { + "application/json" + }; final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { }; - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; return apiClient.invokeAPI("/file/{id}", HttpMethod.GET, pathParams, localVarQueryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } @@ -82,11 +86,12 @@ private ResponseSpec fileIdGetRequestCreation(String id) throws RestClientRespon * *

    200 - ok * @param id The id parameter + * @return FileContent * @throws RestClientResponseException if an error occurs while attempting to invoke the API */ - public void fileIdGet(String id) throws RestClientResponseException { - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; - fileIdGetRequestCreation(id).body(localVarReturnType); + public FileContent fileIdGet(String id) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return fileIdGetRequestCreation(id).body(localVarReturnType); } /** @@ -94,10 +99,11 @@ public void fileIdGet(String id) throws RestClientResponseException { * *

    200 - ok * @param id The id parameter + * @return ResponseEntity<FileContent> * @throws RestClientResponseException if an error occurs while attempting to invoke the API */ - public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientResponseException { - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; return fileIdGetRequestCreation(id).toEntity(localVarReturnType); } diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..cc0e7c9ca9fa --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java @@ -0,0 +1,121 @@ +package org.openapitools.client.api; + +import org.openapitools.client.ApiClient; + +import org.openapitools.client.model.RequiredAndNullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClient.ResponseSpec; +import org.springframework.web.client.RestClientResponseException; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullableApi { + private ApiClient apiClient; + + public RequiredAndNullableApi() { + this(new ApiClient()); + } + + public RequiredAndNullableApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return RequiredAndNullable + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec requiredAndNullablePostRequestCreation(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + Object postBody = requiredAndNullable; + // verify the required parameter 'requiredAndNullable' is set + if (requiredAndNullable == null) { + throw new RestClientResponseException("Missing the required parameter 'requiredAndNullable' when calling requiredAndNullablePost", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap<>(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap<>(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap<>(); + final MultiValueMap formParams = new LinkedMultiValueMap<>(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return apiClient.invokeAPI("/requiredAndNullable", HttpMethod.POST, pathParams, localVarQueryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return RequiredAndNullable + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + public RequiredAndNullable requiredAndNullablePost(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return requiredAndNullablePostRequestCreation(requiredAndNullable).body(localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return ResponseEntity<RequiredAndNullable> + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseEntity requiredAndNullablePostWithHttpInfo(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return requiredAndNullablePostRequestCreation(requiredAndNullable).toEntity(localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return ResponseSpec + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec requiredAndNullablePostWithResponseSpec(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + return requiredAndNullablePostRequestCreation(requiredAndNullable); + } +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/FileContent.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/FileContent.java new file mode 100644 index 000000000000..b0f00682525b --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/FileContent.java @@ -0,0 +1,247 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * FileContent + */ +@JsonPropertyOrder({ + FileContent.JSON_PROPERTY_NAME, + FileContent.JSON_PROPERTY_SIZE, + FileContent.JSON_PROPERTY_VIRUS_SCAN +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + public static final String JSON_PROPERTY_NAME = "name"; + + private String name; + + public static final String JSON_PROPERTY_SIZE = "size"; + + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN(String.valueOf("clean")), + + DETECTED(String.valueOf("detected")); + + private String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_VIRUS_SCAN = "virusScan"; + + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + } + /** + * Constructor with only readonly parameters and all parameters + */ + @JsonCreator + public FileContent( + @JsonProperty(JSON_PROPERTY_NAME) String name, + @JsonProperty(JSON_PROPERTY_SIZE) Integer size, + @JsonProperty(JSON_PROPERTY_VIRUS_SCAN) VirusScanEnum virusScan + ) { + this(); + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + /** + * Get name + * @return name + */ + + @JsonProperty(value = JSON_PROPERTY_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getName() { + return name; + } + + + + /** + * Get size + * @return size + */ + + @JsonProperty(value = JSON_PROPERTY_SIZE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable Integer getSize() { + return size; + } + + + + /** + * Get virusScan + * @return virusScan + */ + + @JsonProperty(value = JSON_PROPERTY_VIRUS_SCAN, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + public FileContent.Builder name(String name) { + this.instance.name = name; + return this; + } + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size = size; + return this; + } + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan = virusScan; + return this; + } + + + /** + * returns a built FileContent instance. + * + * The builder is not reusable. + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + return new FileContent.Builder() + .name(getName()) + .size(getSize()) + .virusScan(getVirusScan()); + } + + +} + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/Foo.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/Foo.java index 3397bcbf9b49..e5cc9c951158 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/Foo.java +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/Foo.java @@ -317,7 +317,7 @@ public Foo nullableListMinIntems(@Nullable List nullableListM } public Foo addNullableListMinIntemsItem(java.time.Instant nullableListMinIntemsItem) { - if (this.nullableListMinIntems == null || !this.nullableListMinIntems.isPresent()) { + if (this.nullableListMinIntems == null || !this.nullableListMinIntems.isPresent() || this.nullableListMinIntems.get() == null) { this.nullableListMinIntems = JsonNullable.>of(new ArrayList<>()); } try { diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/RequiredAndNullable.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/RequiredAndNullable.java new file mode 100644 index 000000000000..55653e9e6161 --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/main/java/org/openapitools/client/model/RequiredAndNullable.java @@ -0,0 +1,328 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * RequiredAndNullable + */ +@JsonPropertyOrder({ + RequiredAndNullable.JSON_PROPERTY_STR, + RequiredAndNullable.JSON_PROPERTY_FILE, + RequiredAndNullable.JSON_PROPERTY_COLOR, + RequiredAndNullable.JSON_PROPERTY_ONLY_REQUIRED, + RequiredAndNullable.JSON_PROPERTY_LIST +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + public static final String JSON_PROPERTY_STR = "str"; + + private @Nullable String str; + + public static final String JSON_PROPERTY_FILE = "file"; + + private @Nullable File _file; + + public static final String JSON_PROPERTY_COLOR = "color"; + + private @Nullable String color = "red"; + + public static final String JSON_PROPERTY_ONLY_REQUIRED = "onlyRequired"; + + private String onlyRequired; + + public static final String JSON_PROPERTY_LIST = "list"; + + private @Nullable List _list; + + public RequiredAndNullable() { + } + + /** + * Constructor with all args parameters + */ + public RequiredAndNullable(@JsonProperty(JSON_PROPERTY_STR) @Nullable String str, @JsonProperty(JSON_PROPERTY_FILE) @Nullable File _file, @JsonProperty(JSON_PROPERTY_COLOR) @Nullable String color, @JsonProperty(JSON_PROPERTY_ONLY_REQUIRED) String onlyRequired, @JsonProperty(JSON_PROPERTY_LIST) @Nullable List _list) { + this.str = str; + this._file = _file; + this.color = color; + this.onlyRequired = onlyRequired; + this._list = _list; + } + + public RequiredAndNullable str(@Nullable String str) { + + this.str = str; + return this; + } + + /** + * Get str + * @return str + */ + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getStr() { + return str; + } + + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStr(@Nullable String str) { + this.str = str; + } + + public RequiredAndNullable _file(@Nullable File _file) { + + this._file = _file; + return this; + } + + /** + * Get _file + * @return _file + */ + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable File getFile() { + return _file; + } + + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFile(@Nullable File _file) { + this._file = _file; + } + + public RequiredAndNullable color(@Nullable String color) { + + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getColor() { + return color; + } + + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setColor(@Nullable String color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getOnlyRequired() { + return onlyRequired; + } + + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + + this._list = _list; + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null) { + this._list = new ArrayList<>(); + } + this._list.add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable List getList() { + return _list; + } + + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setList(@Nullable List _list) { + this._list = _list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this._file, requiredAndNullable._file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, _file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str = str; + return this; + } + public RequiredAndNullable.Builder _file(@Nullable File _file) { + this.instance._file = _file; + return this; + } + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color = color; + return this; + } + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired = onlyRequired; + return this; + } + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list = _list; + return this; + } + + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable. + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + return new RequiredAndNullable.Builder() + .str(getStr()) + ._file(getFile()) + .color(getColor()) + .onlyRequired(getOnlyRequired()) + ._list(getList()); + } + + +} + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java new file mode 100644 index 000000000000..41e971ae1aa5 --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java @@ -0,0 +1,48 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.model.RequiredAndNullable; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * API tests for RequiredAndNullableApi + */ +@Disabled +public class RequiredAndNullableApiTest { + + private final RequiredAndNullableApi api = new RequiredAndNullableApi(); + + + /** + * + * + * + */ + @Test + public void requiredAndNullablePostTest() { + RequiredAndNullable requiredAndNullable = null; + RequiredAndNullable response = api.requiredAndNullablePost(requiredAndNullable); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/FileContentTest.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/FileContentTest.java new file mode 100644 index 000000000000..bc686732b1ca --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/FileContentTest.java @@ -0,0 +1,55 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FileContent + */ +class FileContentTest { + private final FileContent model = new FileContent(); + + /** + * Model tests for FileContent + */ + @Test + void testFileContent() { + // TODO: test FileContent + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'size' + */ + @Test + void sizeTest() { + // TODO: test size + } + +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java new file mode 100644 index 000000000000..3d3388460faf --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify-openapiNullable/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java @@ -0,0 +1,72 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RequiredAndNullable + */ +class RequiredAndNullableTest { + private final RequiredAndNullable model = new RequiredAndNullable(); + + /** + * Model tests for RequiredAndNullable + */ + @Test + void testRequiredAndNullable() { + // TODO: test RequiredAndNullable + } + + /** + * Test the property 'str' + */ + @Test + void strTest() { + // TODO: test str + } + + /** + * Test the property '_file' + */ + @Test + void _fileTest() { + // TODO: test _file + } + + /** + * Test the property 'color' + */ + @Test + void colorTest() { + // TODO: test color + } + + /** + * Test the property 'onlyRequired' + */ + @Test + void onlyRequiredTest() { + // TODO: test onlyRequired + } + +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES index 905482ebbf2c..a9762735bc0b 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES @@ -6,8 +6,11 @@ api/openapi.yaml build.gradle build.sbt docs/FileApi.md +docs/FileContent.md docs/Foo.md docs/FooApi.md +docs/RequiredAndNullable.md +docs/RequiredAndNullableApi.md docs/UploadApi.md git_push.sh gradle.properties @@ -27,12 +30,15 @@ src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java src/main/java/org/openapitools/client/api/FileApi.java src/main/java/org/openapitools/client/api/FooApi.java +src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java src/main/java/org/openapitools/client/api/UploadApi.java src/main/java/org/openapitools/client/api/package-info.java src/main/java/org/openapitools/client/auth/ApiKeyAuth.java src/main/java/org/openapitools/client/auth/Authentication.java src/main/java/org/openapitools/client/auth/HttpBasicAuth.java src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +src/main/java/org/openapitools/client/model/FileContent.java src/main/java/org/openapitools/client/model/Foo.java +src/main/java/org/openapitools/client/model/RequiredAndNullable.java src/main/java/org/openapitools/client/model/package-info.java src/main/java/org/openapitools/client/package-info.java diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/README.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/README.md index 4d406688dd86..c8dcc331bcce 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/README.md +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/README.md @@ -95,7 +95,8 @@ public class FileApiExample { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (HttpStatusCodeException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getStatusCode().value()); @@ -116,13 +117,16 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *FileApi* | [**fileIdGet**](docs/FileApi.md#fileIdGet) | **GET** /file/{id} | *FooApi* | [**fooDtParamGet**](docs/FooApi.md#fooDtParamGet) | **GET** /foo/{dtParam} | +*RequiredAndNullableApi* | [**requiredAndNullablePost**](docs/RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | *UploadApi* | [**uploadFilesPost**](docs/UploadApi.md#uploadFilesPost) | **POST** /uploadFiles | *UploadApi* | [**uploadPost**](docs/UploadApi.md#uploadPost) | **POST** /upload | ## Documentation for Models + - [FileContent](docs/FileContent.md) - [Foo](docs/Foo.md) + - [RequiredAndNullable](docs/RequiredAndNullable.md) diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/api/openapi.yaml b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/api/openapi.yaml index b5f967c8460e..15c1f4176a50 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/api/openapi.yaml +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/api/openapi.yaml @@ -6,6 +6,8 @@ info: servers: - url: / tags: +- description: requiredAndNullable + name: requiredAndNullable - description: foo name: foo - description: upload @@ -59,6 +61,27 @@ paths: - foo x-accepts: - application/json + /requiredAndNullable: + post: + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: bodyWithRequiredAndNullableAttributes + required: true + responses: + default: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: response + tags: + - requiredAndNullable + x-content-type: application/json + x-accepts: + - application/json /upload: post: requestBody: @@ -103,6 +126,10 @@ paths: style: simple responses: "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FileContent" description: ok tags: - file @@ -185,6 +212,62 @@ components: required: - requiredColor - requiredDt + RequiredAndNullable: + example: + str: str + file: "" + color: red + onlyRequired: onlyRequired + list: + - list + - list + properties: + str: + nullable: true + type: string + file: + format: binary + nullable: true + type: string + color: + default: red + nullable: true + type: string + onlyRequired: + type: string + list: + items: + type: string + nullable: true + type: array + required: + - color + - file + - list + - onlyRequired + - str + type: object + FileContent: + example: + name: name + size: 0 + virusScan: clean + properties: + name: + readOnly: true + type: string + size: + readOnly: true + type: integer + virusScan: + enum: + - clean + - detected + readOnly: true + type: string + required: + - name + type: object _upload_post_request: properties: file: diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileApi.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileApi.md index 4e6607ae5a71..59683371bc55 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileApi.md +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileApi.md @@ -10,7 +10,7 @@ All URIs are relative to *http://localhost* ## fileIdGet -> fileIdGet(id) +> FileContent fileIdGet(id) @@ -32,7 +32,8 @@ public class Example { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -53,7 +54,7 @@ public class Example { ### Return type -null (empty response body) +[**FileContent**](FileContent.md) ### Authorization @@ -62,7 +63,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileContent.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileContent.md new file mode 100644 index 000000000000..5b6654a0bf18 --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/FileContent.md @@ -0,0 +1,24 @@ + + +# FileContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [readonly] | +|**size** | **Integer** | | [optional] [readonly] | +|**virusScan** | [**VirusScanEnum**](#VirusScanEnum) | | [optional] [readonly] | + + + +## Enum: VirusScanEnum + +| Name | Value | +|---- | -----| +| CLEAN | "clean" | +| DETECTED | "detected" | + + + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md new file mode 100644 index 000000000000..ff4ade0f226d --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md @@ -0,0 +1,17 @@ + + +# RequiredAndNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**str** | **String** | | | +|**_file** | **File** | | | +|**color** | **String** | | | +|**onlyRequired** | **String** | | | +|**_list** | **List<String>** | | | + + + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md new file mode 100644 index 000000000000..ada434bf0b9e --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md @@ -0,0 +1,73 @@ +# RequiredAndNullableApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**requiredAndNullablePost**](RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | | + + + +## requiredAndNullablePost + +> RequiredAndNullable requiredAndNullablePost(requiredAndNullable) + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.RequiredAndNullableApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + RequiredAndNullableApi apiInstance = new RequiredAndNullableApi(defaultClient); + RequiredAndNullable requiredAndNullable = new RequiredAndNullable(); // RequiredAndNullable | bodyWithRequiredAndNullableAttributes + try { + RequiredAndNullable result = apiInstance.requiredAndNullablePost(requiredAndNullable); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RequiredAndNullableApi#requiredAndNullablePost"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **requiredAndNullable** | [**RequiredAndNullable**](RequiredAndNullable.md)| bodyWithRequiredAndNullableAttributes | | + +### Return type + +[**RequiredAndNullable**](RequiredAndNullable.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java index 4f1bf741d207..a391a80e7577 100644 --- a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java @@ -2,6 +2,7 @@ import org.openapitools.client.ApiClient; +import org.openapitools.client.model.FileContent; import java.util.HashMap; import java.util.List; @@ -48,6 +49,7 @@ public void setApiClient(ApiClient apiClient) { * *

    200 - ok * @param id The id parameter + * @return FileContent * @throws RestClientResponseException if an error occurs while attempting to invoke the API */ private ResponseSpec fileIdGetRequestCreation(String id) throws RestClientResponseException { @@ -66,14 +68,16 @@ private ResponseSpec fileIdGetRequestCreation(String id) throws RestClientRespon final MultiValueMap cookieParams = new LinkedMultiValueMap<>(); final MultiValueMap formParams = new LinkedMultiValueMap<>(); - final String[] localVarAccepts = { }; + final String[] localVarAccepts = { + "application/json" + }; final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { }; - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; return apiClient.invokeAPI("/file/{id}", HttpMethod.GET, pathParams, localVarQueryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } @@ -82,11 +86,12 @@ private ResponseSpec fileIdGetRequestCreation(String id) throws RestClientRespon * *

    200 - ok * @param id The id parameter + * @return FileContent * @throws RestClientResponseException if an error occurs while attempting to invoke the API */ - public void fileIdGet(String id) throws RestClientResponseException { - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; - fileIdGetRequestCreation(id).body(localVarReturnType); + public FileContent fileIdGet(String id) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return fileIdGetRequestCreation(id).body(localVarReturnType); } /** @@ -94,10 +99,11 @@ public void fileIdGet(String id) throws RestClientResponseException { * *

    200 - ok * @param id The id parameter + * @return ResponseEntity<FileContent> * @throws RestClientResponseException if an error occurs while attempting to invoke the API */ - public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientResponseException { - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; return fileIdGetRequestCreation(id).toEntity(localVarReturnType); } diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..cc0e7c9ca9fa --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java @@ -0,0 +1,121 @@ +package org.openapitools.client.api; + +import org.openapitools.client.ApiClient; + +import org.openapitools.client.model.RequiredAndNullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClient.ResponseSpec; +import org.springframework.web.client.RestClientResponseException; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullableApi { + private ApiClient apiClient; + + public RequiredAndNullableApi() { + this(new ApiClient()); + } + + public RequiredAndNullableApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return RequiredAndNullable + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec requiredAndNullablePostRequestCreation(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + Object postBody = requiredAndNullable; + // verify the required parameter 'requiredAndNullable' is set + if (requiredAndNullable == null) { + throw new RestClientResponseException("Missing the required parameter 'requiredAndNullable' when calling requiredAndNullablePost", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap<>(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap<>(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap<>(); + final MultiValueMap formParams = new LinkedMultiValueMap<>(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return apiClient.invokeAPI("/requiredAndNullable", HttpMethod.POST, pathParams, localVarQueryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return RequiredAndNullable + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + public RequiredAndNullable requiredAndNullablePost(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return requiredAndNullablePostRequestCreation(requiredAndNullable).body(localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return ResponseEntity<RequiredAndNullable> + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseEntity requiredAndNullablePostWithHttpInfo(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {}; + return requiredAndNullablePostRequestCreation(requiredAndNullable).toEntity(localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return ResponseSpec + * @throws RestClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec requiredAndNullablePostWithResponseSpec(RequiredAndNullable requiredAndNullable) throws RestClientResponseException { + return requiredAndNullablePostRequestCreation(requiredAndNullable); + } +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java new file mode 100644 index 000000000000..b0f00682525b --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java @@ -0,0 +1,247 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * FileContent + */ +@JsonPropertyOrder({ + FileContent.JSON_PROPERTY_NAME, + FileContent.JSON_PROPERTY_SIZE, + FileContent.JSON_PROPERTY_VIRUS_SCAN +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + public static final String JSON_PROPERTY_NAME = "name"; + + private String name; + + public static final String JSON_PROPERTY_SIZE = "size"; + + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN(String.valueOf("clean")), + + DETECTED(String.valueOf("detected")); + + private String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_VIRUS_SCAN = "virusScan"; + + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + } + /** + * Constructor with only readonly parameters and all parameters + */ + @JsonCreator + public FileContent( + @JsonProperty(JSON_PROPERTY_NAME) String name, + @JsonProperty(JSON_PROPERTY_SIZE) Integer size, + @JsonProperty(JSON_PROPERTY_VIRUS_SCAN) VirusScanEnum virusScan + ) { + this(); + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + /** + * Get name + * @return name + */ + + @JsonProperty(value = JSON_PROPERTY_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getName() { + return name; + } + + + + /** + * Get size + * @return size + */ + + @JsonProperty(value = JSON_PROPERTY_SIZE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable Integer getSize() { + return size; + } + + + + /** + * Get virusScan + * @return virusScan + */ + + @JsonProperty(value = JSON_PROPERTY_VIRUS_SCAN, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + public FileContent.Builder name(String name) { + this.instance.name = name; + return this; + } + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size = size; + return this; + } + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan = virusScan; + return this; + } + + + /** + * returns a built FileContent instance. + * + * The builder is not reusable. + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + return new FileContent.Builder() + .name(getName()) + .size(getSize()) + .virusScan(getVirusScan()); + } + + +} + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java new file mode 100644 index 000000000000..55653e9e6161 --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java @@ -0,0 +1,328 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * RequiredAndNullable + */ +@JsonPropertyOrder({ + RequiredAndNullable.JSON_PROPERTY_STR, + RequiredAndNullable.JSON_PROPERTY_FILE, + RequiredAndNullable.JSON_PROPERTY_COLOR, + RequiredAndNullable.JSON_PROPERTY_ONLY_REQUIRED, + RequiredAndNullable.JSON_PROPERTY_LIST +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + public static final String JSON_PROPERTY_STR = "str"; + + private @Nullable String str; + + public static final String JSON_PROPERTY_FILE = "file"; + + private @Nullable File _file; + + public static final String JSON_PROPERTY_COLOR = "color"; + + private @Nullable String color = "red"; + + public static final String JSON_PROPERTY_ONLY_REQUIRED = "onlyRequired"; + + private String onlyRequired; + + public static final String JSON_PROPERTY_LIST = "list"; + + private @Nullable List _list; + + public RequiredAndNullable() { + } + + /** + * Constructor with all args parameters + */ + public RequiredAndNullable(@JsonProperty(JSON_PROPERTY_STR) @Nullable String str, @JsonProperty(JSON_PROPERTY_FILE) @Nullable File _file, @JsonProperty(JSON_PROPERTY_COLOR) @Nullable String color, @JsonProperty(JSON_PROPERTY_ONLY_REQUIRED) String onlyRequired, @JsonProperty(JSON_PROPERTY_LIST) @Nullable List _list) { + this.str = str; + this._file = _file; + this.color = color; + this.onlyRequired = onlyRequired; + this._list = _list; + } + + public RequiredAndNullable str(@Nullable String str) { + + this.str = str; + return this; + } + + /** + * Get str + * @return str + */ + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getStr() { + return str; + } + + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStr(@Nullable String str) { + this.str = str; + } + + public RequiredAndNullable _file(@Nullable File _file) { + + this._file = _file; + return this; + } + + /** + * Get _file + * @return _file + */ + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable File getFile() { + return _file; + } + + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFile(@Nullable File _file) { + this._file = _file; + } + + public RequiredAndNullable color(@Nullable String color) { + + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getColor() { + return color; + } + + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setColor(@Nullable String color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getOnlyRequired() { + return onlyRequired; + } + + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + + this._list = _list; + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null) { + this._list = new ArrayList<>(); + } + this._list.add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable List getList() { + return _list; + } + + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setList(@Nullable List _list) { + this._list = _list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this._file, requiredAndNullable._file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, _file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str = str; + return this; + } + public RequiredAndNullable.Builder _file(@Nullable File _file) { + this.instance._file = _file; + return this; + } + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color = color; + return this; + } + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired = onlyRequired; + return this; + } + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list = _list; + return this; + } + + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable. + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + return new RequiredAndNullable.Builder() + .str(getStr()) + ._file(getFile()) + .color(getColor()) + .onlyRequired(getOnlyRequired()) + ._list(getList()); + } + + +} + diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java new file mode 100644 index 000000000000..41e971ae1aa5 --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java @@ -0,0 +1,48 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.model.RequiredAndNullable; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * API tests for RequiredAndNullableApi + */ +@Disabled +public class RequiredAndNullableApiTest { + + private final RequiredAndNullableApi api = new RequiredAndNullableApi(); + + + /** + * + * + * + */ + @Test + public void requiredAndNullablePostTest() { + RequiredAndNullable requiredAndNullable = null; + RequiredAndNullable response = api.requiredAndNullablePost(requiredAndNullable); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java new file mode 100644 index 000000000000..bc686732b1ca --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java @@ -0,0 +1,55 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FileContent + */ +class FileContentTest { + private final FileContent model = new FileContent(); + + /** + * Model tests for FileContent + */ + @Test + void testFileContent() { + // TODO: test FileContent + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'size' + */ + @Test + void sizeTest() { + // TODO: test size + } + +} diff --git a/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java new file mode 100644 index 000000000000..3d3388460faf --- /dev/null +++ b/samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java @@ -0,0 +1,72 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RequiredAndNullable + */ +class RequiredAndNullableTest { + private final RequiredAndNullable model = new RequiredAndNullable(); + + /** + * Model tests for RequiredAndNullable + */ + @Test + void testRequiredAndNullable() { + // TODO: test RequiredAndNullable + } + + /** + * Test the property 'str' + */ + @Test + void strTest() { + // TODO: test str + } + + /** + * Test the property '_file' + */ + @Test + void _fileTest() { + // TODO: test _file + } + + /** + * Test the property 'color' + */ + @Test + void colorTest() { + // TODO: test color + } + + /** + * Test the property 'onlyRequired' + */ + @Test + void onlyRequiredTest() { + // TODO: test onlyRequired + } + +} diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java index d6cab3c6d44e..8dbec199a934 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -343,7 +343,7 @@ public EnumTest outerEnum(@jakarta.annotation.Nullable OuterEnum outerEnum) { * @return outerEnum */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public OuterEnum getOuterEnum() { diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java index acaacf9f1ed4..8aee3efd00bc 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java @@ -56,7 +56,7 @@ public HealthCheckResult nullableMessage(@jakarta.annotation.Nullable String nul * @return nullableMessage */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public String getNullableMessage() { diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java index fc29bdb28d6c..0d4c5fb23fde 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java @@ -122,7 +122,7 @@ public NullableClass integerProp(@jakarta.annotation.Nullable Integer integerPro * @return integerProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Integer getIntegerProp() { @@ -156,7 +156,7 @@ public NullableClass numberProp(@jakarta.annotation.Nullable BigDecimal numberPr * @return numberProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public BigDecimal getNumberProp() { @@ -190,7 +190,7 @@ public NullableClass booleanProp(@jakarta.annotation.Nullable Boolean booleanPro * @return booleanProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Boolean getBooleanProp() { @@ -224,7 +224,7 @@ public NullableClass stringProp(@jakarta.annotation.Nullable String stringProp) * @return stringProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public String getStringProp() { @@ -258,7 +258,7 @@ public NullableClass dateProp(@jakarta.annotation.Nullable LocalDate dateProp) { * @return dateProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public LocalDate getDateProp() { @@ -292,7 +292,7 @@ public NullableClass datetimeProp(@jakarta.annotation.Nullable OffsetDateTime da * @return datetimeProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public OffsetDateTime getDatetimeProp() { @@ -322,7 +322,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -338,7 +338,7 @@ public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { * @return arrayNullableProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public List getArrayNullableProp() { @@ -368,7 +368,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -384,7 +384,7 @@ public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullab * @return arrayAndItemsNullableProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public List getArrayAndItemsNullableProp() { @@ -448,7 +448,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -464,7 +464,7 @@ public NullableClass putObjectNullablePropItem(String key, Object objectNullable * @return objectNullableProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Map getObjectNullableProp() { @@ -494,7 +494,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { @@ -510,7 +510,7 @@ public NullableClass putObjectAndItemsNullablePropItem(String key, Object object * @return objectAndItemsNullableProp */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Map getObjectAndItemsNullableProp() { diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java index 504c9fe527a1..cca6f0b72f88 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -131,7 +131,7 @@ public ParentWithNullable nullableProperty(@jakarta.annotation.Nullable String n * @return nullableProperty */ @jakarta.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public String getNullableProperty() { diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/model/NullableClass.java index 8e50413b1253..bcb4cde1aa7b 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter-static/src/main/java/org/openapitools/client/model/NullableClass.java @@ -315,7 +315,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -360,7 +360,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -438,7 +438,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -483,7 +483,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java index 8e50413b1253..bcb4cde1aa7b 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java @@ -315,7 +315,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -360,7 +360,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -438,7 +438,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -483,7 +483,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/NullableClass.java index 46625c62e002..0b54c6d0fcf5 100644 --- a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/NullableClass.java @@ -315,7 +315,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -360,7 +360,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -438,7 +438,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -483,7 +483,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/NullableClass.java index c84494a9487a..e8a4f5eb3b28 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/NullableClass.java @@ -317,7 +317,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -362,7 +362,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -440,7 +440,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -485,7 +485,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/.openapi-generator/FILES index 530107e2c6dc..61311fa8a555 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/.openapi-generator/FILES @@ -6,8 +6,11 @@ api/openapi.yaml build.gradle build.sbt docs/FileApi.md +docs/FileContent.md docs/Foo.md docs/FooApi.md +docs/RequiredAndNullable.md +docs/RequiredAndNullableApi.md docs/UploadApi.md git_push.sh gradle.properties @@ -28,12 +31,15 @@ src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/FileApi.java src/main/java/org/openapitools/client/api/FooApi.java +src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java src/main/java/org/openapitools/client/api/UploadApi.java src/main/java/org/openapitools/client/api/package-info.java src/main/java/org/openapitools/client/auth/ApiKeyAuth.java src/main/java/org/openapitools/client/auth/Authentication.java src/main/java/org/openapitools/client/auth/HttpBasicAuth.java src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +src/main/java/org/openapitools/client/model/FileContent.java src/main/java/org/openapitools/client/model/Foo.java +src/main/java/org/openapitools/client/model/RequiredAndNullable.java src/main/java/org/openapitools/client/model/package-info.java src/main/java/org/openapitools/client/package-info.java diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/README.md b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/README.md index 26aaed664ac5..cc1feadaafbf 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/README.md +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/README.md @@ -95,7 +95,8 @@ public class FileApiExample { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -116,13 +117,16 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *FileApi* | [**fileIdGet**](docs/FileApi.md#fileIdGet) | **GET** /file/{id} | *FooApi* | [**fooDtParamGet**](docs/FooApi.md#fooDtParamGet) | **GET** /foo/{dtParam} | +*RequiredAndNullableApi* | [**requiredAndNullablePost**](docs/RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | *UploadApi* | [**uploadFilesPost**](docs/UploadApi.md#uploadFilesPost) | **POST** /uploadFiles | *UploadApi* | [**uploadPost**](docs/UploadApi.md#uploadPost) | **POST** /upload | ## Documentation for Models + - [FileContent](docs/FileContent.md) - [Foo](docs/Foo.md) + - [RequiredAndNullable](docs/RequiredAndNullable.md) diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/api/openapi.yaml b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/api/openapi.yaml index b5f967c8460e..15c1f4176a50 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/api/openapi.yaml +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/api/openapi.yaml @@ -6,6 +6,8 @@ info: servers: - url: / tags: +- description: requiredAndNullable + name: requiredAndNullable - description: foo name: foo - description: upload @@ -59,6 +61,27 @@ paths: - foo x-accepts: - application/json + /requiredAndNullable: + post: + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: bodyWithRequiredAndNullableAttributes + required: true + responses: + default: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: response + tags: + - requiredAndNullable + x-content-type: application/json + x-accepts: + - application/json /upload: post: requestBody: @@ -103,6 +126,10 @@ paths: style: simple responses: "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FileContent" description: ok tags: - file @@ -185,6 +212,62 @@ components: required: - requiredColor - requiredDt + RequiredAndNullable: + example: + str: str + file: "" + color: red + onlyRequired: onlyRequired + list: + - list + - list + properties: + str: + nullable: true + type: string + file: + format: binary + nullable: true + type: string + color: + default: red + nullable: true + type: string + onlyRequired: + type: string + list: + items: + type: string + nullable: true + type: array + required: + - color + - file + - list + - onlyRequired + - str + type: object + FileContent: + example: + name: name + size: 0 + virusScan: clean + properties: + name: + readOnly: true + type: string + size: + readOnly: true + type: integer + virusScan: + enum: + - clean + - detected + readOnly: true + type: string + required: + - name + type: object _upload_post_request: properties: file: diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileApi.md b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileApi.md index 4e6607ae5a71..59683371bc55 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileApi.md +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileApi.md @@ -10,7 +10,7 @@ All URIs are relative to *http://localhost* ## fileIdGet -> fileIdGet(id) +> FileContent fileIdGet(id) @@ -32,7 +32,8 @@ public class Example { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -53,7 +54,7 @@ public class Example { ### Return type -null (empty response body) +[**FileContent**](FileContent.md) ### Authorization @@ -62,7 +63,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileContent.md b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileContent.md new file mode 100644 index 000000000000..5b6654a0bf18 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/FileContent.md @@ -0,0 +1,24 @@ + + +# FileContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [readonly] | +|**size** | **Integer** | | [optional] [readonly] | +|**virusScan** | [**VirusScanEnum**](#VirusScanEnum) | | [optional] [readonly] | + + + +## Enum: VirusScanEnum + +| Name | Value | +|---- | -----| +| CLEAN | "clean" | +| DETECTED | "detected" | + + + diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md new file mode 100644 index 000000000000..ff4ade0f226d --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md @@ -0,0 +1,17 @@ + + +# RequiredAndNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**str** | **String** | | | +|**_file** | **File** | | | +|**color** | **String** | | | +|**onlyRequired** | **String** | | | +|**_list** | **List<String>** | | | + + + diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md new file mode 100644 index 000000000000..ada434bf0b9e --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md @@ -0,0 +1,73 @@ +# RequiredAndNullableApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**requiredAndNullablePost**](RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | | + + + +## requiredAndNullablePost + +> RequiredAndNullable requiredAndNullablePost(requiredAndNullable) + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.RequiredAndNullableApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + RequiredAndNullableApi apiInstance = new RequiredAndNullableApi(defaultClient); + RequiredAndNullable requiredAndNullable = new RequiredAndNullable(); // RequiredAndNullable | bodyWithRequiredAndNullableAttributes + try { + RequiredAndNullable result = apiInstance.requiredAndNullablePost(requiredAndNullable); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RequiredAndNullableApi#requiredAndNullablePost"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **requiredAndNullable** | [**RequiredAndNullable**](RequiredAndNullable.md)| bodyWithRequiredAndNullableAttributes | | + +### Return type + +[**RequiredAndNullable**](RequiredAndNullable.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java index e9d287276f56..56c01021fec5 100644 --- a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import org.openapitools.client.BaseApi; +import org.openapitools.client.model.FileContent; import java.util.Collections; import java.util.HashMap; @@ -41,10 +42,11 @@ public FileApi(ApiClient apiClient) { * *

    200 - ok * @param id (required) + * @return FileContent * @throws RestClientException if an error occurs while attempting to invoke the API */ - public void fileIdGet(String id) throws RestClientException { - fileIdGetWithHttpInfo(id); + public FileContent fileIdGet(String id) throws RestClientException { + return fileIdGetWithHttpInfo(id).getBody(); } /** @@ -52,10 +54,10 @@ public void fileIdGet(String id) throws RestClientException { * *

    200 - ok * @param id (required) - * @return ResponseEntity<Void> + * @return ResponseEntity<FileContent> * @throws RestClientException if an error occurs while attempting to invoke the API */ - public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientException { + public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientException { Object localVarPostBody = null; // verify the required parameter 'id' is set @@ -72,14 +74,16 @@ public ResponseEntity fileIdGetWithHttpInfo(String id) throws RestClientEx final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); - final String[] localVarAccepts = { }; + final String[] localVarAccepts = { + "application/json" + }; final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { }; - ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; + ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/file/{id}", HttpMethod.GET, uriVariables, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); } @@ -94,7 +98,9 @@ public ResponseEntity invokeAPI(String url, HttpMethod method, Object req final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); - final String[] localVarAccepts = { }; + final String[] localVarAccepts = { + "application/json" + }; final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..7778cdd5c5aa --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java @@ -0,0 +1,113 @@ +package org.openapitools.client.api; + +import org.openapitools.client.ApiClient; +import org.openapitools.client.BaseApi; + +import org.openapitools.client.model.RequiredAndNullable; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullableApi extends BaseApi { + + public RequiredAndNullableApi() { + super(new ApiClient()); + } + + public RequiredAndNullableApi(ApiClient apiClient) { + super(apiClient); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return RequiredAndNullable + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public RequiredAndNullable requiredAndNullablePost(RequiredAndNullable requiredAndNullable) throws RestClientException { + return requiredAndNullablePostWithHttpInfo(requiredAndNullable).getBody(); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return ResponseEntity<RequiredAndNullable> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity requiredAndNullablePostWithHttpInfo(RequiredAndNullable requiredAndNullable) throws RestClientException { + Object localVarPostBody = requiredAndNullable; + + // verify the required parameter 'requiredAndNullable' is set + if (requiredAndNullable == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'requiredAndNullable' when calling requiredAndNullablePost"); + } + + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/requiredAndNullable", HttpMethod.POST, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); + } + + @Override + public ResponseEntity invokeAPI(String url, HttpMethod method, Object request, ParameterizedTypeReference returnType) throws RestClientException { + String localVarPath = url.replace(apiClient.getBasePath(), ""); + Object localVarPostBody = request; + + final Map uriVariables = new HashMap(); + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + return apiClient.invokeAPI(localVarPath, method, uriVariables, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, returnType); + } +} diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java new file mode 100644 index 000000000000..b0f00682525b --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java @@ -0,0 +1,247 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * FileContent + */ +@JsonPropertyOrder({ + FileContent.JSON_PROPERTY_NAME, + FileContent.JSON_PROPERTY_SIZE, + FileContent.JSON_PROPERTY_VIRUS_SCAN +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + public static final String JSON_PROPERTY_NAME = "name"; + + private String name; + + public static final String JSON_PROPERTY_SIZE = "size"; + + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN(String.valueOf("clean")), + + DETECTED(String.valueOf("detected")); + + private String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_VIRUS_SCAN = "virusScan"; + + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + } + /** + * Constructor with only readonly parameters and all parameters + */ + @JsonCreator + public FileContent( + @JsonProperty(JSON_PROPERTY_NAME) String name, + @JsonProperty(JSON_PROPERTY_SIZE) Integer size, + @JsonProperty(JSON_PROPERTY_VIRUS_SCAN) VirusScanEnum virusScan + ) { + this(); + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + /** + * Get name + * @return name + */ + + @JsonProperty(value = JSON_PROPERTY_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getName() { + return name; + } + + + + /** + * Get size + * @return size + */ + + @JsonProperty(value = JSON_PROPERTY_SIZE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable Integer getSize() { + return size; + } + + + + /** + * Get virusScan + * @return virusScan + */ + + @JsonProperty(value = JSON_PROPERTY_VIRUS_SCAN, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + public FileContent.Builder name(String name) { + this.instance.name = name; + return this; + } + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size = size; + return this; + } + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan = virusScan; + return this; + } + + + /** + * returns a built FileContent instance. + * + * The builder is not reusable. + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + return new FileContent.Builder() + .name(getName()) + .size(getSize()) + .virusScan(getVirusScan()); + } + + +} + diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java new file mode 100644 index 000000000000..55653e9e6161 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java @@ -0,0 +1,328 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * RequiredAndNullable + */ +@JsonPropertyOrder({ + RequiredAndNullable.JSON_PROPERTY_STR, + RequiredAndNullable.JSON_PROPERTY_FILE, + RequiredAndNullable.JSON_PROPERTY_COLOR, + RequiredAndNullable.JSON_PROPERTY_ONLY_REQUIRED, + RequiredAndNullable.JSON_PROPERTY_LIST +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + public static final String JSON_PROPERTY_STR = "str"; + + private @Nullable String str; + + public static final String JSON_PROPERTY_FILE = "file"; + + private @Nullable File _file; + + public static final String JSON_PROPERTY_COLOR = "color"; + + private @Nullable String color = "red"; + + public static final String JSON_PROPERTY_ONLY_REQUIRED = "onlyRequired"; + + private String onlyRequired; + + public static final String JSON_PROPERTY_LIST = "list"; + + private @Nullable List _list; + + public RequiredAndNullable() { + } + + /** + * Constructor with all args parameters + */ + public RequiredAndNullable(@JsonProperty(JSON_PROPERTY_STR) @Nullable String str, @JsonProperty(JSON_PROPERTY_FILE) @Nullable File _file, @JsonProperty(JSON_PROPERTY_COLOR) @Nullable String color, @JsonProperty(JSON_PROPERTY_ONLY_REQUIRED) String onlyRequired, @JsonProperty(JSON_PROPERTY_LIST) @Nullable List _list) { + this.str = str; + this._file = _file; + this.color = color; + this.onlyRequired = onlyRequired; + this._list = _list; + } + + public RequiredAndNullable str(@Nullable String str) { + + this.str = str; + return this; + } + + /** + * Get str + * @return str + */ + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getStr() { + return str; + } + + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStr(@Nullable String str) { + this.str = str; + } + + public RequiredAndNullable _file(@Nullable File _file) { + + this._file = _file; + return this; + } + + /** + * Get _file + * @return _file + */ + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable File getFile() { + return _file; + } + + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFile(@Nullable File _file) { + this._file = _file; + } + + public RequiredAndNullable color(@Nullable String color) { + + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getColor() { + return color; + } + + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setColor(@Nullable String color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getOnlyRequired() { + return onlyRequired; + } + + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + + this._list = _list; + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null) { + this._list = new ArrayList<>(); + } + this._list.add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable List getList() { + return _list; + } + + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setList(@Nullable List _list) { + this._list = _list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this._file, requiredAndNullable._file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, _file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str = str; + return this; + } + public RequiredAndNullable.Builder _file(@Nullable File _file) { + this.instance._file = _file; + return this; + } + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color = color; + return this; + } + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired = onlyRequired; + return this; + } + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list = _list; + return this; + } + + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable. + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + return new RequiredAndNullable.Builder() + .str(getStr()) + ._file(getFile()) + .color(getColor()) + .onlyRequired(getOnlyRequired()) + ._list(getList()); + } + + +} + diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java new file mode 100644 index 000000000000..e082ae37e368 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java @@ -0,0 +1,54 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.model.RequiredAndNullable; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.web.client.RestClientException; + +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * API tests for RequiredAndNullableApi + */ +@Disabled +class RequiredAndNullableApiTest { + + private final RequiredAndNullableApi api = new RequiredAndNullableApi(); + + + /** + * + * + * + * + * @throws RestClientException + * if the Api call fails + */ + @Test + void requiredAndNullablePostTest() { + RequiredAndNullable requiredAndNullable = null; + + RequiredAndNullable response = api.requiredAndNullablePost(requiredAndNullable); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java new file mode 100644 index 000000000000..bc686732b1ca --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java @@ -0,0 +1,55 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FileContent + */ +class FileContentTest { + private final FileContent model = new FileContent(); + + /** + * Model tests for FileContent + */ + @Test + void testFileContent() { + // TODO: test FileContent + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'size' + */ + @Test + void sizeTest() { + // TODO: test size + } + +} diff --git a/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java new file mode 100644 index 000000000000..3d3388460faf --- /dev/null +++ b/samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java @@ -0,0 +1,72 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RequiredAndNullable + */ +class RequiredAndNullableTest { + private final RequiredAndNullable model = new RequiredAndNullable(); + + /** + * Model tests for RequiredAndNullable + */ + @Test + void testRequiredAndNullable() { + // TODO: test RequiredAndNullable + } + + /** + * Test the property 'str' + */ + @Test + void strTest() { + // TODO: test str + } + + /** + * Test the property '_file' + */ + @Test + void _fileTest() { + // TODO: test _file + } + + /** + * Test the property 'color' + */ + @Test + void colorTest() { + // TODO: test color + } + + /** + * Test the property 'onlyRequired' + */ + @Test + void onlyRequiredTest() { + // TODO: test onlyRequired + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/NullableClass.java index 424dfc9afe8e..e0705bb0c852 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/NullableClass.java @@ -341,7 +341,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -388,7 +388,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -472,7 +472,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -519,7 +519,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/NullableClass.java index 118676eda91d..1dfe7ed13186 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/NullableClass.java @@ -333,7 +333,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -378,7 +378,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -456,7 +456,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -501,7 +501,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/vertx-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/vertx-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java index c84494a9487a..e8a4f5eb3b28 100644 --- a/samples/client/petstore/java/vertx-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/vertx-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java @@ -317,7 +317,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -362,7 +362,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -440,7 +440,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -485,7 +485,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/NullableClass.java index c84494a9487a..e8a4f5eb3b28 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/NullableClass.java @@ -317,7 +317,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -362,7 +362,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -440,7 +440,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -485,7 +485,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/vertx5-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/vertx5-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java index c84494a9487a..e8a4f5eb3b28 100644 --- a/samples/client/petstore/java/vertx5-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/vertx5-supportVertxFuture/src/main/java/org/openapitools/client/model/NullableClass.java @@ -317,7 +317,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -362,7 +362,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -440,7 +440,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -485,7 +485,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/vertx5/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/vertx5/src/main/java/org/openapitools/client/model/NullableClass.java index c84494a9487a..e8a4f5eb3b28 100644 --- a/samples/client/petstore/java/vertx5/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/vertx5/src/main/java/org/openapitools/client/model/NullableClass.java @@ -317,7 +317,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -362,7 +362,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -440,7 +440,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -485,7 +485,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/NullableClass.java index d401652b6fa7..de26bea586ab 100644 --- a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/NullableClass.java @@ -314,7 +314,7 @@ public NullableClass arrayNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -359,7 +359,7 @@ public NullableClass arrayAndItemsNullableProp(@jakarta.annotation.Nullable List } public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -437,7 +437,7 @@ public NullableClass objectNullableProp(@jakarta.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -482,7 +482,7 @@ public NullableClass objectAndItemsNullableProp(@jakarta.annotation.Nullable Map } public NullableClass putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES index 537a17ba9f7d..821db0873c19 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/.openapi-generator/FILES @@ -6,8 +6,11 @@ api/openapi.yaml build.gradle build.sbt docs/FileApi.md +docs/FileContent.md docs/Foo.md docs/FooApi.md +docs/RequiredAndNullable.md +docs/RequiredAndNullableApi.md docs/UploadApi.md git_push.sh gradle.properties @@ -29,12 +32,15 @@ src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java src/main/java/org/openapitools/client/api/FileApi.java src/main/java/org/openapitools/client/api/FooApi.java +src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java src/main/java/org/openapitools/client/api/UploadApi.java src/main/java/org/openapitools/client/api/package-info.java src/main/java/org/openapitools/client/auth/ApiKeyAuth.java src/main/java/org/openapitools/client/auth/Authentication.java src/main/java/org/openapitools/client/auth/HttpBasicAuth.java src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +src/main/java/org/openapitools/client/model/FileContent.java src/main/java/org/openapitools/client/model/Foo.java +src/main/java/org/openapitools/client/model/RequiredAndNullable.java src/main/java/org/openapitools/client/model/package-info.java src/main/java/org/openapitools/client/package-info.java diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/README.md b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/README.md index 36aac7266f67..6e3266ebce3f 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/README.md +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/README.md @@ -95,7 +95,8 @@ public class FileApiExample { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -116,13 +117,16 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *FileApi* | [**fileIdGet**](docs/FileApi.md#fileIdGet) | **GET** /file/{id} | *FooApi* | [**fooDtParamGet**](docs/FooApi.md#fooDtParamGet) | **GET** /foo/{dtParam} | +*RequiredAndNullableApi* | [**requiredAndNullablePost**](docs/RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | *UploadApi* | [**uploadFilesPost**](docs/UploadApi.md#uploadFilesPost) | **POST** /uploadFiles | *UploadApi* | [**uploadPost**](docs/UploadApi.md#uploadPost) | **POST** /upload | ## Documentation for Models + - [FileContent](docs/FileContent.md) - [Foo](docs/Foo.md) + - [RequiredAndNullable](docs/RequiredAndNullable.md) diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/api/openapi.yaml b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/api/openapi.yaml index b5f967c8460e..15c1f4176a50 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/api/openapi.yaml +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/api/openapi.yaml @@ -6,6 +6,8 @@ info: servers: - url: / tags: +- description: requiredAndNullable + name: requiredAndNullable - description: foo name: foo - description: upload @@ -59,6 +61,27 @@ paths: - foo x-accepts: - application/json + /requiredAndNullable: + post: + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: bodyWithRequiredAndNullableAttributes + required: true + responses: + default: + content: + application/json: + schema: + $ref: "#/components/schemas/RequiredAndNullable" + description: response + tags: + - requiredAndNullable + x-content-type: application/json + x-accepts: + - application/json /upload: post: requestBody: @@ -103,6 +126,10 @@ paths: style: simple responses: "200": + content: + application/json: + schema: + $ref: "#/components/schemas/FileContent" description: ok tags: - file @@ -185,6 +212,62 @@ components: required: - requiredColor - requiredDt + RequiredAndNullable: + example: + str: str + file: "" + color: red + onlyRequired: onlyRequired + list: + - list + - list + properties: + str: + nullable: true + type: string + file: + format: binary + nullable: true + type: string + color: + default: red + nullable: true + type: string + onlyRequired: + type: string + list: + items: + type: string + nullable: true + type: array + required: + - color + - file + - list + - onlyRequired + - str + type: object + FileContent: + example: + name: name + size: 0 + virusScan: clean + properties: + name: + readOnly: true + type: string + size: + readOnly: true + type: integer + virusScan: + enum: + - clean + - detected + readOnly: true + type: string + required: + - name + type: object _upload_post_request: properties: file: diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileApi.md b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileApi.md index 4e6607ae5a71..59683371bc55 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileApi.md +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileApi.md @@ -10,7 +10,7 @@ All URIs are relative to *http://localhost* ## fileIdGet -> fileIdGet(id) +> FileContent fileIdGet(id) @@ -32,7 +32,8 @@ public class Example { FileApi apiInstance = new FileApi(defaultClient); String id = "id_example"; // String | try { - apiInstance.fileIdGet(id); + FileContent result = apiInstance.fileIdGet(id); + System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling FileApi#fileIdGet"); System.err.println("Status code: " + e.getCode()); @@ -53,7 +54,7 @@ public class Example { ### Return type -null (empty response body) +[**FileContent**](FileContent.md) ### Authorization @@ -62,7 +63,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined -- **Accept**: Not defined +- **Accept**: application/json ### HTTP response details diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileContent.md b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileContent.md new file mode 100644 index 000000000000..5b6654a0bf18 --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/FileContent.md @@ -0,0 +1,24 @@ + + +# FileContent + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**name** | **String** | | [readonly] | +|**size** | **Integer** | | [optional] [readonly] | +|**virusScan** | [**VirusScanEnum**](#VirusScanEnum) | | [optional] [readonly] | + + + +## Enum: VirusScanEnum + +| Name | Value | +|---- | -----| +| CLEAN | "clean" | +| DETECTED | "detected" | + + + diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md new file mode 100644 index 000000000000..ff4ade0f226d --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullable.md @@ -0,0 +1,17 @@ + + +# RequiredAndNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**str** | **String** | | | +|**_file** | **File** | | | +|**color** | **String** | | | +|**onlyRequired** | **String** | | | +|**_list** | **List<String>** | | | + + + diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md new file mode 100644 index 000000000000..ada434bf0b9e --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/docs/RequiredAndNullableApi.md @@ -0,0 +1,73 @@ +# RequiredAndNullableApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**requiredAndNullablePost**](RequiredAndNullableApi.md#requiredAndNullablePost) | **POST** /requiredAndNullable | | + + + +## requiredAndNullablePost + +> RequiredAndNullable requiredAndNullablePost(requiredAndNullable) + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.RequiredAndNullableApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + RequiredAndNullableApi apiInstance = new RequiredAndNullableApi(defaultClient); + RequiredAndNullable requiredAndNullable = new RequiredAndNullable(); // RequiredAndNullable | bodyWithRequiredAndNullableAttributes + try { + RequiredAndNullable result = apiInstance.requiredAndNullablePost(requiredAndNullable); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RequiredAndNullableApi#requiredAndNullablePost"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **requiredAndNullable** | [**RequiredAndNullable**](RequiredAndNullable.md)| bodyWithRequiredAndNullableAttributes | | + +### Return type + +[**RequiredAndNullable**](RequiredAndNullable.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java index 5832d514cbad..5f15e56030a1 100644 --- a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/FileApi.java @@ -2,6 +2,7 @@ import org.openapitools.client.ApiClient; +import org.openapitools.client.model.FileContent; import java.util.HashMap; import java.util.List; @@ -50,6 +51,7 @@ public void setApiClient(ApiClient apiClient) { * *

    200 - ok * @param id The id parameter + * @return FileContent * @throws WebClientResponseException if an error occurs while attempting to invoke the API */ private ResponseSpec fileIdGetRequestCreation(String id) throws WebClientResponseException { @@ -68,14 +70,16 @@ private ResponseSpec fileIdGetRequestCreation(String id) throws WebClientRespons final MultiValueMap cookieParams = new LinkedMultiValueMap(); final MultiValueMap formParams = new LinkedMultiValueMap(); - final String[] localVarAccepts = { }; + final String[] localVarAccepts = { + "application/json" + }; final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { }; - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/file/{id}", HttpMethod.GET, pathParams, localVarQueryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } @@ -84,10 +88,11 @@ private ResponseSpec fileIdGetRequestCreation(String id) throws WebClientRespons * *

    200 - ok * @param id The id parameter + * @return FileContent * @throws WebClientResponseException if an error occurs while attempting to invoke the API */ - public Mono fileIdGet(String id) throws WebClientResponseException { - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + public Mono fileIdGet(String id) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return fileIdGetRequestCreation(id).bodyToMono(localVarReturnType); } @@ -96,10 +101,11 @@ public Mono fileIdGet(String id) throws WebClientResponseException { * *

    200 - ok * @param id The id parameter + * @return ResponseEntity<FileContent> * @throws WebClientResponseException if an error occurs while attempting to invoke the API */ - public Mono> fileIdGetWithHttpInfo(String id) throws WebClientResponseException { - ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + public Mono> fileIdGetWithHttpInfo(String id) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return fileIdGetRequestCreation(id).toEntity(localVarReturnType); } diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..502a694520af --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/api/RequiredAndNullableApi.java @@ -0,0 +1,123 @@ +package org.openapitools.client.api; + +import org.openapitools.client.ApiClient; + +import org.openapitools.client.model.RequiredAndNullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; +import org.springframework.web.reactive.function.client.WebClientResponseException; +import reactor.core.publisher.Mono; +import reactor.core.publisher.Flux; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullableApi { + private ApiClient apiClient; + + public RequiredAndNullableApi() { + this(new ApiClient()); + } + + public RequiredAndNullableApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return RequiredAndNullable + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec requiredAndNullablePostRequestCreation(RequiredAndNullable requiredAndNullable) throws WebClientResponseException { + Object postBody = requiredAndNullable; + // verify the required parameter 'requiredAndNullable' is set + if (requiredAndNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'requiredAndNullable' when calling requiredAndNullablePost", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/requiredAndNullable", HttpMethod.POST, pathParams, localVarQueryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return RequiredAndNullable + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono requiredAndNullablePost(RequiredAndNullable requiredAndNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return requiredAndNullablePostRequestCreation(requiredAndNullable).bodyToMono(localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return ResponseEntity<RequiredAndNullable> + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> requiredAndNullablePostWithHttpInfo(RequiredAndNullable requiredAndNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return requiredAndNullablePostRequestCreation(requiredAndNullable).toEntity(localVarReturnType); + } + + /** + * + * + *

    0 - response + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec requiredAndNullablePostWithResponseSpec(RequiredAndNullable requiredAndNullable) throws WebClientResponseException { + return requiredAndNullablePostRequestCreation(requiredAndNullable); + } +} diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java new file mode 100644 index 000000000000..f93380d95eac --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/FileContent.java @@ -0,0 +1,246 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * FileContent + */ +@JsonPropertyOrder({ + FileContent.JSON_PROPERTY_NAME, + FileContent.JSON_PROPERTY_SIZE, + FileContent.JSON_PROPERTY_VIRUS_SCAN +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + public static final String JSON_PROPERTY_NAME = "name"; + + private String name; + + public static final String JSON_PROPERTY_SIZE = "size"; + + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN(String.valueOf("clean")), + + DETECTED(String.valueOf("detected")); + + private String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_VIRUS_SCAN = "virusScan"; + + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + } + /** + * Constructor with only readonly parameters and all parameters + */ + @JsonCreator + public FileContent( + @JsonProperty(JSON_PROPERTY_NAME) String name, + @JsonProperty(JSON_PROPERTY_SIZE) Integer size, + @JsonProperty(JSON_PROPERTY_VIRUS_SCAN) VirusScanEnum virusScan + ) { + this(); + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + /** + * Get name + * @return name + */ + + @JsonProperty(value = JSON_PROPERTY_NAME, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getName() { + return name; + } + + + + /** + * Get size + * @return size + */ + + @JsonProperty(value = JSON_PROPERTY_SIZE, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable Integer getSize() { + return size; + } + + + + /** + * Get virusScan + * @return virusScan + */ + + @JsonProperty(value = JSON_PROPERTY_VIRUS_SCAN, required = false) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + public FileContent.Builder name(String name) { + this.instance.name = name; + return this; + } + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size = size; + return this; + } + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan = virusScan; + return this; + } + + + /** + * returns a built FileContent instance. + * + * The builder is not reusable. + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + return new FileContent.Builder() + .name(getName()) + .size(getSize()) + .virusScan(getVirusScan()); + } + + +} + diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java new file mode 100644 index 000000000000..9c18ec5777e1 --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/RequiredAndNullable.java @@ -0,0 +1,327 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * RequiredAndNullable + */ +@JsonPropertyOrder({ + RequiredAndNullable.JSON_PROPERTY_STR, + RequiredAndNullable.JSON_PROPERTY_FILE, + RequiredAndNullable.JSON_PROPERTY_COLOR, + RequiredAndNullable.JSON_PROPERTY_ONLY_REQUIRED, + RequiredAndNullable.JSON_PROPERTY_LIST +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + public static final String JSON_PROPERTY_STR = "str"; + + private @Nullable String str; + + public static final String JSON_PROPERTY_FILE = "file"; + + private @Nullable File _file; + + public static final String JSON_PROPERTY_COLOR = "color"; + + private @Nullable String color = "red"; + + public static final String JSON_PROPERTY_ONLY_REQUIRED = "onlyRequired"; + + private String onlyRequired; + + public static final String JSON_PROPERTY_LIST = "list"; + + private @Nullable List _list; + + public RequiredAndNullable() { + } + + /** + * Constructor with all args parameters + */ + public RequiredAndNullable(@JsonProperty(JSON_PROPERTY_STR) @Nullable String str, @JsonProperty(JSON_PROPERTY_FILE) @Nullable File _file, @JsonProperty(JSON_PROPERTY_COLOR) @Nullable String color, @JsonProperty(JSON_PROPERTY_ONLY_REQUIRED) String onlyRequired, @JsonProperty(JSON_PROPERTY_LIST) @Nullable List _list) { + this.str = str; + this._file = _file; + this.color = color; + this.onlyRequired = onlyRequired; + this._list = _list; + } + + public RequiredAndNullable str(@Nullable String str) { + + this.str = str; + return this; + } + + /** + * Get str + * @return str + */ + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getStr() { + return str; + } + + + @JsonProperty(value = JSON_PROPERTY_STR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStr(@Nullable String str) { + this.str = str; + } + + public RequiredAndNullable _file(@Nullable File _file) { + + this._file = _file; + return this; + } + + /** + * Get _file + * @return _file + */ + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable File getFile() { + return _file; + } + + + @JsonProperty(value = JSON_PROPERTY_FILE, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFile(@Nullable File _file) { + this._file = _file; + } + + public RequiredAndNullable color(@Nullable String color) { + + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable String getColor() { + return color; + } + + + @JsonProperty(value = JSON_PROPERTY_COLOR, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setColor(@Nullable String color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public String getOnlyRequired() { + return onlyRequired; + } + + + @JsonProperty(value = JSON_PROPERTY_ONLY_REQUIRED, required = true) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + + this._list = _list; + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null) { + this._list = new ArrayList<>(); + } + this._list.add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + + public @Nullable List getList() { + return _list; + } + + + @JsonProperty(value = JSON_PROPERTY_LIST, required = false) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setList(@Nullable List _list) { + this._list = _list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this._file, requiredAndNullable._file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, _file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str = str; + return this; + } + public RequiredAndNullable.Builder _file(@Nullable File _file) { + this.instance._file = _file; + return this; + } + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color = color; + return this; + } + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired = onlyRequired; + return this; + } + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list = _list; + return this; + } + + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable. + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field. + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + return new RequiredAndNullable.Builder() + .str(getStr()) + ._file(getFile()) + .color(getColor()) + .onlyRequired(getOnlyRequired()) + ._list(getList()); + } + + +} + diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java new file mode 100644 index 000000000000..5adf56d29694 --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/api/RequiredAndNullableApiTest.java @@ -0,0 +1,50 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.model.RequiredAndNullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * API tests for RequiredAndNullableApi + */ +@Disabled +public class RequiredAndNullableApiTest { + + private final RequiredAndNullableApi api = new RequiredAndNullableApi(); + + + /** + * + * + * + */ + @Test + public void requiredAndNullablePostTest() { + // uncomment below to test the function + //RequiredAndNullable requiredAndNullable = null; + //RequiredAndNullable response = api.requiredAndNullablePost(requiredAndNullable).block(); + + // TODO: test validations + } + +} diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java new file mode 100644 index 000000000000..bc686732b1ca --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/FileContentTest.java @@ -0,0 +1,55 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FileContent + */ +class FileContentTest { + private final FileContent model = new FileContent(); + + /** + * Model tests for FileContent + */ + @Test + void testFileContent() { + // TODO: test FileContent + } + + /** + * Test the property 'name' + */ + @Test + void nameTest() { + // TODO: test name + } + + /** + * Test the property 'size' + */ + @Test + void sizeTest() { + // TODO: test size + } + +} diff --git a/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java new file mode 100644 index 000000000000..3d3388460faf --- /dev/null +++ b/samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/test/java/org/openapitools/client/model/RequiredAndNullableTest.java @@ -0,0 +1,72 @@ +/* + * jspecify + * test fully qualified name and jspecify + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.File; +import org.jspecify.annotations.Nullable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RequiredAndNullable + */ +class RequiredAndNullableTest { + private final RequiredAndNullable model = new RequiredAndNullable(); + + /** + * Model tests for RequiredAndNullable + */ + @Test + void testRequiredAndNullable() { + // TODO: test RequiredAndNullable + } + + /** + * Test the property 'str' + */ + @Test + void strTest() { + // TODO: test str + } + + /** + * Test the property '_file' + */ + @Test + void _fileTest() { + // TODO: test _file + } + + /** + * Test the property 'color' + */ + @Test + void colorTest() { + // TODO: test color + } + + /** + * Test the property 'onlyRequired' + */ + @Test + void onlyRequiredTest() { + // TODO: test onlyRequired + } + +} diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java index 4cb6c72d1c7a..a2abc60038f5 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -342,7 +342,7 @@ public EnumTest outerEnum(@javax.annotation.Nullable OuterEnum outerEnum) { * @return outerEnum */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public OuterEnum getOuterEnum() { diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java index fd3b4c322384..3acd36551d5c 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/HealthCheckResult.java @@ -55,7 +55,7 @@ public HealthCheckResult nullableMessage(@javax.annotation.Nullable String nulla * @return nullableMessage */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public String getNullableMessage() { diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java index de20b627ec8a..e33c593549c5 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/NullableClass.java @@ -121,7 +121,7 @@ public NullableClass integerProp(@javax.annotation.Nullable Integer integerProp) * @return integerProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Integer getIntegerProp() { @@ -155,7 +155,7 @@ public NullableClass numberProp(@javax.annotation.Nullable BigDecimal numberProp * @return numberProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public BigDecimal getNumberProp() { @@ -189,7 +189,7 @@ public NullableClass booleanProp(@javax.annotation.Nullable Boolean booleanProp) * @return booleanProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Boolean getBooleanProp() { @@ -223,7 +223,7 @@ public NullableClass stringProp(@javax.annotation.Nullable String stringProp) { * @return stringProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public String getStringProp() { @@ -257,7 +257,7 @@ public NullableClass dateProp(@javax.annotation.Nullable LocalDate dateProp) { * @return dateProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public LocalDate getDateProp() { @@ -291,7 +291,7 @@ public NullableClass datetimeProp(@javax.annotation.Nullable OffsetDateTime date * @return datetimeProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public OffsetDateTime getDatetimeProp() { @@ -321,7 +321,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -337,7 +337,7 @@ public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { * @return arrayNullableProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public List getArrayNullableProp() { @@ -367,7 +367,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -383,7 +383,7 @@ public NullableClass addArrayAndItemsNullablePropItem(Object arrayAndItemsNullab * @return arrayAndItemsNullableProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public List getArrayAndItemsNullableProp() { @@ -447,7 +447,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -463,7 +463,7 @@ public NullableClass putObjectNullablePropItem(String key, Object objectNullable * @return objectNullableProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Map getObjectNullableProp() { @@ -493,7 +493,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -509,7 +509,7 @@ public NullableClass putObjectAndItemsNullablePropItem(String key, Object object * @return objectAndItemsNullableProp */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public Map getObjectAndItemsNullableProp() { diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java index 25f57e937f87..988db24f6d00 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -130,7 +130,7 @@ public ParentWithNullable nullableProperty(@javax.annotation.Nullable String nul * @return nullableProperty */ @javax.annotation.Nullable - @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "", nullable = true) @JsonIgnore public String getNullableProperty() { diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java index de1623f94d5d..d043d63cd0db 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/NullableClass.java @@ -314,7 +314,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -359,7 +359,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -437,7 +437,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -482,7 +482,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/NullableClass.java index ecc0197fc121..8229f317c5a9 100644 --- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/NullableClass.java @@ -314,7 +314,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -359,7 +359,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -437,7 +437,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -482,7 +482,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Pet.java b/samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Pet.java index 53b64044c6e3..cbfefe49d0ce 100644 --- a/samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Pet.java +++ b/samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/model/Pet.java @@ -149,8 +149,8 @@ public Pet name(String name) { * Get name * @return name */ - @NotNull - @Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("name") public JsonNullable getName() { return name; diff --git a/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java b/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java index d88271c2bf46..bff7e7b1bf37 100644 --- a/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java +++ b/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -49,7 +49,7 @@ public ContainerDefaultValueDto nullableArray(List nullableArray) { } public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -76,7 +76,7 @@ public ContainerDefaultValueDto nullableRequiredArray(List nullableRequi } public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -87,7 +87,7 @@ public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequ * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -132,7 +132,7 @@ public ContainerDefaultValueDto nullableArrayWithDefault(List nullableAr } public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/NullableMapPropertyDto.java b/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/NullableMapPropertyDto.java index f84d9d21f9cf..9014b6f011cb 100644 --- a/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/NullableMapPropertyDto.java +++ b/samples/client/petstore/spring-http-interface-bean-validation/src/main/java/org/openapitools/model/NullableMapPropertyDto.java @@ -36,7 +36,7 @@ public NullableMapPropertyDto languageValues(Map languageValues) } public NullableMapPropertyDto putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java b/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java index fe0be24e229d..97abe298e2a2 100644 --- a/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java +++ b/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -48,7 +48,7 @@ public ContainerDefaultValueDto nullableArray(List nullableArray) { } public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -75,7 +75,7 @@ public ContainerDefaultValueDto nullableRequiredArray(List nullableRequi } public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -86,7 +86,7 @@ public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequ * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -131,7 +131,7 @@ public ContainerDefaultValueDto nullableArrayWithDefault(List nullableAr } public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/NullableMapPropertyDto.java b/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/NullableMapPropertyDto.java index d9edf72050f1..4e174dcc657b 100644 --- a/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/NullableMapPropertyDto.java +++ b/samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/model/NullableMapPropertyDto.java @@ -35,7 +35,7 @@ public NullableMapPropertyDto languageValues(Map languageValues) } public NullableMapPropertyDto putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java index ca932fee5f0f..e01eaa250b71 100644 --- a/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -55,7 +55,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -82,7 +82,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -93,7 +93,7 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -138,7 +138,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/NullableMapProperty.java index dff5aa4523f8..591056e5100f 100644 --- a/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/client/petstore/spring-http-interface-reactive-bean-validation/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -34,7 +34,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 31a8133cb94f..d0b2e33d0b77 100644 --- a/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -54,7 +54,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -81,7 +81,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -92,7 +92,7 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -137,7 +137,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java index 5e0395f3fd34..a723c91d0d1c 100644 --- a/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -33,7 +33,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 31a8133cb94f..d0b2e33d0b77 100644 --- a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -54,7 +54,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -81,7 +81,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -92,7 +92,7 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -137,7 +137,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java index 5e0395f3fd34..a723c91d0d1c 100644 --- a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -33,7 +33,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/client/petstore/spring-http-interface-springboot-4/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java b/samples/client/petstore/spring-http-interface-springboot-4/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java index b5627e929b6b..fd7d122ed37b 100644 --- a/samples/client/petstore/spring-http-interface-springboot-4/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java +++ b/samples/client/petstore/spring-http-interface-springboot-4/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -86,7 +86,7 @@ public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequ * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + @JsonProperty("nullable_required_array") public List getNullableRequiredArray() { return nullableRequiredArray; diff --git a/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 219aeb0cd0ed..0876fa4f8b1f 100644 --- a/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -83,7 +83,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -94,7 +94,7 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -139,7 +139,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/NullableMapProperty.java index c25a2eaa55bf..77672ce2ef4f 100644 --- a/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/client/petstore/spring-http-interface-useHttpServiceProxyFactoryInterfacesConfigurator/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java index fe0be24e229d..97abe298e2a2 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -48,7 +48,7 @@ public ContainerDefaultValueDto nullableArray(List nullableArray) { } public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -75,7 +75,7 @@ public ContainerDefaultValueDto nullableRequiredArray(List nullableRequi } public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -86,7 +86,7 @@ public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequ * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull + /* @Present */ @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -131,7 +131,7 @@ public ContainerDefaultValueDto nullableArrayWithDefault(List nullableAr } public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/NullableMapPropertyDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/NullableMapPropertyDto.java index d9edf72050f1..4e174dcc657b 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/NullableMapPropertyDto.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/NullableMapPropertyDto.java @@ -35,7 +35,7 @@ public NullableMapPropertyDto languageValues(Map languageValues) } public NullableMapPropertyDto putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/NullableClass.java index 84830c15f4a2..b24140ddb017 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/NullableClass.java @@ -307,7 +307,7 @@ public NullableClass arrayNullableProp(@javax.annotation.Nullable List a } public NullableClass addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.>of(new ArrayList<>()); } try { @@ -352,7 +352,7 @@ public NullableClass arrayAndItemsNullableProp(@javax.annotation.Nullable List>of(new ArrayList<>()); } try { @@ -430,7 +430,7 @@ public NullableClass objectNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { @@ -475,7 +475,7 @@ public NullableClass objectAndItemsNullableProp(@javax.annotation.Nullable Map>of(new HashMap<>()); } try { diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 5e934e643224..8caad40bef04 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -48,7 +48,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -60,7 +60,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -76,7 +76,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -87,8 +87,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -134,7 +134,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -146,7 +146,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/.openapi-generator/FILES index bc1941bdad50..559ef9c95db3 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/.openapi-generator/FILES @@ -3,8 +3,11 @@ pom.xml src/main/java/org/openapitools/api/ApiUtil.java src/main/java/org/openapitools/api/FileApi.java src/main/java/org/openapitools/api/FooApi.java +src/main/java/org/openapitools/api/RequiredAndNullableApi.java src/main/java/org/openapitools/api/UploadApi.java src/main/java/org/openapitools/api/UploadFilesApi.java src/main/java/org/openapitools/api/package-info.java +src/main/java/org/openapitools/model/FileContent.java src/main/java/org/openapitools/model/Foo.java +src/main/java/org/openapitools/model/RequiredAndNullable.java src/main/java/org/openapitools/model/package-info.java diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/FileApi.java b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/FileApi.java index 0ee298fc93e5..ee8c018556a2 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/FileApi.java +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/FileApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import org.openapitools.model.FileContent; import io.swagger.v3.oas.annotations.ExternalDocumentation; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -52,16 +53,28 @@ default Optional getRequest() { operationId = "fileIdGet", tags = { "file" }, responses = { - @ApiResponse(responseCode = "200", description = "ok") + @ApiResponse(responseCode = "200", description = "ok", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = FileContent.class)) + }) } ) @RequestMapping( method = RequestMethod.GET, - value = FileApi.PATH_FILE_ID_GET + value = FileApi.PATH_FILE_ID_GET, + produces = { "application/json" } ) - default ResponseEntity fileIdGet( + default ResponseEntity fileIdGet( @Parameter(name = "id", description = "", required = true, in = ParameterIn.PATH) @PathVariable("id") String id ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"name\" : \"name\", \"size\" : 0, \"virusScan\" : \"clean\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/RequiredAndNullableApi.java b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..a7057ce15f82 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/api/RequiredAndNullableApi.java @@ -0,0 +1,83 @@ +/* + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.25.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.RequiredAndNullable; +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import jakarta.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +@Validated +@Tag(name = "requiredAndNullable", description = "requiredAndNullable") +public interface RequiredAndNullableApi { + + default Optional getRequest() { + return Optional.empty(); + } + + String PATH_REQUIRED_AND_NULLABLE_POST = "/requiredAndNullable"; + /** + * POST /requiredAndNullable + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return response (status code 200) + */ + @Operation( + operationId = "requiredAndNullablePost", + tags = { "requiredAndNullable" }, + responses = { + @ApiResponse(responseCode = "default", description = "response", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = RequiredAndNullable.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = RequiredAndNullableApi.PATH_REQUIRED_AND_NULLABLE_POST, + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity requiredAndNullablePost( + @Parameter(name = "RequiredAndNullable", description = "bodyWithRequiredAndNullableAttributes", required = true) @Valid @RequestBody RequiredAndNullable requiredAndNullable + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"str\" : \"str\", \"file\" : \"\", \"color\" : \"red\", \"onlyRequired\" : \"onlyRequired\", \"list\" : [ \"list\", \"list\" ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/FileContent.java b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/FileContent.java new file mode 100644 index 000000000000..02f2fd5666ed --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/FileContent.java @@ -0,0 +1,274 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import io.swagger.v3.oas.annotations.media.Schema; + +import jakarta.xml.bind.annotation.*; + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * FileContent + */ + +@JacksonXmlRootElement(localName = "FileContent") +@XmlRootElement(name = "FileContent") +@XmlAccessorType(XmlAccessType.FIELD) +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + + private String name; + + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN("clean"), + + DETECTED("detected"); + + private final String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + super(); + } + + /** + * Constructor with only required parameters + */ + public FileContent(String name) { + this.name = name; + } + + /** + * Constructor with all args parameters + */ + public FileContent(String name, @Nullable Integer size, @Nullable VirusScanEnum virusScan) { + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + public FileContent name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + + @Schema(name = "name", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("name") + @JacksonXmlProperty(localName = "name") + @XmlElement(name = "name") + public String getName() { + return name; + } + + @JsonProperty("name") + @JacksonXmlProperty(localName = "name") + public void setName(String name) { + this.name = name; + } + + public FileContent size(@Nullable Integer size) { + this.size = size; + return this; + } + + /** + * Get size + * @return size + */ + + @Schema(name = "size", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("size") + @JacksonXmlProperty(localName = "size") + @XmlElement(name = "size") + public @Nullable Integer getSize() { + return size; + } + + @JsonProperty("size") + @JacksonXmlProperty(localName = "size") + public void setSize(@Nullable Integer size) { + this.size = size; + } + + public FileContent virusScan(@Nullable VirusScanEnum virusScan) { + this.virusScan = virusScan; + return this; + } + + /** + * Get virusScan + * @return virusScan + */ + + @Schema(name = "virusScan", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("virusScan") + @JacksonXmlProperty(localName = "virusScan") + @XmlElement(name = "virusScan") + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + @JsonProperty("virusScan") + @JacksonXmlProperty(localName = "virusScan") + public void setVirusScan(@Nullable VirusScanEnum virusScan) { + this.virusScan = virusScan; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + protected Builder copyOf(FileContent value) { + this.instance.setName(value.name); + this.instance.setSize(value.size); + this.instance.setVirusScan(value.virusScan); + return this; + } + + public FileContent.Builder name(String name) { + this.instance.name(name); + return this; + } + + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size(size); + return this; + } + + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan(virusScan); + return this; + } + + /** + * returns a built FileContent instance. + * + * The builder is not reusable (NullPointerException) + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field (except for the default values). + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + FileContent.Builder builder = new FileContent.Builder(); + return builder.copyOf(this); + } + +} + diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/Foo.java b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/Foo.java index 59f585f6eb8d..edae969af681 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/Foo.java +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/Foo.java @@ -131,7 +131,7 @@ public Foo nullableDt(java.time.@Nullable Instant nullableDt) { * @return nullableDt */ @Valid - @Schema(name = "nullableDt", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableDt", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableDt") @JacksonXmlProperty(localName = "nullableDt") @XmlElement(name = "nullableDt") @@ -177,7 +177,7 @@ public Foo nullableBinary(org.springframework.core.io.@Nullable Resource nullabl * @return nullableBinary */ @Valid - @Schema(name = "nullableBinary", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableBinary", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableBinary") @JacksonXmlProperty(localName = "nullableBinary") @XmlElement(name = "nullableBinary") @@ -263,7 +263,7 @@ public Foo nullableListMinIntems(@Nullable List nullableListM } public Foo addNullableListMinIntemsItem(java.time.Instant nullableListMinIntemsItem) { - if (this.nullableListMinIntems == null || !this.nullableListMinIntems.isPresent()) { + if (this.nullableListMinIntems == null || !this.nullableListMinIntems.isPresent() || this.nullableListMinIntems.get() == null) { this.nullableListMinIntems = JsonNullable.of(new ArrayList<>()); } this.nullableListMinIntems.get().add(nullableListMinIntemsItem); @@ -275,7 +275,7 @@ public Foo addNullableListMinIntemsItem(java.time.Instant nullableListMinIntemsI * @return nullableListMinIntems */ @Valid @Size(min = 1) - @Schema(name = "nullableListMinIntems", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableListMinIntems", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableListMinIntems") @JacksonXmlProperty(localName = "nullableListMinIntems") @JacksonXmlElementWrapper(useWrapping = false) @@ -346,7 +346,7 @@ public Foo nullableNumber(java.math.@Nullable BigDecimal nullableNumber) { * @return nullableNumber */ @Valid - @Schema(name = "nullableNumber", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableNumber", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableNumber") @JacksonXmlProperty(localName = "nullableNumber") @XmlElement(name = "nullableNumber") @@ -416,7 +416,7 @@ public Foo nullableColor(@Nullable String nullableColor) { * @return nullableColor */ - @Schema(name = "nullableColor", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableColor", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableColor") @JacksonXmlProperty(localName = "nullableColor") @XmlElement(name = "nullableColor") diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/RequiredAndNullable.java b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/RequiredAndNullable.java new file mode 100644 index 000000000000..3db95fb22627 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-openapiNullable/src/main/java/org/openapitools/model/RequiredAndNullable.java @@ -0,0 +1,334 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import io.swagger.v3.oas.annotations.media.Schema; + +import jakarta.xml.bind.annotation.*; + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * RequiredAndNullable + */ + +@JacksonXmlRootElement(localName = "RequiredAndNullable") +@XmlRootElement(name = "RequiredAndNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + + private JsonNullable str = JsonNullable.undefined(); + + private JsonNullable file = JsonNullable.undefined(); + + private JsonNullable color = JsonNullable.undefined(); + + private String onlyRequired; + + private JsonNullable> _list = JsonNullable.>undefined(); + + public RequiredAndNullable() { + super(); + } + + /** + * Constructor with only required parameters and all parameters + */ + public RequiredAndNullable(@Nullable String str, org.springframework.core.io.@Nullable Resource file, @Nullable String color, String onlyRequired, @Nullable List _list) { + this.str = JsonNullable.of(str); + this.file = JsonNullable.of(file); + this.color = JsonNullable.of(color); + this.onlyRequired = onlyRequired; + this._list = JsonNullable.of(_list); + } + + public RequiredAndNullable str(@Nullable String str) { + this.str = JsonNullable.of(str); + return this; + } + + /** + * Get str + * @return str + */ + /* @Present */ + @Schema(name = "str", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("str") + @JacksonXmlProperty(localName = "str") + @XmlElement(name = "str") + public JsonNullable getStr() { + return str; + } + + @JsonProperty("str") + @JacksonXmlProperty(localName = "str") + public void setStr(JsonNullable str) { + this.str = str; + } + + public RequiredAndNullable file(org.springframework.core.io.@Nullable Resource file) { + this.file = JsonNullable.of(file); + return this; + } + + /** + * Get file + * @return file + */ + /* @Present */ @Valid + @Schema(name = "file", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("file") + @JacksonXmlProperty(localName = "file") + @XmlElement(name = "file") + public JsonNullable getFile() { + return file; + } + + @JsonProperty("file") + @JacksonXmlProperty(localName = "file") + public void setFile(JsonNullable file) { + this.file = file; + } + + public RequiredAndNullable color(@Nullable String color) { + this.color = JsonNullable.of(color); + return this; + } + + /** + * Get color + * @return color + */ + /* @Present */ + @Schema(name = "color", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("color") + @JacksonXmlProperty(localName = "color") + @XmlElement(name = "color") + public JsonNullable getColor() { + return color; + } + + @JsonProperty("color") + @JacksonXmlProperty(localName = "color") + public void setColor(JsonNullable color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + @NotNull + @Schema(name = "onlyRequired", requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("onlyRequired") + @JacksonXmlProperty(localName = "onlyRequired") + @XmlElement(name = "onlyRequired") + public String getOnlyRequired() { + return onlyRequired; + } + + @JsonProperty("onlyRequired") + @JacksonXmlProperty(localName = "onlyRequired") + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + this._list = JsonNullable.of(_list); + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null || !this._list.isPresent() || this._list.get() == null) { + this._list = JsonNullable.of(new ArrayList<>()); + } + this._list.get().add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + /* @Present */ + @Schema(name = "list", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("list") + @JacksonXmlProperty(localName = "list") + @JacksonXmlElementWrapper(useWrapping = false) + @XmlElement(name = "list") + public JsonNullable> getList() { + return _list; + } + + @JsonProperty("list") + @JacksonXmlProperty(localName = "list") + @JacksonXmlElementWrapper(useWrapping = false) + public void setList(JsonNullable> _list) { + this._list = _list; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this.file, requiredAndNullable.file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + protected Builder copyOf(RequiredAndNullable value) { + this.instance.setStr(value.str); + this.instance.setFile(value.file); + this.instance.setColor(value.color); + this.instance.setOnlyRequired(value.onlyRequired); + this.instance.setList(value._list); + return this; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str(str); + return this; + } + + public RequiredAndNullable.Builder str(JsonNullable str) { + this.instance.str = str; + return this; + } + + public RequiredAndNullable.Builder file(org.springframework.core.io.@Nullable Resource file) { + this.instance.file(file); + return this; + } + + public RequiredAndNullable.Builder file(JsonNullable file) { + this.instance.file = file; + return this; + } + + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color(color); + return this; + } + + public RequiredAndNullable.Builder color(JsonNullable color) { + this.instance.color = color; + return this; + } + + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired(onlyRequired); + return this; + } + + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list(_list); + return this; + } + + public RequiredAndNullable.Builder _list(JsonNullable> _list) { + this.instance._list = _list; + return this; + } + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable (NullPointerException) + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field (except for the default values). + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + RequiredAndNullable.Builder builder = new RequiredAndNullable.Builder(); + return builder.copyOf(this); + } + +} + diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/.openapi-generator/FILES index bc1941bdad50..559ef9c95db3 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/.openapi-generator/FILES @@ -3,8 +3,11 @@ pom.xml src/main/java/org/openapitools/api/ApiUtil.java src/main/java/org/openapitools/api/FileApi.java src/main/java/org/openapitools/api/FooApi.java +src/main/java/org/openapitools/api/RequiredAndNullableApi.java src/main/java/org/openapitools/api/UploadApi.java src/main/java/org/openapitools/api/UploadFilesApi.java src/main/java/org/openapitools/api/package-info.java +src/main/java/org/openapitools/model/FileContent.java src/main/java/org/openapitools/model/Foo.java +src/main/java/org/openapitools/model/RequiredAndNullable.java src/main/java/org/openapitools/model/package-info.java diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/FileApi.java b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/FileApi.java index 0ee298fc93e5..ee8c018556a2 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/FileApi.java +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/FileApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import org.openapitools.model.FileContent; import io.swagger.v3.oas.annotations.ExternalDocumentation; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -52,16 +53,28 @@ default Optional getRequest() { operationId = "fileIdGet", tags = { "file" }, responses = { - @ApiResponse(responseCode = "200", description = "ok") + @ApiResponse(responseCode = "200", description = "ok", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = FileContent.class)) + }) } ) @RequestMapping( method = RequestMethod.GET, - value = FileApi.PATH_FILE_ID_GET + value = FileApi.PATH_FILE_ID_GET, + produces = { "application/json" } ) - default ResponseEntity fileIdGet( + default ResponseEntity fileIdGet( @Parameter(name = "id", description = "", required = true, in = ParameterIn.PATH) @PathVariable("id") String id ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"name\" : \"name\", \"size\" : 0, \"virusScan\" : \"clean\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/RequiredAndNullableApi.java b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..a7057ce15f82 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/api/RequiredAndNullableApi.java @@ -0,0 +1,83 @@ +/* + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.25.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.RequiredAndNullable; +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import jakarta.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +@Validated +@Tag(name = "requiredAndNullable", description = "requiredAndNullable") +public interface RequiredAndNullableApi { + + default Optional getRequest() { + return Optional.empty(); + } + + String PATH_REQUIRED_AND_NULLABLE_POST = "/requiredAndNullable"; + /** + * POST /requiredAndNullable + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return response (status code 200) + */ + @Operation( + operationId = "requiredAndNullablePost", + tags = { "requiredAndNullable" }, + responses = { + @ApiResponse(responseCode = "default", description = "response", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = RequiredAndNullable.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = RequiredAndNullableApi.PATH_REQUIRED_AND_NULLABLE_POST, + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity requiredAndNullablePost( + @Parameter(name = "RequiredAndNullable", description = "bodyWithRequiredAndNullableAttributes", required = true) @Valid @RequestBody RequiredAndNullable requiredAndNullable + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"str\" : \"str\", \"file\" : \"\", \"color\" : \"red\", \"onlyRequired\" : \"onlyRequired\", \"list\" : [ \"list\", \"list\" ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/FileContent.java b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/FileContent.java new file mode 100644 index 000000000000..666e6ffdafb7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/FileContent.java @@ -0,0 +1,274 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.jspecify.annotations.Nullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import io.swagger.v3.oas.annotations.media.Schema; + +import jakarta.xml.bind.annotation.*; + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * FileContent + */ + +@JacksonXmlRootElement(localName = "FileContent") +@XmlRootElement(name = "FileContent") +@XmlAccessorType(XmlAccessType.FIELD) +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + + private String name; + + private Optional size = Optional.empty(); + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN("clean"), + + DETECTED("detected"); + + private final String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private Optional virusScan = Optional.empty(); + + public FileContent() { + super(); + } + + /** + * Constructor with only required parameters + */ + public FileContent(String name) { + this.name = name; + } + + /** + * Constructor with all args parameters + */ + public FileContent(String name, @Nullable Integer size, @Nullable VirusScanEnum virusScan) { + this.name = name; + this.size = Optional.ofNullable(size); + this.virusScan = Optional.ofNullable(virusScan); + } + + public FileContent name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + + @Schema(name = "name", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("name") + @JacksonXmlProperty(localName = "name") + @XmlElement(name = "name") + public String getName() { + return name; + } + + @JsonProperty("name") + @JacksonXmlProperty(localName = "name") + public void setName(String name) { + this.name = name; + } + + public FileContent size(@Nullable Integer size) { + this.size = Optional.ofNullable(size); + return this; + } + + /** + * Get size + * @return size + */ + + @Schema(name = "size", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("size") + @JacksonXmlProperty(localName = "size") + @XmlElement(name = "size") + public Optional getSize() { + return size; + } + + @JsonProperty("size") + @JacksonXmlProperty(localName = "size") + public void setSize(Optional size) { + this.size = size; + } + + public FileContent virusScan(@Nullable VirusScanEnum virusScan) { + this.virusScan = Optional.ofNullable(virusScan); + return this; + } + + /** + * Get virusScan + * @return virusScan + */ + + @Schema(name = "virusScan", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("virusScan") + @JacksonXmlProperty(localName = "virusScan") + @XmlElement(name = "virusScan") + public Optional getVirusScan() { + return virusScan; + } + + @JsonProperty("virusScan") + @JacksonXmlProperty(localName = "virusScan") + public void setVirusScan(Optional virusScan) { + this.virusScan = virusScan; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + protected Builder copyOf(FileContent value) { + this.instance.setName(value.name); + this.instance.setSize(value.size); + this.instance.setVirusScan(value.virusScan); + return this; + } + + public FileContent.Builder name(String name) { + this.instance.name(name); + return this; + } + + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size(size); + return this; + } + + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan(virusScan); + return this; + } + + /** + * returns a built FileContent instance. + * + * The builder is not reusable (NullPointerException) + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field (except for the default values). + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + FileContent.Builder builder = new FileContent.Builder(); + return builder.copyOf(this); + } + +} + diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/Foo.java b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/Foo.java index 53fae78adf9f..3fb4d4b8ada4 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/Foo.java +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/Foo.java @@ -131,7 +131,7 @@ public Foo nullableDt(java.time.@Nullable Instant nullableDt) { * @return nullableDt */ @Valid - @Schema(name = "nullableDt", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableDt", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableDt") @JacksonXmlProperty(localName = "nullableDt") @XmlElement(name = "nullableDt") @@ -177,7 +177,7 @@ public Foo nullableBinary(org.springframework.core.io.@Nullable Resource nullabl * @return nullableBinary */ @Valid - @Schema(name = "nullableBinary", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableBinary", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableBinary") @JacksonXmlProperty(localName = "nullableBinary") @XmlElement(name = "nullableBinary") @@ -263,7 +263,7 @@ public Foo nullableListMinIntems(@Nullable List nullableListM } public Foo addNullableListMinIntemsItem(java.time.Instant nullableListMinIntemsItem) { - if (this.nullableListMinIntems == null || !this.nullableListMinIntems.isPresent()) { + if (this.nullableListMinIntems == null || !this.nullableListMinIntems.isPresent() || this.nullableListMinIntems.get() == null) { this.nullableListMinIntems = JsonNullable.of(new ArrayList<>()); } this.nullableListMinIntems.get().add(nullableListMinIntemsItem); @@ -275,7 +275,7 @@ public Foo addNullableListMinIntemsItem(java.time.Instant nullableListMinIntemsI * @return nullableListMinIntems */ @Valid @Size(min = 1) - @Schema(name = "nullableListMinIntems", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableListMinIntems", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableListMinIntems") @JacksonXmlProperty(localName = "nullableListMinIntems") @JacksonXmlElementWrapper(useWrapping = false) @@ -346,7 +346,7 @@ public Foo nullableNumber(java.math.@Nullable BigDecimal nullableNumber) { * @return nullableNumber */ @Valid - @Schema(name = "nullableNumber", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableNumber", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableNumber") @JacksonXmlProperty(localName = "nullableNumber") @XmlElement(name = "nullableNumber") @@ -416,7 +416,7 @@ public Foo nullableColor(@Nullable String nullableColor) { * @return nullableColor */ - @Schema(name = "nullableColor", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableColor", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableColor") @JacksonXmlProperty(localName = "nullableColor") @XmlElement(name = "nullableColor") diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/RequiredAndNullable.java b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/RequiredAndNullable.java new file mode 100644 index 000000000000..3db95fb22627 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify-useOptional/src/main/java/org/openapitools/model/RequiredAndNullable.java @@ -0,0 +1,334 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import io.swagger.v3.oas.annotations.media.Schema; + +import jakarta.xml.bind.annotation.*; + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * RequiredAndNullable + */ + +@JacksonXmlRootElement(localName = "RequiredAndNullable") +@XmlRootElement(name = "RequiredAndNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + + private JsonNullable str = JsonNullable.undefined(); + + private JsonNullable file = JsonNullable.undefined(); + + private JsonNullable color = JsonNullable.undefined(); + + private String onlyRequired; + + private JsonNullable> _list = JsonNullable.>undefined(); + + public RequiredAndNullable() { + super(); + } + + /** + * Constructor with only required parameters and all parameters + */ + public RequiredAndNullable(@Nullable String str, org.springframework.core.io.@Nullable Resource file, @Nullable String color, String onlyRequired, @Nullable List _list) { + this.str = JsonNullable.of(str); + this.file = JsonNullable.of(file); + this.color = JsonNullable.of(color); + this.onlyRequired = onlyRequired; + this._list = JsonNullable.of(_list); + } + + public RequiredAndNullable str(@Nullable String str) { + this.str = JsonNullable.of(str); + return this; + } + + /** + * Get str + * @return str + */ + /* @Present */ + @Schema(name = "str", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("str") + @JacksonXmlProperty(localName = "str") + @XmlElement(name = "str") + public JsonNullable getStr() { + return str; + } + + @JsonProperty("str") + @JacksonXmlProperty(localName = "str") + public void setStr(JsonNullable str) { + this.str = str; + } + + public RequiredAndNullable file(org.springframework.core.io.@Nullable Resource file) { + this.file = JsonNullable.of(file); + return this; + } + + /** + * Get file + * @return file + */ + /* @Present */ @Valid + @Schema(name = "file", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("file") + @JacksonXmlProperty(localName = "file") + @XmlElement(name = "file") + public JsonNullable getFile() { + return file; + } + + @JsonProperty("file") + @JacksonXmlProperty(localName = "file") + public void setFile(JsonNullable file) { + this.file = file; + } + + public RequiredAndNullable color(@Nullable String color) { + this.color = JsonNullable.of(color); + return this; + } + + /** + * Get color + * @return color + */ + /* @Present */ + @Schema(name = "color", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("color") + @JacksonXmlProperty(localName = "color") + @XmlElement(name = "color") + public JsonNullable getColor() { + return color; + } + + @JsonProperty("color") + @JacksonXmlProperty(localName = "color") + public void setColor(JsonNullable color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + @NotNull + @Schema(name = "onlyRequired", requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("onlyRequired") + @JacksonXmlProperty(localName = "onlyRequired") + @XmlElement(name = "onlyRequired") + public String getOnlyRequired() { + return onlyRequired; + } + + @JsonProperty("onlyRequired") + @JacksonXmlProperty(localName = "onlyRequired") + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + this._list = JsonNullable.of(_list); + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null || !this._list.isPresent() || this._list.get() == null) { + this._list = JsonNullable.of(new ArrayList<>()); + } + this._list.get().add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + /* @Present */ + @Schema(name = "list", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("list") + @JacksonXmlProperty(localName = "list") + @JacksonXmlElementWrapper(useWrapping = false) + @XmlElement(name = "list") + public JsonNullable> getList() { + return _list; + } + + @JsonProperty("list") + @JacksonXmlProperty(localName = "list") + @JacksonXmlElementWrapper(useWrapping = false) + public void setList(JsonNullable> _list) { + this._list = _list; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this.file, requiredAndNullable.file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + protected Builder copyOf(RequiredAndNullable value) { + this.instance.setStr(value.str); + this.instance.setFile(value.file); + this.instance.setColor(value.color); + this.instance.setOnlyRequired(value.onlyRequired); + this.instance.setList(value._list); + return this; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str(str); + return this; + } + + public RequiredAndNullable.Builder str(JsonNullable str) { + this.instance.str = str; + return this; + } + + public RequiredAndNullable.Builder file(org.springframework.core.io.@Nullable Resource file) { + this.instance.file(file); + return this; + } + + public RequiredAndNullable.Builder file(JsonNullable file) { + this.instance.file = file; + return this; + } + + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color(color); + return this; + } + + public RequiredAndNullable.Builder color(JsonNullable color) { + this.instance.color = color; + return this; + } + + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired(onlyRequired); + return this; + } + + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list(_list); + return this; + } + + public RequiredAndNullable.Builder _list(JsonNullable> _list) { + this.instance._list = _list; + return this; + } + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable (NullPointerException) + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field (except for the default values). + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + RequiredAndNullable.Builder builder = new RequiredAndNullable.Builder(); + return builder.copyOf(this); + } + +} + diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-4-jspecify/.openapi-generator/FILES index bc1941bdad50..559ef9c95db3 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/.openapi-generator/FILES @@ -3,8 +3,11 @@ pom.xml src/main/java/org/openapitools/api/ApiUtil.java src/main/java/org/openapitools/api/FileApi.java src/main/java/org/openapitools/api/FooApi.java +src/main/java/org/openapitools/api/RequiredAndNullableApi.java src/main/java/org/openapitools/api/UploadApi.java src/main/java/org/openapitools/api/UploadFilesApi.java src/main/java/org/openapitools/api/package-info.java +src/main/java/org/openapitools/model/FileContent.java src/main/java/org/openapitools/model/Foo.java +src/main/java/org/openapitools/model/RequiredAndNullable.java src/main/java/org/openapitools/model/package-info.java diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/FileApi.java b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/FileApi.java index 0ee298fc93e5..ee8c018556a2 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/FileApi.java +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/FileApi.java @@ -5,6 +5,7 @@ */ package org.openapitools.api; +import org.openapitools.model.FileContent; import io.swagger.v3.oas.annotations.ExternalDocumentation; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -52,16 +53,28 @@ default Optional getRequest() { operationId = "fileIdGet", tags = { "file" }, responses = { - @ApiResponse(responseCode = "200", description = "ok") + @ApiResponse(responseCode = "200", description = "ok", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = FileContent.class)) + }) } ) @RequestMapping( method = RequestMethod.GET, - value = FileApi.PATH_FILE_ID_GET + value = FileApi.PATH_FILE_ID_GET, + produces = { "application/json" } ) - default ResponseEntity fileIdGet( + default ResponseEntity fileIdGet( @Parameter(name = "id", description = "", required = true, in = ParameterIn.PATH) @PathVariable("id") String id ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"name\" : \"name\", \"size\" : 0, \"virusScan\" : \"clean\" }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/RequiredAndNullableApi.java b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/RequiredAndNullableApi.java new file mode 100644 index 000000000000..a7057ce15f82 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/api/RequiredAndNullableApi.java @@ -0,0 +1,83 @@ +/* + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.25.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.RequiredAndNullable; +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import jakarta.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +@Validated +@Tag(name = "requiredAndNullable", description = "requiredAndNullable") +public interface RequiredAndNullableApi { + + default Optional getRequest() { + return Optional.empty(); + } + + String PATH_REQUIRED_AND_NULLABLE_POST = "/requiredAndNullable"; + /** + * POST /requiredAndNullable + * + * @param requiredAndNullable bodyWithRequiredAndNullableAttributes (required) + * @return response (status code 200) + */ + @Operation( + operationId = "requiredAndNullablePost", + tags = { "requiredAndNullable" }, + responses = { + @ApiResponse(responseCode = "default", description = "response", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = RequiredAndNullable.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = RequiredAndNullableApi.PATH_REQUIRED_AND_NULLABLE_POST, + produces = { "application/json" }, + consumes = { "application/json" } + ) + default ResponseEntity requiredAndNullablePost( + @Parameter(name = "RequiredAndNullable", description = "bodyWithRequiredAndNullableAttributes", required = true) @Valid @RequestBody RequiredAndNullable requiredAndNullable + ) { + getRequest().ifPresent(request -> { + for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + String exampleString = "{ \"str\" : \"str\", \"file\" : \"\", \"color\" : \"red\", \"onlyRequired\" : \"onlyRequired\", \"list\" : [ \"list\", \"list\" ] }"; + ApiUtil.setExampleResponse(request, "application/json", exampleString); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/FileContent.java b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/FileContent.java new file mode 100644 index 000000000000..7b0f652e20c6 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/FileContent.java @@ -0,0 +1,281 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.Nulls; +import org.jspecify.annotations.Nullable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import io.swagger.v3.oas.annotations.media.Schema; + +import jakarta.xml.bind.annotation.*; + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * FileContent + */ + +@JacksonXmlRootElement(localName = "FileContent") +@XmlRootElement(name = "FileContent") +@XmlAccessorType(XmlAccessType.FIELD) +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class FileContent { + + @JsonInclude(JsonInclude.Include.NON_NULL) + private String name; + + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSetter(nulls = Nulls.SKIP) + private @Nullable Integer size; + + /** + * Gets or Sets virusScan + */ + public enum VirusScanEnum { + CLEAN("clean"), + + DETECTED("detected"); + + private final String value; + + VirusScanEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VirusScanEnum fromValue(String value) { + for (VirusScanEnum b : VirusScanEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSetter(nulls = Nulls.SKIP) + private @Nullable VirusScanEnum virusScan; + + public FileContent() { + super(); + } + + /** + * Constructor with only required parameters + */ + public FileContent(String name) { + this.name = name; + } + + /** + * Constructor with all args parameters + */ + public FileContent(String name, @Nullable Integer size, @Nullable VirusScanEnum virusScan) { + this.name = name; + this.size = size; + this.virusScan = virusScan; + } + + public FileContent name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + */ + + @Schema(name = "name", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("name") + @JacksonXmlProperty(localName = "name") + @XmlElement(name = "name") + public String getName() { + return name; + } + + @JsonProperty("name") + @JacksonXmlProperty(localName = "name") + public void setName(String name) { + this.name = name; + } + + public FileContent size(@Nullable Integer size) { + this.size = size; + return this; + } + + /** + * Get size + * @return size + */ + + @Schema(name = "size", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("size") + @JacksonXmlProperty(localName = "size") + @XmlElement(name = "size") + public @Nullable Integer getSize() { + return size; + } + + @JsonProperty("size") + @JacksonXmlProperty(localName = "size") + public void setSize(@Nullable Integer size) { + this.size = size; + } + + public FileContent virusScan(@Nullable VirusScanEnum virusScan) { + this.virusScan = virusScan; + return this; + } + + /** + * Get virusScan + * @return virusScan + */ + + @Schema(name = "virusScan", accessMode = Schema.AccessMode.READ_ONLY, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("virusScan") + @JacksonXmlProperty(localName = "virusScan") + @XmlElement(name = "virusScan") + public @Nullable VirusScanEnum getVirusScan() { + return virusScan; + } + + @JsonProperty("virusScan") + @JacksonXmlProperty(localName = "virusScan") + public void setVirusScan(@Nullable VirusScanEnum virusScan) { + this.virusScan = virusScan; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileContent fileContent = (FileContent) o; + return Objects.equals(this.name, fileContent.name) && + Objects.equals(this.size, fileContent.size) && + Objects.equals(this.virusScan, fileContent.virusScan); + } + + @Override + public int hashCode() { + return Objects.hash(name, size, virusScan); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FileContent {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" virusScan: ").append(toIndentedString(virusScan)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private FileContent instance; + + public Builder() { + this(new FileContent()); + } + + protected Builder(FileContent instance) { + this.instance = instance; + } + + protected Builder copyOf(FileContent value) { + this.instance.setName(value.name); + this.instance.setSize(value.size); + this.instance.setVirusScan(value.virusScan); + return this; + } + + public FileContent.Builder name(String name) { + this.instance.name(name); + return this; + } + + public FileContent.Builder size(@Nullable Integer size) { + this.instance.size(size); + return this; + } + + public FileContent.Builder virusScan(@Nullable VirusScanEnum virusScan) { + this.instance.virusScan(virusScan); + return this; + } + + /** + * returns a built FileContent instance. + * + * The builder is not reusable (NullPointerException) + */ + public FileContent build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field (except for the default values). + */ + public static FileContent.Builder builder() { + return new FileContent.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public FileContent.Builder toBuilder() { + FileContent.Builder builder = new FileContent.Builder(); + return builder.copyOf(this); + } + +} + diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/Foo.java b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/Foo.java index 41b025136ba6..5977f48d0055 100644 --- a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/Foo.java +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/Foo.java @@ -145,7 +145,7 @@ public Foo nullableDt(java.time.@Nullable Instant nullableDt) { * @return nullableDt */ @Valid - @Schema(name = "nullableDt", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableDt", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableDt") @JacksonXmlProperty(localName = "nullableDt") @XmlElement(name = "nullableDt") @@ -193,7 +193,7 @@ public Foo nullableBinary(org.springframework.core.io.@Nullable Resource nullabl * @return nullableBinary */ @Valid - @Schema(name = "nullableBinary", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableBinary", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableBinary") @JacksonXmlProperty(localName = "nullableBinary") @XmlElement(name = "nullableBinary") @@ -293,7 +293,7 @@ public Foo addNullableListMinIntemsItem(java.time.Instant nullableListMinIntemsI * @return nullableListMinIntems */ @Valid @Size(min = 1) - @Schema(name = "nullableListMinIntems", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableListMinIntems", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableListMinIntems") @JacksonXmlProperty(localName = "nullableListMinIntems") @JacksonXmlElementWrapper(useWrapping = false) @@ -367,7 +367,7 @@ public Foo nullableNumber(java.math.@Nullable BigDecimal nullableNumber) { * @return nullableNumber */ @Valid - @Schema(name = "nullableNumber", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableNumber", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableNumber") @JacksonXmlProperty(localName = "nullableNumber") @XmlElement(name = "nullableNumber") @@ -439,7 +439,7 @@ public Foo nullableColor(@Nullable String nullableColor) { * @return nullableColor */ - @Schema(name = "nullableColor", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableColor", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableColor") @JacksonXmlProperty(localName = "nullableColor") @XmlElement(name = "nullableColor") diff --git a/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/RequiredAndNullable.java b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/RequiredAndNullable.java new file mode 100644 index 000000000000..1629985f9c71 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/RequiredAndNullable.java @@ -0,0 +1,319 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.jspecify.annotations.Nullable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import io.swagger.v3.oas.annotations.media.Schema; + +import jakarta.xml.bind.annotation.*; + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * RequiredAndNullable + */ + +@JacksonXmlRootElement(localName = "RequiredAndNullable") +@XmlRootElement(name = "RequiredAndNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.25.0-SNAPSHOT") +public class RequiredAndNullable { + + @JsonInclude(JsonInclude.Include.ALWAYS) + private @Nullable String str = null; + + @JsonInclude(JsonInclude.Include.ALWAYS) + private org.springframework.core.io.@Nullable Resource file = null; + + @JsonInclude(JsonInclude.Include.ALWAYS) + private @Nullable String color = null; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private String onlyRequired; + + @JsonInclude(JsonInclude.Include.ALWAYS) + private @Nullable List _list; + + public RequiredAndNullable() { + super(); + } + + /** + * Constructor with only required parameters and all parameters + */ + public RequiredAndNullable(@Nullable String str, org.springframework.core.io.@Nullable Resource file, @Nullable String color, String onlyRequired, @Nullable List _list) { + this.str = str; + this.file = file; + this.color = color; + this.onlyRequired = onlyRequired; + this._list = _list; + } + + public RequiredAndNullable str(@Nullable String str) { + this.str = str; + return this; + } + + /** + * Get str + * @return str + */ + + @Schema(name = "str", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("str") + @JacksonXmlProperty(localName = "str") + @XmlElement(name = "str") + public @Nullable String getStr() { + return str; + } + + @JsonProperty("str") + @JacksonXmlProperty(localName = "str") + public void setStr(@Nullable String str) { + this.str = str; + } + + public RequiredAndNullable file(org.springframework.core.io.@Nullable Resource file) { + this.file = file; + return this; + } + + /** + * Get file + * @return file + */ + @Valid + @Schema(name = "file", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("file") + @JacksonXmlProperty(localName = "file") + @XmlElement(name = "file") + public org.springframework.core.io.@Nullable Resource getFile() { + return file; + } + + @JsonProperty("file") + @JacksonXmlProperty(localName = "file") + public void setFile(org.springframework.core.io.@Nullable Resource file) { + this.file = file; + } + + public RequiredAndNullable color(@Nullable String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + */ + + @Schema(name = "color", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("color") + @JacksonXmlProperty(localName = "color") + @XmlElement(name = "color") + public @Nullable String getColor() { + return color; + } + + @JsonProperty("color") + @JacksonXmlProperty(localName = "color") + public void setColor(@Nullable String color) { + this.color = color; + } + + public RequiredAndNullable onlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + return this; + } + + /** + * Get onlyRequired + * @return onlyRequired + */ + @NotNull + @Schema(name = "onlyRequired", requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("onlyRequired") + @JacksonXmlProperty(localName = "onlyRequired") + @XmlElement(name = "onlyRequired") + public String getOnlyRequired() { + return onlyRequired; + } + + @JsonProperty("onlyRequired") + @JacksonXmlProperty(localName = "onlyRequired") + public void setOnlyRequired(String onlyRequired) { + this.onlyRequired = onlyRequired; + } + + public RequiredAndNullable _list(@Nullable List _list) { + this._list = _list; + return this; + } + + public RequiredAndNullable addListItem(String _listItem) { + if (this._list == null) { + this._list = new ArrayList<>(); + } + this._list.add(_listItem); + return this; + } + + /** + * Get _list + * @return _list + */ + + @Schema(name = "list", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) + @JsonProperty("list") + @JacksonXmlProperty(localName = "list") + @JacksonXmlElementWrapper(useWrapping = false) + @XmlElement(name = "list") + public @Nullable List getList() { + return _list; + } + + @JsonProperty("list") + @JacksonXmlProperty(localName = "list") + @JacksonXmlElementWrapper(useWrapping = false) + public void setList(@Nullable List _list) { + this._list = _list; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequiredAndNullable requiredAndNullable = (RequiredAndNullable) o; + return Objects.equals(this.str, requiredAndNullable.str) && + Objects.equals(this.file, requiredAndNullable.file) && + Objects.equals(this.color, requiredAndNullable.color) && + Objects.equals(this.onlyRequired, requiredAndNullable.onlyRequired) && + Objects.equals(this._list, requiredAndNullable._list); + } + + @Override + public int hashCode() { + return Objects.hash(str, file, color, onlyRequired, _list); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequiredAndNullable {\n"); + sb.append(" str: ").append(toIndentedString(str)).append("\n"); + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" onlyRequired: ").append(toIndentedString(onlyRequired)).append("\n"); + sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } + + public static class Builder { + + private RequiredAndNullable instance; + + public Builder() { + this(new RequiredAndNullable()); + } + + protected Builder(RequiredAndNullable instance) { + this.instance = instance; + } + + protected Builder copyOf(RequiredAndNullable value) { + this.instance.setStr(value.str); + this.instance.setFile(value.file); + this.instance.setColor(value.color); + this.instance.setOnlyRequired(value.onlyRequired); + this.instance.setList(value._list); + return this; + } + + public RequiredAndNullable.Builder str(@Nullable String str) { + this.instance.str(str); + return this; + } + + public RequiredAndNullable.Builder file(org.springframework.core.io.@Nullable Resource file) { + this.instance.file(file); + return this; + } + + public RequiredAndNullable.Builder color(@Nullable String color) { + this.instance.color(color); + return this; + } + + public RequiredAndNullable.Builder onlyRequired(String onlyRequired) { + this.instance.onlyRequired(onlyRequired); + return this; + } + + public RequiredAndNullable.Builder _list(@Nullable List _list) { + this.instance._list(_list); + return this; + } + + /** + * returns a built RequiredAndNullable instance. + * + * The builder is not reusable (NullPointerException) + */ + public RequiredAndNullable build() { + try { + return this.instance; + } finally { + // ensure that this.instance is not reused + this.instance = null; + } + } + + @Override + public String toString() { + return getClass() + "=(" + instance + ")"; + } + } + + /** + * Create a builder with no initialized field (except for the default values). + */ + public static RequiredAndNullable.Builder builder() { + return new RequiredAndNullable.Builder(); + } + + /** + * Create a builder with a shallow copy of this instance. + */ + public RequiredAndNullable.Builder toBuilder() { + RequiredAndNullable.Builder builder = new RequiredAndNullable.Builder(); + return builder.copyOf(this); + } + +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledExcp/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/spring-boot-nullable-set/src/main/java/org/openapitools/model/ObjectWithUniqueItems.java b/samples/server/petstore/spring-boot-nullable-set/src/main/java/org/openapitools/model/ObjectWithUniqueItems.java index 430f680158d4..30bff5f61534 100644 --- a/samples/server/petstore/spring-boot-nullable-set/src/main/java/org/openapitools/model/ObjectWithUniqueItems.java +++ b/samples/server/petstore/spring-boot-nullable-set/src/main/java/org/openapitools/model/ObjectWithUniqueItems.java @@ -57,7 +57,7 @@ public ObjectWithUniqueItems nullSet(Set nullSet) { } public ObjectWithUniqueItems addNullSetItem(String nullSetItem) { - if (this.nullSet == null || !this.nullSet.isPresent()) { + if (this.nullSet == null || !this.nullSet.isPresent() || this.nullSet.get() == null) { this.nullSet = JsonNullable.of(new LinkedHashSet<>()); } this.nullSet.get().add(nullSetItem); @@ -69,7 +69,7 @@ public ObjectWithUniqueItems addNullSetItem(String nullSetItem) { * @return nullSet */ - @Schema(name = "nullSet", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullSet", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullSet") public JsonNullable> getNullSet() { return nullSet; @@ -115,7 +115,7 @@ public ObjectWithUniqueItems nullList(List nullList) { } public ObjectWithUniqueItems addNullListItem(String nullListItem) { - if (this.nullList == null || !this.nullList.isPresent()) { + if (this.nullList == null || !this.nullList.isPresent() || this.nullList.get() == null) { this.nullList = JsonNullable.of(new ArrayList<>()); } this.nullList.get().add(nullListItem); @@ -127,7 +127,7 @@ public ObjectWithUniqueItems addNullListItem(String nullListItem) { * @return nullList */ - @Schema(name = "nullList", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullList", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullList") public JsonNullable> getNullList() { return nullList; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index 8c8fef587001..047b517697a9 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -333,7 +333,7 @@ public AdditionalPropertiesClass anytype2(@Nullable Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public @Nullable Object getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 6674c88a2e4f..d662c38a4a75 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -65,7 +65,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public @Nullable List getNullableArray() { return nullableArray; @@ -93,8 +93,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public List getNullableRequiredArray() { return nullableRequiredArray; @@ -152,7 +152,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public @Nullable List getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NullableMapProperty.java index 855c53622446..0c9a62ab9578 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -43,7 +43,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public @Nullable Map getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java index 032a06cb2a2b..069e175455ce 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -107,7 +107,7 @@ public ParentWithNullable nullableProperty(@Nullable String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public @Nullable String getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-builtin-validation/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index 32023ee3da1e..8f54cd848b67 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -346,7 +346,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java index b6557ceff4e9..ce39cfc4f753 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -66,7 +66,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -78,7 +78,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -94,7 +94,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -105,8 +105,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -152,7 +152,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -164,7 +164,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java index e2ceeea637fe..3db7f9296c5b 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -46,7 +46,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -58,7 +58,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java index 50c34a0c9121..dfa072f98090 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -120,7 +120,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index 3f6cf5af234f..d8c6725ed27c 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 1e996c854efe..b7d3d6d42d75 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java index 56d45c3ad292..71380912bcc1 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java index af16949486cc..75408c9a5421 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java index 9ea7f74985a9..4b738ea3239f 100644 --- a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java +++ b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java @@ -327,7 +327,7 @@ public AdditionalPropertiesClassDto anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java index 2bc02f7a7cc3..6c8f9274fcdf 100644 --- a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java +++ b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -58,7 +58,7 @@ public ContainerDefaultValueDto nullableArray(List nullableArray) { } public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -70,7 +70,7 @@ public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -86,7 +86,7 @@ public ContainerDefaultValueDto nullableRequiredArray(List nullableRequi } public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -97,8 +97,8 @@ public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequ * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -144,7 +144,7 @@ public ContainerDefaultValueDto nullableArrayWithDefault(List nullableAr } public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -156,7 +156,7 @@ public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableA * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/NullableMapPropertyDto.java b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/NullableMapPropertyDto.java index 98ba228cdc9b..6f63407a6d66 100644 --- a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/NullableMapPropertyDto.java +++ b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/NullableMapPropertyDto.java @@ -37,7 +37,7 @@ public NullableMapPropertyDto languageValues(Map languageValues) } public NullableMapPropertyDto putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -49,7 +49,7 @@ public NullableMapPropertyDto putLanguageValuesItem(String key, String languageV * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ParentWithNullableDto.java index 982f8d038258..213234e9599f 100644 --- a/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ParentWithNullableDto.java +++ b/samples/server/petstore/springboot-include-http-request-context/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -109,7 +109,7 @@ public ParentWithNullableDto nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java index fc4f770ac1d9..4105491f50a1 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java index a51bd99c90fc..2828ceb3a770 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java index 31127013b739..1e54ce87a90f 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java index d394b3e38431..dd5243a5203a 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java index e6fa1ccea8b4..dfaee4afe5db 100644 --- a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java +++ b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java @@ -80,7 +80,7 @@ public NullableModel requiredNullable(String requiredNullable) { * Get requiredNullable * @return requiredNullable */ - @NotNull + /* @Present */ @JsonProperty("requiredNullable") public JsonNullable getRequiredNullable() { return requiredNullable; 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 f28336e48905..0bc3c35c6272 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 @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ContainerDefaultValue.java index 89a4873f502e..a023236fb245 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NullableMapProperty.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NullableMapProperty.java index 1c8b66beb4e6..199467adfb4a 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; 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 db85e72833c9..2258fe6d6c95 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 @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/AdditionalPropertiesClass.java index 51f8239e6287..283ef0c9edf8 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/AdditionalPropertiesClass.java @@ -325,7 +325,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ContainerDefaultValue.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ContainerDefaultValue.java index 2bd4f51c4140..6c4935f5803c 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ContainerDefaultValue.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ContainerDefaultValue.java @@ -56,7 +56,7 @@ public ContainerDefaultValue nullableArray(List nullableArray) { } public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -68,7 +68,7 @@ public ContainerDefaultValue addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -84,7 +84,7 @@ public ContainerDefaultValue nullableRequiredArray(List nullableRequired } public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -95,8 +95,8 @@ public ContainerDefaultValue addNullableRequiredArrayItem(String nullableRequire * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -142,7 +142,7 @@ public ContainerDefaultValue nullableArrayWithDefault(List nullableArray } public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -154,7 +154,7 @@ public ContainerDefaultValue addNullableArrayWithDefaultItem(String nullableArra * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/NullableMapProperty.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/NullableMapProperty.java index fc013fe70f4c..64a065bae769 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/NullableMapProperty.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/NullableMapProperty.java @@ -35,7 +35,7 @@ public NullableMapProperty languageValues(Map languageValues) { } public NullableMapProperty putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -47,7 +47,7 @@ public NullableMapProperty putLanguageValuesItem(String key, String languageValu * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java index bb28729decdd..c8ccf5a155c1 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java @@ -108,7 +108,7 @@ public ParentWithNullable nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/EnumTestDto.java b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/EnumTestDto.java index 1576c5046e33..4b646de3b597 100644 --- a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/EnumTestDto.java +++ b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/EnumTestDto.java @@ -305,7 +305,7 @@ public EnumTestDto outerEnum(OuterEnumDto outerEnum) { * @return outerEnum */ @Valid - @Schema(name = "outerEnum", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "outerEnum", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("outerEnum") public JsonNullable getOuterEnum() { return outerEnum; diff --git a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/HealthCheckResultDto.java b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/HealthCheckResultDto.java index ac09a0a9834b..edb49de12b67 100644 --- a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/HealthCheckResultDto.java +++ b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/HealthCheckResultDto.java @@ -40,7 +40,7 @@ public HealthCheckResultDto nullableMessage(String nullableMessage) { * @return nullableMessage */ - @Schema(name = "NullableMessage", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "NullableMessage", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("NullableMessage") public JsonNullable getNullableMessage() { return nullableMessage; diff --git a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/NullableClassDto.java b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/NullableClassDto.java index 55fe5702be7f..8631a088be7f 100644 --- a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/NullableClassDto.java +++ b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/NullableClassDto.java @@ -78,7 +78,7 @@ public NullableClassDto integerProp(Integer integerProp) { * @return integerProp */ - @Schema(name = "integer_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "integer_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("integer_prop") public JsonNullable getIntegerProp() { return integerProp; @@ -98,7 +98,7 @@ public NullableClassDto numberProp(BigDecimal numberProp) { * @return numberProp */ @Valid - @Schema(name = "number_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "number_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("number_prop") public JsonNullable getNumberProp() { return numberProp; @@ -118,7 +118,7 @@ public NullableClassDto booleanProp(Boolean booleanProp) { * @return booleanProp */ - @Schema(name = "boolean_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "boolean_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("boolean_prop") public JsonNullable getBooleanProp() { return booleanProp; @@ -138,7 +138,7 @@ public NullableClassDto stringProp(String stringProp) { * @return stringProp */ - @Schema(name = "string_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "string_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("string_prop") public JsonNullable getStringProp() { return stringProp; @@ -158,7 +158,7 @@ public NullableClassDto dateProp(LocalDate dateProp) { * @return dateProp */ @Valid - @Schema(name = "date_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "date_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("date_prop") public JsonNullable getDateProp() { return dateProp; @@ -178,7 +178,7 @@ public NullableClassDto datetimeProp(OffsetDateTime datetimeProp) { * @return datetimeProp */ @Valid - @Schema(name = "datetime_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "datetime_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("datetime_prop") public JsonNullable getDatetimeProp() { return datetimeProp; @@ -194,7 +194,7 @@ public NullableClassDto arrayNullableProp(List arrayNullableProp) { } public NullableClassDto addArrayNullablePropItem(Object arrayNullablePropItem) { - if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent()) { + if (this.arrayNullableProp == null || !this.arrayNullableProp.isPresent() || this.arrayNullableProp.get() == null) { this.arrayNullableProp = JsonNullable.of(new ArrayList<>()); } this.arrayNullableProp.get().add(arrayNullablePropItem); @@ -206,7 +206,7 @@ public NullableClassDto addArrayNullablePropItem(Object arrayNullablePropItem) { * @return arrayNullableProp */ - @Schema(name = "array_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "array_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("array_nullable_prop") public JsonNullable> getArrayNullableProp() { return arrayNullableProp; @@ -222,7 +222,7 @@ public NullableClassDto arrayAndItemsNullableProp(List arrayAndItemsNull } public NullableClassDto addArrayAndItemsNullablePropItem(Object arrayAndItemsNullablePropItem) { - if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent()) { + if (this.arrayAndItemsNullableProp == null || !this.arrayAndItemsNullableProp.isPresent() || this.arrayAndItemsNullableProp.get() == null) { this.arrayAndItemsNullableProp = JsonNullable.of(new ArrayList<>()); } this.arrayAndItemsNullableProp.get().add(arrayAndItemsNullablePropItem); @@ -234,7 +234,7 @@ public NullableClassDto addArrayAndItemsNullablePropItem(Object arrayAndItemsNul * @return arrayAndItemsNullableProp */ - @Schema(name = "array_and_items_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "array_and_items_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("array_and_items_nullable_prop") public JsonNullable> getArrayAndItemsNullableProp() { return arrayAndItemsNullableProp; @@ -279,7 +279,7 @@ public NullableClassDto objectNullableProp(Map objectNullablePro } public NullableClassDto putObjectNullablePropItem(String key, Object objectNullablePropItem) { - if (this.objectNullableProp == null || !this.objectNullableProp.isPresent()) { + if (this.objectNullableProp == null || !this.objectNullableProp.isPresent() || this.objectNullableProp.get() == null) { this.objectNullableProp = JsonNullable.of(new HashMap<>()); } this.objectNullableProp.get().put(key, objectNullablePropItem); @@ -291,7 +291,7 @@ public NullableClassDto putObjectNullablePropItem(String key, Object objectNulla * @return objectNullableProp */ - @Schema(name = "object_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "object_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("object_nullable_prop") public JsonNullable> getObjectNullableProp() { return objectNullableProp; @@ -307,7 +307,7 @@ public NullableClassDto objectAndItemsNullableProp(Map objectAnd } public NullableClassDto putObjectAndItemsNullablePropItem(String key, Object objectAndItemsNullablePropItem) { - if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent()) { + if (this.objectAndItemsNullableProp == null || !this.objectAndItemsNullableProp.isPresent() || this.objectAndItemsNullableProp.get() == null) { this.objectAndItemsNullableProp = JsonNullable.of(new HashMap<>()); } this.objectAndItemsNullableProp.get().put(key, objectAndItemsNullablePropItem); @@ -319,7 +319,7 @@ public NullableClassDto putObjectAndItemsNullablePropItem(String key, Object obj * @return objectAndItemsNullableProp */ - @Schema(name = "object_and_items_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "object_and_items_nullable_prop", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("object_and_items_nullable_prop") public JsonNullable> getObjectAndItemsNullableProp() { return objectAndItemsNullableProp; diff --git a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/ParentWithNullableDto.java index 982f8d038258..213234e9599f 100644 --- a/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/ParentWithNullableDto.java +++ b/samples/server/petstore/springboot-x-implements-skip/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -109,7 +109,7 @@ public ParentWithNullableDto nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java index 3115be7ad0b3..54a246e65c81 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AdditionalPropertiesClassDto.java @@ -327,7 +327,7 @@ public AdditionalPropertiesClassDto anytype2(Object anytype2) { * @return anytype2 */ - @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "anytype_2", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("anytype_2") public JsonNullable getAnytype2() { return anytype2; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java index 39f4e40b9ba0..ba50a4de0576 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -58,7 +58,7 @@ public ContainerDefaultValueDto nullableArray(List nullableArray) { } public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { - if (this.nullableArray == null || !this.nullableArray.isPresent()) { + if (this.nullableArray == null || !this.nullableArray.isPresent() || this.nullableArray.get() == null) { this.nullableArray = JsonNullable.of(new ArrayList<>()); } this.nullableArray.get().add(nullableArrayItem); @@ -70,7 +70,7 @@ public ContainerDefaultValueDto addNullableArrayItem(String nullableArrayItem) { * @return nullableArray */ - @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array") public JsonNullable> getNullableArray() { return nullableArray; @@ -86,7 +86,7 @@ public ContainerDefaultValueDto nullableRequiredArray(List nullableRequi } public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequiredArrayItem) { - if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent()) { + if (this.nullableRequiredArray == null || !this.nullableRequiredArray.isPresent() || this.nullableRequiredArray.get() == null) { this.nullableRequiredArray = JsonNullable.of(new ArrayList<>()); } this.nullableRequiredArray.get().add(nullableRequiredArrayItem); @@ -97,8 +97,8 @@ public ContainerDefaultValueDto addNullableRequiredArrayItem(String nullableRequ * Get nullableRequiredArray * @return nullableRequiredArray */ - @NotNull - @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED) + /* @Present */ + @Schema(name = "nullable_required_array", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true) @JsonProperty("nullable_required_array") public JsonNullable> getNullableRequiredArray() { return nullableRequiredArray; @@ -144,7 +144,7 @@ public ContainerDefaultValueDto nullableArrayWithDefault(List nullableAr } public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableArrayWithDefaultItem) { - if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent()) { + if (this.nullableArrayWithDefault == null || !this.nullableArrayWithDefault.isPresent() || this.nullableArrayWithDefault.get() == null) { this.nullableArrayWithDefault = JsonNullable.of(new ArrayList<>(Arrays.asList("foo", "bar"))); } this.nullableArrayWithDefault.get().add(nullableArrayWithDefaultItem); @@ -156,7 +156,7 @@ public ContainerDefaultValueDto addNullableArrayWithDefaultItem(String nullableA * @return nullableArrayWithDefault */ - @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullable_array_with_default", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullable_array_with_default") public JsonNullable> getNullableArrayWithDefault() { return nullableArrayWithDefault; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/NullableMapPropertyDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/NullableMapPropertyDto.java index 50958c247610..0e002790e407 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/NullableMapPropertyDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/NullableMapPropertyDto.java @@ -37,7 +37,7 @@ public NullableMapPropertyDto languageValues(Map languageValues) } public NullableMapPropertyDto putLanguageValuesItem(String key, String languageValuesItem) { - if (this.languageValues == null || !this.languageValues.isPresent()) { + if (this.languageValues == null || !this.languageValues.isPresent() || this.languageValues.get() == null) { this.languageValues = JsonNullable.of(new HashMap<>()); } this.languageValues.get().put(key, languageValuesItem); @@ -49,7 +49,7 @@ public NullableMapPropertyDto putLanguageValuesItem(String key, String languageV * @return languageValues */ - @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "languageValues", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("languageValues") public JsonNullable> getLanguageValues() { return languageValues; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java index af2b3803d750..590d7f63bc93 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -110,7 +110,7 @@ public ParentWithNullableDto nullableProperty(String nullableProperty) { * @return nullableProperty */ - @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true) @JsonProperty("nullableProperty") public JsonNullable getNullableProperty() { return nullableProperty;