From d6695056fe17fb7e0d4ff8b5b2d963e30e479a6f Mon Sep 17 00:00:00 2001 From: martin-mfg <2026226+martin-mfg@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:59:58 +0200 Subject: [PATCH] add test case for nullable parent property (#16552) * add nullable case to spring test spec * generate samples for changed spring input * add nullable case to general test spec * generate samples for changed general input * generate samples again * generates samples again * re-build from new sources, generates samples again --- ...ith-fake-endpoints-models-for-testing.yaml | 36 ++ ...ith-fake-endpoints-models-for-testing.yaml | 36 ++ .../petstore/elixir/.openapi-generator/FILES | 2 + .../elixir/lib/openapi_petstore/api/fake.ex | 31 ++ .../model/child_with_nullable.ex | 26 + .../model/parent_with_nullable.ex | 24 + .../mp/.openapi-generator/FILES | 4 + .../mp/docs/ChildWithNullable.md | 13 + .../java-helidon-client/mp/docs/FakeApi.md | 36 ++ .../mp/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 10 + .../client/model/ChildWithNullable.java | 78 +++ .../client/model/ParentWithNullable.java | 123 +++++ .../client/model/ChildWithNullableTest.java | 67 +++ .../client/model/ParentWithNullableTest.java | 60 +++ .../se/.openapi-generator/FILES | 4 + .../se/docs/ChildWithNullable.md | 13 + .../java-helidon-client/se/docs/FakeApi.md | 66 +++ .../se/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 9 + .../openapitools/client/api/FakeApiImpl.java | 40 ++ .../client/model/ChildWithNullable.java | 78 +++ .../client/model/ParentWithNullable.java | 123 +++++ .../client/model/ChildWithNullableTest.java | 67 +++ .../client/model/ParentWithNullableTest.java | 60 +++ .../.openapi-generator/FILES | 4 + .../petstore/java/apache-httpclient/README.md | 3 + .../java/apache-httpclient/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/apache-httpclient/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 72 +++ .../client/model/ChildWithNullable.java | 208 ++++++++ .../client/model/ParentWithNullable.java | 261 ++++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../java/feign/.openapi-generator/FILES | 2 + .../petstore/java/feign/api/openapi.yaml | 38 ++ .../org/openapitools/client/api/FakeApi.java | 28 + .../client/model/ChildWithNullable.java | 129 +++++ .../client/model/ParentWithNullable.java | 204 ++++++++ .../client/model/ChildWithNullableTest.java | 66 +++ .../client/model/ParentWithNullableTest.java | 60 +++ .../java/resteasy/.openapi-generator/FILES | 4 + .../client/petstore/java/resteasy/README.md | 3 + .../petstore/java/resteasy/api/openapi.yaml | 38 ++ .../java/resteasy/docs/ChildWithNullable.md | 13 + .../petstore/java/resteasy/docs/FakeApi.md | 66 +++ .../java/resteasy/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 43 ++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../.openapi-generator/FILES | 4 + .../java/resttemplate-withXml/README.md | 3 + .../resttemplate-withXml/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/resttemplate-withXml/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 46 ++ .../client/model/ChildWithNullable.java | 150 ++++++ .../client/model/ParentWithNullable.java | 218 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../resttemplate/.openapi-generator/FILES | 4 + .../petstore/java/resttemplate/README.md | 3 + .../java/resttemplate/api/openapi.yaml | 38 ++ .../resttemplate/docs/ChildWithNullable.md | 13 + .../java/resttemplate/docs/FakeApi.md | 66 +++ .../resttemplate/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 46 ++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../java/vertx/.openapi-generator/FILES | 4 + samples/client/petstore/java/vertx/README.md | 3 + .../petstore/java/vertx/api/openapi.yaml | 38 ++ .../java/vertx/docs/ChildWithNullable.md | 13 + .../petstore/java/vertx/docs/FakeApi.md | 66 +++ .../java/vertx/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 5 + .../openapitools/client/api/FakeApiImpl.java | 49 ++ .../client/api/rxjava/FakeApi.java | 46 ++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../.openapi-generator/FILES | 4 + .../petstore/java/webclient-jakarta/README.md | 3 + .../java/webclient-jakarta/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/webclient-jakarta/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 70 +++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../.openapi-generator/FILES | 4 + .../java/webclient-swagger2/README.md | 3 + .../java/webclient-swagger2/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/webclient-swagger2/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 70 +++ .../client/model/ChildWithNullable.java | 142 +++++ .../client/model/ParentWithNullable.java | 206 ++++++++ .../client/model/ChildWithNullableTest.java | 69 +++ .../client/model/ParentWithNullableTest.java | 63 +++ .../java/webclient/.openapi-generator/FILES | 4 + .../client/petstore/java/webclient/README.md | 3 + .../petstore/java/webclient/api/openapi.yaml | 38 ++ .../java/webclient/docs/ChildWithNullable.md | 13 + .../petstore/java/webclient/docs/FakeApi.md | 66 +++ .../java/webclient/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 70 +++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ samples/client/petstore/k6/script.js | 16 + .../petstore/perl/.openapi-generator/FILES | 4 + samples/client/petstore/perl/README.md | 7 + .../petstore/perl/docs/ChildWithNullable.md | 15 + .../petstore/perl/docs/DeprecatedObject.md | 15 + samples/client/petstore/perl/docs/FakeApi.md | 46 ++ .../petstore/perl/docs/ParentWithNullable.md | 16 + .../perl/lib/WWW/OpenAPIClient/FakeApi.pm | 61 +++ .../OpenAPIClient/Object/ChildWithNullable.pm | 255 +++++++++ .../OpenAPIClient/Object/DeprecatedObject.pm | 242 +++++++++ .../Object/ParentWithNullable.pm | 251 +++++++++ .../petstore/perl/t/ChildWithNullableTest.t | 34 ++ .../petstore/perl/t/DeprecatedObjectTest.t | 34 ++ .../petstore/perl/t/ParentWithNullableTest.t | 34 ++ .../.openapi-generator/FILES | 4 + .../php-nextgen/OpenAPIClient-php/README.md | 3 + .../OpenAPIClient-php/docs/Api/FakeApi.md | 56 ++ .../docs/Model/ChildWithNullable.md | 9 + .../docs/Model/ParentWithNullable.md | 10 + .../OpenAPIClient-php/src/Api/FakeApi.php | 231 +++++++++ .../src/Model/ChildWithNullable.php | 403 +++++++++++++++ .../src/Model/ParentWithNullable.php | 485 ++++++++++++++++++ .../tests/Model/ChildWithNullableTest.php | 90 ++++ .../tests/Model/ParentWithNullableTest.php | 99 ++++ .../src/PSPetstore/Model/ModelMapping.ps1 | 97 ++++ .../tests/Model/ModelMapping.Tests.ps1 | 17 + .../ruby-autoload/.openapi-generator/FILES | 4 + .../client/petstore/ruby-autoload/README.md | 3 + .../ruby-autoload/docs/ChildWithNullable.md | 18 + .../petstore/ruby-autoload/docs/FakeApi.md | 64 +++ .../ruby-autoload/docs/ParentWithNullable.md | 20 + .../petstore/ruby-autoload/lib/petstore.rb | 2 + .../lib/petstore/api/fake_api.rb | 66 +++ .../petstore/models/child_with_nullable.rb | 247 +++++++++ .../petstore/models/parent_with_nullable.rb | 263 ++++++++++ .../spec/models/child_with_nullable_spec.rb | 34 ++ .../spec/models/parent_with_nullable_spec.rb | 44 ++ .../ruby-faraday/.openapi-generator/FILES | 4 + .../client/petstore/ruby-faraday/README.md | 3 + .../ruby-faraday/docs/ChildWithNullable.md | 18 + .../petstore/ruby-faraday/docs/FakeApi.md | 64 +++ .../ruby-faraday/docs/ParentWithNullable.md | 20 + .../petstore/ruby-faraday/lib/petstore.rb | 2 + .../ruby-faraday/lib/petstore/api/fake_api.rb | 66 +++ .../petstore/models/child_with_nullable.rb | 247 +++++++++ .../petstore/models/parent_with_nullable.rb | 263 ++++++++++ .../spec/models/child_with_nullable_spec.rb | 34 ++ .../spec/models/parent_with_nullable_spec.rb | 44 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 19 + .../openapitools/model/ChildWithNullable.java | 111 ++++ .../model/ParentWithNullable.java | 163 ++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 19 + .../model/ChildWithNullableDto.java | 113 ++++ .../model/ParentWithNullableDto.java | 164 ++++++ .../default-v3.0/.openapi-generator/FILES | 2 + .../builds/default-v3.0/apis/FakeApi.ts | 41 ++ .../default-v3.0/models/ChildWithNullable.ts | 74 +++ .../default-v3.0/models/ParentWithNullable.ts | 92 ++++ .../builds/default-v3.0/models/index.ts | 2 + .../.openapi-generator/FILES | 4 + .../README.md | 3 + .../doc/ChildWithNullable.md | 17 + .../doc/FakeApi.md | 43 ++ .../doc/ParentWithNullable.md | 16 + .../lib/openapi.dart | 2 + .../lib/src/api/fake_api.dart | 66 +++ .../lib/src/deserialize.dart | 6 + .../lib/src/model/child_with_nullable.dart | 98 ++++ .../lib/src/model/parent_with_nullable.dart | 79 +++ .../test/child_with_nullable_test.dart | 26 + .../test/parent_with_nullable_test.dart | 21 + .../.openapi-generator/FILES | 4 + .../petstore_client_lib_fake/README.md | 3 + .../doc/ChildWithNullable.md | 17 + .../petstore_client_lib_fake/doc/FakeApi.md | 43 ++ .../doc/ParentWithNullable.md | 16 + .../petstore_client_lib_fake/lib/openapi.dart | 2 + .../lib/src/api/fake_api.dart | 68 +++ .../lib/src/model/child_with_nullable.dart | 156 ++++++ .../lib/src/model/parent_with_nullable.dart | 212 ++++++++ .../lib/src/serializers.dart | 5 + .../test/child_with_nullable_test.dart | 26 + .../test/parent_with_nullable_test.dart | 21 + .../.openapi-generator/FILES | 4 + .../dart2/petstore_client_lib_fake/README.md | 3 + .../doc/ChildWithNullable.md | 17 + .../petstore_client_lib_fake/doc/FakeApi.md | 43 ++ .../doc/ParentWithNullable.md | 16 + .../petstore_client_lib_fake/lib/api.dart | 2 + .../lib/api/fake_api.dart | 50 ++ .../lib/api_client.dart | 4 + .../lib/model/child_with_nullable.dart | 211 ++++++++ .../lib/model/parent_with_nullable.dart | 194 +++++++ .../test/child_with_nullable_test.dart | 37 ++ .../test/parent_with_nullable_test.dart | 32 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 27 + .../openapitools/model/ChildWithNullable.java | 114 ++++ .../model/ParentWithNullable.java | 167 ++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 29 ++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 14 + .../openapitools/model/ChildWithNullable.java | 114 ++++ .../model/ParentWithNullable.java | 167 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 114 ++++ .../model/ParentWithNullable.java | 167 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../petstore/mysql/.openapi-generator/FILES | 2 + .../mysql/Model/ChildWithNullable.sql | 26 + .../mysql/Model/ParentWithNullable.sql | 26 + .../schema/petstore/mysql/mysql_schema.sql | 19 + .../generated/3_0/.openapi-generator/FILES | 4 + .../cpp-restbed/generated/3_0/api/FakeApi.cpp | 130 +++++ .../cpp-restbed/generated/3_0/api/FakeApi.h | 69 +++ .../generated/3_0/model/ChildWithNullable.cpp | 140 +++++ .../generated/3_0/model/ChildWithNullable.h | 106 ++++ .../3_0/model/ParentWithNullable.cpp | 127 +++++ .../generated/3_0/model/ParentWithNullable.h | 97 ++++ .../mp/.openapi-generator/FILES | 2 + .../petstore/java-helidon-server/mp/README.md | 1 + .../openapitools/server/api/FakeService.java | 6 + .../server/api/FakeServiceImpl.java | 7 + .../server/model/ChildWithNullable.java | 80 +++ .../server/model/ParentWithNullable.java | 149 ++++++ .../src/main/resources/META-INF/openapi.yml | 38 ++ .../server/model/ChildWithNullableTest.java | 62 +++ .../server/model/ParentWithNullableTest.java | 53 ++ .../se/.openapi-generator/FILES | 2 + .../petstore/java-helidon-server/se/README.md | 1 + .../openapitools/server/api/FakeService.java | 10 + .../server/api/FakeServiceImpl.java | 5 + .../server/model/ChildWithNullable.java | 73 +++ .../server/model/ParentWithNullable.java | 125 +++++ .../src/main/resources/META-INF/openapi.yml | 38 ++ .../server/model/ChildWithNullableTest.java | 62 +++ .../server/model/ParentWithNullableTest.java | 53 ++ .../jaxrs-jersey/.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 13 + .../org/openapitools/api/FakeApiService.java | 2 + .../openapitools/model/ChildWithNullable.java | 98 ++++ .../model/ParentWithNullable.java | 160 ++++++ .../api/impl/FakeApiServiceImpl.java | 6 + .../php-laravel/.openapi-generator/FILES | 2 + .../app/Http/Controllers/FakeController.php | 24 + .../lib/app/Models/ChildWithNullable.php | 21 + .../lib/app/Models/ParentWithNullable.php | 18 + .../petstore/php-laravel/lib/routes/api.php | 7 + .../lib/app/Http/Controllers/FakeApi.php | 24 + .../petstore/php-lumen/lib/routes/web.php | 7 + .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 27 + .../openapitools/model/ChildWithNullable.java | 114 ++++ .../model/ParentWithNullable.java | 167 ++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 101 ++++ .../model/ParentWithNullable.java | 153 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 29 ++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 14 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 29 ++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 14 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 31 ++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 17 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 17 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 115 +++++ .../model/ParentWithNullable.java | 168 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../.openapi-generator/FILES | 2 + .../openapitools/virtualan/api/FakeApi.java | 31 ++ .../virtualan/api/FakeApiController.java | 1 + .../virtualan/model/ChildWithNullable.java | 114 ++++ .../virtualan/model/ParentWithNullable.java | 167 ++++++ .../src/main/resources/openapi.yaml | 40 ++ .../springboot/.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++ .../openapitools/api/FakeApiController.java | 1 + .../model/ChildWithNullableDto.java | 117 +++++ .../model/ParentWithNullableDto.java | 169 ++++++ .../src/main/resources/openapi.yaml | 40 ++ 346 files changed, 20471 insertions(+) create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex create mode 100644 samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/resteasy/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/resteasy/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/vertx/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/vertx/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/webclient/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/perl/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/perl/docs/DeprecatedObject.md create mode 100644 samples/client/petstore/perl/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm create mode 100644 samples/client/petstore/perl/t/ChildWithNullableTest.t create mode 100644 samples/client/petstore/perl/t/DeprecatedObjectTest.t create mode 100644 samples/client/petstore/perl/t/ParentWithNullableTest.t create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php create mode 100644 samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 create mode 100644 samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 create mode 100644 samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb create mode 100644 samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb create mode 100644 samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb create mode 100644 samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb create mode 100644 samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb create mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb create mode 100644 samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb create mode 100644 samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb create mode 100644 samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java create mode 100644 samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java create mode 100644 samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/schema/petstore/mysql/Model/ChildWithNullable.sql create mode 100644 samples/schema/petstore/mysql/Model/ParentWithNullable.sql create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h create mode 100644 samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java create mode 100644 samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java create mode 100644 samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php create mode 100644 samples/server/petstore/php-laravel/lib/app/Models/ParentWithNullable.php create mode 100644 samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java create mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml index c6091e8cacc..746d1be1134 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1014,6 +1014,23 @@ paths: type: string description: request body required: true + /fake/nullable: + post: + tags: + - fake + summary: test nullable parent property + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation /fake/body-with-query-params: put: tags: @@ -1826,6 +1843,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + type: object + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - ChildWithNullable + nullableProperty: + type: string + nullable: true + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - type: object + properties: + otherProperty: + type: string StringBooleanMap: additionalProperties: type: boolean diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml index 9f965349404..f92d9a5c978 100644 --- a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml @@ -924,6 +924,23 @@ paths: responses: "200": description: successful operation + /fake/nullable: + post: + tags: + - fake + summary: test nullable parent property + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation /fake/body-with-query-params: put: tags: @@ -1743,6 +1760,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + type: object + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - ChildWithNullable + nullableProperty: + type: string + nullable: true + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - type: object + properties: + otherProperty: + type: string StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/elixir/.openapi-generator/FILES b/samples/client/petstore/elixir/.openapi-generator/FILES index cf3fc36a0ab..4e11f3ad074 100644 --- a/samples/client/petstore/elixir/.openapi-generator/FILES +++ b/samples/client/petstore/elixir/.openapi-generator/FILES @@ -24,6 +24,7 @@ lib/openapi_petstore/model/array_test.ex lib/openapi_petstore/model/capitalization.ex lib/openapi_petstore/model/cat.ex lib/openapi_petstore/model/category.ex +lib/openapi_petstore/model/child_with_nullable.ex lib/openapi_petstore/model/class_model.ex lib/openapi_petstore/model/client.ex lib/openapi_petstore/model/deprecated_model.ex @@ -53,6 +54,7 @@ lib/openapi_petstore/model/outer_enum_default_value.ex lib/openapi_petstore/model/outer_enum_integer.ex lib/openapi_petstore/model/outer_enum_integer_default_value.ex lib/openapi_petstore/model/outer_object_with_enum_property.ex +lib/openapi_petstore/model/parent_with_nullable.ex lib/openapi_petstore/model/pet.ex lib/openapi_petstore/model/read_only_first.ex lib/openapi_petstore/model/return.ex diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex index 86607169736..6cdb560634a 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex @@ -618,6 +618,37 @@ defmodule OpenapiPetstore.Api.Fake do ]) end + @doc """ + test nullable parent property + + + ### Parameters + + - `connection` (OpenapiPetstore.Connection): Connection to server + - `child_with_nullable` (ChildWithNullable): request body + - `opts` (keyword): Optional parameters + + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure + """ + @spec test_nullable(Tesla.Env.client, OpenapiPetstore.Model.ChildWithNullable.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} + def test_nullable(connection, child_with_nullable, _opts \\ []) do + request = + %{} + |> method(:post) + |> url("/fake/nullable") + |> add_param(:body, :body, child_with_nullable) + |> Enum.into([]) + + connection + |> Connection.request(request) + |> evaluate_response([ + {200, false} + ]) + end + @doc """ To test the collection format in query parameters diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex new file mode 100644 index 00000000000..850ce5cbdf4 --- /dev/null +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex @@ -0,0 +1,26 @@ +# NOTE: This file is auto generated by OpenAPI Generator 7.0.1-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. + +defmodule OpenapiPetstore.Model.ChildWithNullable do + @moduledoc """ + + """ + + @derive Jason.Encoder + defstruct [ + :type, + :nullableProperty, + :otherProperty + ] + + @type t :: %__MODULE__{ + :type => String.t | nil, + :nullableProperty => String.t | nil, + :otherProperty => String.t | nil + } + + def decode(value) do + value + end +end + diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex new file mode 100644 index 00000000000..8fc6d5113e8 --- /dev/null +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex @@ -0,0 +1,24 @@ +# NOTE: This file is auto generated by OpenAPI Generator 7.0.1-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. + +defmodule OpenapiPetstore.Model.ParentWithNullable do + @moduledoc """ + + """ + + @derive Jason.Encoder + defstruct [ + :type, + :nullableProperty + ] + + @type t :: %__MODULE__{ + :type => String.t | nil, + :nullableProperty => String.t | nil + } + + def decode(value) do + value + end +end + diff --git a/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES b/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES index 3355ff7560c..697bbc6ddab 100644 --- a/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES +++ b/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES @@ -9,6 +9,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -44,6 +45,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -74,6 +76,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -106,6 +109,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md b/samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md b/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md index be1544eae6e..5ad01909152 100644 --- a/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md +++ b/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -640,6 +641,41 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> void testNullable(childWithNullable) + +test nullable parent property + + + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +[**void**](Void.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > void testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md b/samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java index af82256d0d7..89484f30f6c 100644 --- a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java @@ -26,6 +26,7 @@ import org.eclipse.microprofile.rest.client.annotation.RegisterProvider; import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -169,6 +170,15 @@ public interface FakeApi { @Consumes({ "application/x-www-form-urlencoded" }) void testJsonFormData(@FormParam("param") String param, @FormParam("param2") String param2) throws ApiException, ProcessingException; + /** + * test nullable parent property + * + */ + @POST + @Path("/nullable") + @Consumes({ "application/json" }) + void testNullable(ChildWithNullable childWithNullable) throws ApiException, ProcessingException; + @PUT @Path("/test-query-parameters") void testQueryParameterCollectionFormat(@QueryParam("pipe") List pipe, @QueryParam("ioutil") List ioutil, @QueryParam("http") List http, @QueryParam("url") List url, @QueryParam("context") List context, @QueryParam("allowEmpty") String allowEmpty, @QueryParam("language") Map language) throws ApiException, ProcessingException; diff --git a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..90b2f7ceb09 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,78 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + + + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Get otherProperty + * @return otherProperty + **/ + public String getOtherProperty() { + return otherProperty; + } + + /** + * Set otherProperty + **/ + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..25c24ff8602 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,123 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + + + + +public class ParentWithNullable { + +public enum TypeEnum { + + CHILDWITHNULLABLE(String.valueOf("ChildWithNullable")); + + String value; + + TypeEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +} + + private TypeEnum type; + + private String nullableProperty; + + /** + * Get type + * @return type + **/ + public TypeEnum getType() { + return type; + } + + /** + * Set type + **/ + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set nullableProperty + **/ + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..68acb8c5234 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,67 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..a0fe79ed444 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,60 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES b/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES index 4fcd023785c..e94daa98539 100644 --- a/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES +++ b/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES @@ -9,6 +9,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -44,6 +45,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -83,6 +85,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -115,6 +118,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md b/samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md b/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md +++ b/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md b/samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java index 5e5dec6bfb2..d1c8dd114ec 100644 --- a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java @@ -14,6 +14,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiResponse; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -144,6 +145,14 @@ public interface FakeApi { */ ApiResponse testJsonFormData(String param, String param2); + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @return {@code ApiResponse} + */ + ApiResponse testNullable(ChildWithNullable childWithNullable); + ApiResponse testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language); } diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java index 9a2849d61ae..ae2bdc30f22 100644 --- a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java @@ -30,6 +30,7 @@ import io.helidon.webclient.WebClientResponse; import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -75,6 +76,7 @@ public class FakeApiImpl implements FakeApi { protected static final GenericType RESPONSE_TYPE_testGroupParameters = ResponseType.create(Void.class); protected static final GenericType RESPONSE_TYPE_testInlineAdditionalProperties = ResponseType.create(Void.class); protected static final GenericType RESPONSE_TYPE_testJsonFormData = ResponseType.create(Void.class); + protected static final GenericType RESPONSE_TYPE_testNullable = ResponseType.create(Void.class); protected static final GenericType RESPONSE_TYPE_testQueryParameterCollectionFormat = ResponseType.create(Void.class); /** @@ -856,6 +858,44 @@ public class FakeApiImpl implements FakeApi { return ApiResponse.create(RESPONSE_TYPE_testJsonFormData, webClientResponse); } + @Override + public ApiResponse testNullable(ChildWithNullable childWithNullable) { + Objects.requireNonNull(childWithNullable, "Required parameter 'childWithNullable' not specified"); + WebClientRequestBuilder webClientRequestBuilder = testNullableRequestBuilder(childWithNullable); + return testNullableSubmit(webClientRequestBuilder, childWithNullable); + } + + /** + * Creates a {@code WebClientRequestBuilder} for the testNullable operation. + * Optional customization point for subclasses. + * + * @param childWithNullable request body (required) + * @return WebClientRequestBuilder for testNullable + */ + protected WebClientRequestBuilder testNullableRequestBuilder(ChildWithNullable childWithNullable) { + WebClientRequestBuilder webClientRequestBuilder = apiClient.webClient() + .method("POST"); + + webClientRequestBuilder.path("/fake/nullable"); + webClientRequestBuilder.contentType(MediaType.APPLICATION_JSON); + webClientRequestBuilder.accept(MediaType.APPLICATION_JSON); + + return webClientRequestBuilder; + } + + /** + * Initiates the request for the testNullable operation. + * Optional customization point for subclasses. + * + * @param webClientRequestBuilder the request builder to use for submitting the request + * @param childWithNullable request body (required) + * @return {@code ApiResponse} for the submitted request + */ + protected ApiResponse testNullableSubmit(WebClientRequestBuilder webClientRequestBuilder, ChildWithNullable childWithNullable) { + Single webClientResponse = webClientRequestBuilder.submit(childWithNullable); + return ApiResponse.create(RESPONSE_TYPE_testNullable, webClientResponse); + } + @Override public ApiResponse testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language) { Objects.requireNonNull(pipe, "Required parameter 'pipe' not specified"); diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..90b2f7ceb09 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,78 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + + + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Get otherProperty + * @return otherProperty + **/ + public String getOtherProperty() { + return otherProperty; + } + + /** + * Set otherProperty + **/ + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..25c24ff8602 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,123 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + + + + +public class ParentWithNullable { + +public enum TypeEnum { + + CHILDWITHNULLABLE(String.valueOf("ChildWithNullable")); + + String value; + + TypeEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +} + + private TypeEnum type; + + private String nullableProperty; + + /** + * Get type + * @return type + **/ + public TypeEnum getType() { + return type; + } + + /** + * Set type + **/ + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set nullableProperty + **/ + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..68acb8c5234 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,67 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..a0fe79ed444 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,60 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES index bf886d21ded..c3b1e93a673 100644 --- a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -99,6 +101,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -131,6 +134,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/apache-httpclient/README.md b/samples/client/petstore/java/apache-httpclient/README.md index 3a2c3df03fa..400434d7e49 100644 --- a/samples/client/petstore/java/apache-httpclient/README.md +++ b/samples/client/petstore/java/apache-httpclient/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -161,6 +162,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -193,6 +195,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/apache-httpclient/api/openapi.yaml b/samples/client/petstore/java/apache-httpclient/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/apache-httpclient/api/openapi.yaml +++ b/samples/client/petstore/java/apache-httpclient/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md b/samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md b/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md +++ b/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md b/samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java index 99b71e9b542..c649052dd86 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java @@ -20,6 +20,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.Pair; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1407,6 +1408,77 @@ if (param2 != null) ); } + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @throws ApiException if fails to make API call + */ + public void testNullable(ChildWithNullable childWithNullable) throws ApiException { + this.testNullable(childWithNullable, Collections.emptyMap()); + } + + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param additionalHeaders additionalHeaders for this call + * @throws ApiException if fails to make API call + */ + public void testNullable(ChildWithNullable childWithNullable, Map additionalHeaders) throws ApiException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new ApiException(400, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + // create path and map variables + String localVarPath = "/fake/nullable"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + localVarHeaderParams.putAll(additionalHeaders); + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + apiClient.invokeAPI( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + null + ); + } + /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..6c714ccc580 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,208 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + try { + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `nullableProperty` to the URL query string + if (getNullableProperty() != null) { + try { + joiner.add(String.format("%snullableProperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableProperty()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `otherProperty` to the URL query string + if (getOtherProperty() != null) { + try { + joiner.add(String.format("%sotherProperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOtherProperty()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..ff90d3aa9e2 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,261 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + try { + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `nullableProperty` to the URL query string + if (getNullableProperty() != null) { + try { + joiner.add(String.format("%snullableProperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableProperty()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/feign/.openapi-generator/FILES b/samples/client/petstore/java/feign/.openapi-generator/FILES index fae67fe89c0..995a090dcb2 100644 --- a/samples/client/petstore/java/feign/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign/.openapi-generator/FILES @@ -48,6 +48,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -80,6 +81,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/feign/api/openapi.yaml b/samples/client/petstore/java/feign/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/feign/api/openapi.yaml +++ b/samples/client/petstore/java/feign/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java index de441d239da..56dec984095 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java @@ -5,6 +5,7 @@ import org.openapitools.client.EncodingUtils; import org.openapitools.client.model.ApiResponse; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -839,6 +840,33 @@ public interface FakeApi extends ApiClient.Api { + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + */ + @RequestLine("POST /fake/nullable") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + void testNullable(ChildWithNullable childWithNullable); + + /** + * test nullable parent property + * Similar to testNullable but it also returns the http response headers . + * + * @param childWithNullable request body (required) + */ + @RequestLine("POST /fake/nullable") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + ApiResponse testNullableWithHttpInfo(ChildWithNullable childWithNullable); + + + /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..7d8fa698f33 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,129 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..defe2fe2dd2 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,204 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..746a2c9f9b4 --- /dev/null +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..7a1f1c9d3fc --- /dev/null +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/resteasy/.openapi-generator/FILES b/samples/client/petstore/java/resteasy/.openapi-generator/FILES index 2044e402491..5268fd94f53 100644 --- a/samples/client/petstore/java/resteasy/.openapi-generator/FILES +++ b/samples/client/petstore/java/resteasy/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -100,6 +102,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -132,6 +135,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/resteasy/README.md b/samples/client/petstore/java/resteasy/README.md index 084a6ea31a3..45e1a1c959b 100644 --- a/samples/client/petstore/java/resteasy/README.md +++ b/samples/client/petstore/java/resteasy/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/resteasy/api/openapi.yaml b/samples/client/petstore/java/resteasy/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/resteasy/api/openapi.yaml +++ b/samples/client/petstore/java/resteasy/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/resteasy/docs/ChildWithNullable.md b/samples/client/petstore/java/resteasy/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/resteasy/docs/FakeApi.md b/samples/client/petstore/java/resteasy/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/resteasy/docs/FakeApi.md +++ b/samples/client/petstore/java/resteasy/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/resteasy/docs/ParentWithNullable.md b/samples/client/petstore/java/resteasy/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java index 73d27c887ca..c9bee15e56f 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java @@ -8,6 +8,7 @@ import org.openapitools.client.Pair; import javax.ws.rs.core.GenericType; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -853,6 +854,48 @@ if (param2 != null) apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @throws ApiException if fails to make API call + */ + public void testNullable(ChildWithNullable childWithNullable) throws ApiException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new ApiException(400, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + // create path and map variables + String localVarPath = "/fake/nullable".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..808a97496f3 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..b8ad35eda76 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES index 76a53947ccf..66e0488958e 100644 --- a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -95,6 +97,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -127,6 +130,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/resttemplate-withXml/README.md b/samples/client/petstore/java/resttemplate-withXml/README.md index d450bd82c64..dc708dba258 100644 --- a/samples/client/petstore/java/resttemplate-withXml/README.md +++ b/samples/client/petstore/java/resttemplate-withXml/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml b/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml +++ b/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md b/samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md b/samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java index ea18b45cd97..0ed0c08ed19 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -971,6 +972,51 @@ public class FakeApi { ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/fake/jsonFormData", HttpMethod.GET, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public void testNullable(ChildWithNullable childWithNullable) throws RestClientException { + testNullableWithHttpInfo(childWithNullable); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws RestClientException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + 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("/fake/nullable", HttpMethod.POST, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..dba8d12b8e9 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,150 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.dataformat.xml.annotation.*; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.*; +import io.github.threetenjaxb.core.*; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +@XmlRootElement(name = "ChildWithNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@JacksonXmlRootElement(localName = "ChildWithNullable") +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + @XmlElement(name = "otherProperty") + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "otherProperty") + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "otherProperty") + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..1fef3b6f440 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,218 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.dataformat.xml.annotation.*; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.*; +import io.github.threetenjaxb.core.*; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +@XmlRootElement(name = "ParentWithNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@JacksonXmlRootElement(localName = "ParentWithNullable") +public class ParentWithNullable { + /** + * Gets or Sets type + */ + @XmlType(name="TypeEnum") + @XmlEnum(String.class) + public enum TypeEnum { + @XmlEnumValue("ChildWithNullable") + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + @XmlElement(name = "type") + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + @XmlElement(name = "nullableProperty") + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "type") + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "type") + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "nullableProperty") + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES index 76a53947ccf..66e0488958e 100644 --- a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -95,6 +97,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -127,6 +130,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/resttemplate/README.md b/samples/client/petstore/java/resttemplate/README.md index bfd879857cf..c2f1a0109a6 100644 --- a/samples/client/petstore/java/resttemplate/README.md +++ b/samples/client/petstore/java/resttemplate/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/resttemplate/api/openapi.yaml b/samples/client/petstore/java/resttemplate/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/resttemplate/api/openapi.yaml +++ b/samples/client/petstore/java/resttemplate/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md b/samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/resttemplate/docs/FakeApi.md b/samples/client/petstore/java/resttemplate/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/resttemplate/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md b/samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java index ea18b45cd97..0ed0c08ed19 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -971,6 +972,51 @@ public class FakeApi { ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/fake/jsonFormData", HttpMethod.GET, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public void testNullable(ChildWithNullable childWithNullable) throws RestClientException { + testNullableWithHttpInfo(childWithNullable); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws RestClientException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + 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("/fake/nullable", HttpMethod.POST, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..808a97496f3 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..b8ad35eda76 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/vertx/.openapi-generator/FILES b/samples/client/petstore/java/vertx/.openapi-generator/FILES index d7d207ca6c3..78449bae3e4 100644 --- a/samples/client/petstore/java/vertx/.openapi-generator/FILES +++ b/samples/client/petstore/java/vertx/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -113,6 +115,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -145,6 +148,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/vertx/README.md b/samples/client/petstore/java/vertx/README.md index 883a558aa74..bc346e08dd2 100644 --- a/samples/client/petstore/java/vertx/README.md +++ b/samples/client/petstore/java/vertx/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/vertx/api/openapi.yaml b/samples/client/petstore/java/vertx/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/vertx/api/openapi.yaml +++ b/samples/client/petstore/java/vertx/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/vertx/docs/ChildWithNullable.md b/samples/client/petstore/java/vertx/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/vertx/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/vertx/docs/FakeApi.md b/samples/client/petstore/java/vertx/docs/FakeApi.md index a0fb70ef8d4..d17031d2ac1 100644 --- a/samples/client/petstore/java/vertx/docs/FakeApi.md +++ b/samples/client/petstore/java/vertx/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/vertx/docs/ParentWithNullable.md b/samples/client/petstore/java/vertx/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/vertx/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java index 43d08fbc79a..ac4bf8941f6 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import io.vertx.core.file.AsyncFile; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -90,6 +91,10 @@ public interface FakeApi { void testJsonFormData(String param, String param2, ApiClient.AuthInfo authInfo, Handler> handler); + void testNullable(ChildWithNullable childWithNullable, Handler> handler); + + void testNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo, Handler> handler); + void testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language, Handler> handler); void testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language, ApiClient.AuthInfo authInfo, Handler> handler); diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java index 4236c2b3287..34c098a50fb 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java @@ -2,6 +2,7 @@ package org.openapitools.client.api; import io.vertx.core.file.AsyncFile; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -964,6 +965,54 @@ if (param2 != null) localVarFormParams.put("param2", param2); apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, authInfo, null, resultHandler); } /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, Handler> resultHandler) { + testNullable(childWithNullable, null, resultHandler); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param authInfo per call authentication override. + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo, Handler> resultHandler) { + Object localVarBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + resultHandler.handle(ApiException.fail(400, "Missing the required parameter 'childWithNullable' when calling testNullable")); + return; + } + + // create path and map variables + String localVarPath = "/fake/nullable"; + + // query params + List localVarQueryParams = new ArrayList<>(); + + // header params + MultiMap localVarHeaderParams = MultiMap.caseInsensitiveMultiMap(); + + // cookie params + MultiMap localVarCookieParams = MultiMap.caseInsensitiveMultiMap(); + + // form params + // TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client) + Map localVarFormParams = new HashMap<>(); + + String[] localVarAccepts = { }; + String[] localVarContentTypes = { "application/json" }; + String[] localVarAuthNames = new String[] { }; + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, authInfo, null, resultHandler); + } + /** * * To test the collection format in query parameters * @param pipe (required) diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java index 85106635b97..4ae404ab093 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java @@ -2,6 +2,7 @@ package org.openapitools.client.api.rxjava; import io.vertx.core.file.AsyncFile; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -912,6 +913,51 @@ public class FakeApi { )); } /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, Handler> resultHandler) { + delegate.testNullable(childWithNullable, resultHandler); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param authInfo call specific auth overrides + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo, Handler> resultHandler) { + delegate.testNullable(childWithNullable, authInfo, resultHandler); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @return Asynchronous result handler (RxJava Single) + */ + public Single rxTestNullable(ChildWithNullable childWithNullable) { + return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> + delegate.testNullable(childWithNullable, fut) + )); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param authInfo call specific auth overrides + * @return Asynchronous result handler (RxJava Single) + */ + public Single rxTestNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo) { + return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> + delegate.testNullable(childWithNullable, authInfo, fut) + )); + } + /** * * To test the collection format in query parameters * @param pipe (required) diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..808a97496f3 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..b8ad35eda76 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES index 7b091f23a80..cf2db2afaf1 100644 --- a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -96,6 +98,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -128,6 +131,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/webclient-jakarta/README.md b/samples/client/petstore/java/webclient-jakarta/README.md index 11cf41560c8..178a016bffe 100644 --- a/samples/client/petstore/java/webclient-jakarta/README.md +++ b/samples/client/petstore/java/webclient-jakarta/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml b/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml +++ b/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md b/samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md b/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md b/samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java index d8ff2b837d4..35ad9b29bca 100644 --- a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1449,6 +1450,75 @@ public class FakeApi { public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException { return testJsonFormDataRequestCreation(param, param2); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException { + Object postBody = childWithNullable; + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + 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("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException { + return testNullableRequestCreation(childWithNullable); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..82378f275fa --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..89b485dbe70 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @jakarta.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES index 7b091f23a80..cf2db2afaf1 100644 --- a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -96,6 +98,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -128,6 +131,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/webclient-swagger2/README.md b/samples/client/petstore/java/webclient-swagger2/README.md index 11cf41560c8..178a016bffe 100644 --- a/samples/client/petstore/java/webclient-swagger2/README.md +++ b/samples/client/petstore/java/webclient-swagger2/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml b/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml +++ b/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md b/samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md b/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md b/samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java index a86605d1ae2..da027dbd509 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1449,6 +1450,75 @@ public class FakeApi { public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException { return testJsonFormDataRequestCreation(param, param2); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException { + Object postBody = childWithNullable; + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + 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("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException { + return testNullableRequestCreation(childWithNullable); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..43bf9db8f6f --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,142 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/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 new file mode 100644 index 00000000000..023236bc487 --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,206 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..445815405cf --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..870d9c13459 --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,63 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/webclient/.openapi-generator/FILES b/samples/client/petstore/java/webclient/.openapi-generator/FILES index 7b091f23a80..cf2db2afaf1 100644 --- a/samples/client/petstore/java/webclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -96,6 +98,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -128,6 +131,7 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/client/model/ParentWithNullable.java src/main/java/org/openapitools/client/model/Pet.java src/main/java/org/openapitools/client/model/ReadOnlyFirst.java src/main/java/org/openapitools/client/model/SingleRefType.java diff --git a/samples/client/petstore/java/webclient/README.md b/samples/client/petstore/java/webclient/README.md index 11cf41560c8..178a016bffe 100644 --- a/samples/client/petstore/java/webclient/README.md +++ b/samples/client/petstore/java/webclient/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/webclient/api/openapi.yaml b/samples/client/petstore/java/webclient/api/openapi.yaml index 9f0affe779f..288d4890902 100644 --- a/samples/client/petstore/java/webclient/api/openapi.yaml +++ b/samples/client/petstore/java/webclient/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/webclient/docs/ChildWithNullable.md b/samples/client/petstore/java/webclient/docs/ChildWithNullable.md new file mode 100644 index 00000000000..73c0dd6d473 --- /dev/null +++ b/samples/client/petstore/java/webclient/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/webclient/docs/FakeApi.md b/samples/client/petstore/java/webclient/docs/FakeApi.md index 6eb12aee357..df8b14be8e2 100644 --- a/samples/client/petstore/java/webclient/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### 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.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/webclient/docs/ParentWithNullable.md b/samples/client/petstore/java/webclient/docs/ParentWithNullable.md new file mode 100644 index 00000000000..b8fcf6b42e8 --- /dev/null +++ b/samples/client/petstore/java/webclient/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java index a86605d1ae2..da027dbd509 100644 --- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1449,6 +1450,75 @@ public class FakeApi { public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException { return testJsonFormDataRequestCreation(param, param2); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException { + Object postBody = childWithNullable; + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + 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("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException { + return testNullableRequestCreation(childWithNullable); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 00000000000..808a97496f3 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 00000000000..b8ad35eda76 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..2616181bec3 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..bdd46008b13 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/k6/script.js b/samples/client/petstore/k6/script.js index f657d146f89..1416fe64534 100644 --- a/samples/client/petstore/k6/script.js +++ b/samples/client/petstore/k6/script.js @@ -158,6 +158,22 @@ export default function() { } }); + group("/fake/nullable", () => { + + // Request No. 1: testNullable + { + let url = BASE_URL + `/fake/nullable`; + // TODO: edit the parameters of the request body. + let body = {"type": "string", "nullableProperty": "string", "otherProperty": "string"}; + let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}}; + let request = http.post(url, JSON.stringify(body), params); + + check(request, { + "successful operation": (r) => r.status === 200 + }); + } + }); + group("/fake_classname_test", () => { // Request No. 1: testClassname diff --git a/samples/client/petstore/perl/.openapi-generator/FILES b/samples/client/petstore/perl/.openapi-generator/FILES index 2f27fda7f34..d6a142a834b 100644 --- a/samples/client/petstore/perl/.openapi-generator/FILES +++ b/samples/client/petstore/perl/.openapi-generator/FILES @@ -13,6 +13,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -47,6 +48,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -74,6 +76,7 @@ lib/WWW/OpenAPIClient/Object/ArrayTest.pm lib/WWW/OpenAPIClient/Object/Capitalization.pm lib/WWW/OpenAPIClient/Object/Cat.pm lib/WWW/OpenAPIClient/Object/Category.pm +lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm lib/WWW/OpenAPIClient/Object/ClassModel.pm lib/WWW/OpenAPIClient/Object/Client.pm lib/WWW/OpenAPIClient/Object/DeprecatedModel.pm @@ -105,6 +108,7 @@ lib/WWW/OpenAPIClient/Object/OuterEnumDefaultValue.pm lib/WWW/OpenAPIClient/Object/OuterEnumInteger.pm lib/WWW/OpenAPIClient/Object/OuterEnumIntegerDefaultValue.pm lib/WWW/OpenAPIClient/Object/OuterObjectWithEnumProperty.pm +lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm lib/WWW/OpenAPIClient/Object/Pet.pm lib/WWW/OpenAPIClient/Object/ReadOnlyFirst.pm lib/WWW/OpenAPIClient/Object/SingleRefType.pm diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 18b2ea4aab1..affa55c6194 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -252,6 +252,7 @@ use WWW::OpenAPIClient::Object::ArrayTest; use WWW::OpenAPIClient::Object::Capitalization; use WWW::OpenAPIClient::Object::Cat; use WWW::OpenAPIClient::Object::Category; +use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; use WWW::OpenAPIClient::Object::DeprecatedModel; @@ -283,6 +284,7 @@ use WWW::OpenAPIClient::Object::OuterEnumDefaultValue; use WWW::OpenAPIClient::Object::OuterEnumInteger; use WWW::OpenAPIClient::Object::OuterEnumIntegerDefaultValue; use WWW::OpenAPIClient::Object::OuterObjectWithEnumProperty; +use WWW::OpenAPIClient::Object::ParentWithNullable; use WWW::OpenAPIClient::Object::Pet; use WWW::OpenAPIClient::Object::ReadOnlyFirst; use WWW::OpenAPIClient::Object::SingleRefType; @@ -319,6 +321,7 @@ use WWW::OpenAPIClient::Object::ArrayTest; use WWW::OpenAPIClient::Object::Capitalization; use WWW::OpenAPIClient::Object::Cat; use WWW::OpenAPIClient::Object::Category; +use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; use WWW::OpenAPIClient::Object::DeprecatedModel; @@ -350,6 +353,7 @@ use WWW::OpenAPIClient::Object::OuterEnumDefaultValue; use WWW::OpenAPIClient::Object::OuterEnumInteger; use WWW::OpenAPIClient::Object::OuterEnumIntegerDefaultValue; use WWW::OpenAPIClient::Object::OuterObjectWithEnumProperty; +use WWW::OpenAPIClient::Object::ParentWithNullable; use WWW::OpenAPIClient::Object::Pet; use WWW::OpenAPIClient::Object::ReadOnlyFirst; use WWW::OpenAPIClient::Object::SingleRefType; @@ -401,6 +405,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_nullable**](docs/FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store @@ -437,6 +442,7 @@ Class | Method | HTTP request | Description - [WWW::OpenAPIClient::Object::Capitalization](docs/Capitalization.md) - [WWW::OpenAPIClient::Object::Cat](docs/Cat.md) - [WWW::OpenAPIClient::Object::Category](docs/Category.md) + - [WWW::OpenAPIClient::Object::ChildWithNullable](docs/ChildWithNullable.md) - [WWW::OpenAPIClient::Object::ClassModel](docs/ClassModel.md) - [WWW::OpenAPIClient::Object::Client](docs/Client.md) - [WWW::OpenAPIClient::Object::DeprecatedModel](docs/DeprecatedModel.md) @@ -468,6 +474,7 @@ Class | Method | HTTP request | Description - [WWW::OpenAPIClient::Object::OuterEnumInteger](docs/OuterEnumInteger.md) - [WWW::OpenAPIClient::Object::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [WWW::OpenAPIClient::Object::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [WWW::OpenAPIClient::Object::ParentWithNullable](docs/ParentWithNullable.md) - [WWW::OpenAPIClient::Object::Pet](docs/Pet.md) - [WWW::OpenAPIClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [WWW::OpenAPIClient::Object::SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/perl/docs/ChildWithNullable.md b/samples/client/petstore/perl/docs/ChildWithNullable.md new file mode 100644 index 00000000000..81016dd9404 --- /dev/null +++ b/samples/client/petstore/perl/docs/ChildWithNullable.md @@ -0,0 +1,15 @@ +# WWW::OpenAPIClient::Object::ChildWithNullable + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::ChildWithNullable; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**other_property** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/DeprecatedObject.md b/samples/client/petstore/perl/docs/DeprecatedObject.md new file mode 100644 index 00000000000..692432fcab1 --- /dev/null +++ b/samples/client/petstore/perl/docs/DeprecatedObject.md @@ -0,0 +1,15 @@ +# WWW::OpenAPIClient::Object::DeprecatedObject + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::DeprecatedObject; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/FakeApi.md b/samples/client/petstore/perl/docs/FakeApi.md index 546ef873a8a..0bd3dce02b7 100644 --- a/samples/client/petstore/perl/docs/FakeApi.md +++ b/samples/client/petstore/perl/docs/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_nullable**](FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | @@ -859,6 +860,51 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_nullable** +> test_nullable(child_with_nullable => $child_with_nullable) + +test nullable parent property + + + +### Example +```perl +use Data::Dumper; +use WWW::OpenAPIClient::FakeApi; +my $api_instance = WWW::OpenAPIClient::FakeApi->new( +); + +my $child_with_nullable = WWW::OpenAPIClient::Object::ChildWithNullable->new(); # ChildWithNullable | request body + +eval { + $api_instance->test_nullable(child_with_nullable => $child_with_nullable); +}; +if ($@) { + warn "Exception when calling FakeApi->test_nullable: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **child_with_nullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_query_parameter_collection_format** > test_query_parameter_collection_format(pipe => $pipe, ioutil => $ioutil, http => $http, url => $url, context => $context, allow_empty => $allow_empty, language => $language) diff --git a/samples/client/petstore/perl/docs/ParentWithNullable.md b/samples/client/petstore/perl/docs/ParentWithNullable.md new file mode 100644 index 00000000000..d59af4c9bfb --- /dev/null +++ b/samples/client/petstore/perl/docs/ParentWithNullable.md @@ -0,0 +1,16 @@ +# WWW::OpenAPIClient::Object::ParentWithNullable + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::ParentWithNullable; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | | [optional] +**nullable_property** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm index cdd5fa2cc10..e1a34b97162 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm @@ -1421,6 +1421,67 @@ sub test_json_form_data { return; } +# +# test_nullable +# +# test nullable parent property +# +# @param ChildWithNullable $child_with_nullable request body (required) +{ + my $params = { + 'child_with_nullable' => { + data_type => 'ChildWithNullable', + description => 'request body', + required => '1', + }, + }; + __PACKAGE__->method_documentation->{ 'test_nullable' } = { + summary => 'test nullable parent property', + params => $params, + returns => undef, + }; +} +# @return void +# +sub test_nullable { + my ($self, %args) = @_; + + # verify the required parameter 'child_with_nullable' is set + unless (exists $args{'child_with_nullable'}) { + croak("Missing the required parameter 'child_with_nullable' when calling test_nullable"); + } + + # parse inputs + my $_resource_path = '/fake/nullable'; + + my $_method = 'POST'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept(); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json'); + + my $_body_data; + # body params + if ( exists $args{'child_with_nullable'}) { + $_body_data = $args{'child_with_nullable'}; + } + + # authentication setting, if any + my $auth_settings = [qw()]; + + # make the API Call + $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + return; +} + # # test_query_parameter_collection_format # diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm new file mode 100644 index 00000000000..cc553f3c22f --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm @@ -0,0 +1,255 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Object::ChildWithNullable; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use WWW::OpenAPIClient::Object::ParentWithNullable; + +use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::ParentWithNullable"); + +# +# +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. +# REF: https://openapi-generator.tech +# + +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('openapi_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new plain object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + $self->init(%args); + + return $self; +} + +# initialize the object +sub init +{ + my ($self, %args) = @_; + + foreach my $attribute (keys %{$self->attribute_map}) { + my $args_key = $self->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + # initialize parent object ParentWithNullable + $self->WWW::OpenAPIClient::Object::ParentWithNullable::init(%args); +} + +# return perl hash +sub to_hash { + my $self = shift; + my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); + + # call ParentWithNullable to_hash and then combine hash + $_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::ParentWithNullable::to_hash }; + + return $_hash; +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + my $_json_attribute = $self->attribute_map->{$_key}; + my $_type = $self->openapi_types->{$_key}; + my $_value = $self->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + $_data->{$_json_attribute} = [ map { $self->_to_json_primitives($_subclass, $_) } @$_value ]; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$_value}) { + $_hash{$_key} = $self->_to_json_primitives($_subclass, $_element); + } + $_data->{$_json_attribute} = \%_hash; + } elsif ( grep( /^$_type$/, ('int', 'double', 'string', 'boolean', 'DATE', 'DATE_TIME'))) { + $_data->{$_json_attribute} = $self->_to_json_primitives($_type, $_value); + } else { + $_data->{$_json_attribute} = $_value; + } + } + } + + # combine parent (ParentWithNullable) TO_JSON + $_data = { %$_data, %$self->WWW::OpenAPIClient::Object::ParentWithNullable::TO_JSON }; + + return $_data; +} + +# to_json non-array data +sub _to_json_primitives { + my ($self, $type, $data) = @_; + if ( grep( /^$type$/, ('int', 'double'))) { + # https://metacpan.org/pod/JSON#simple-scalars + # numify it, ensuring it will be dumped as a number + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + # https://metacpan.org/pod/JSON#simple-scalars + # stringified + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + # https://metacpan.org/pod/JSON#JSON::true,-JSON::false,-JSON::null + return $data ? \1 : \0; + } elsif ($type eq 'DATE') { + return undef unless defined $data; + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Eymd($optional_separator),-$dt-%3Emdy(...),-$dt-%3Edmy(...) + return $data->ymd; + } + return $data .q(); + } elsif ($type eq 'DATE_TIME') { + return undef unless defined $data; + # the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Erfc3339 + return $data->rfc3339; + } + return $data .q(); + } else { # hash (model), In this case, the TO_JSON of the $data object is executed + return $data; + } +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use openapi_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->openapi_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { + $_hash{$_key} = $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \%_hash; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + # call parent (ParentWithNullable) from_hash + $self->WWW::OpenAPIClient::Object::ParentWithNullable::from_hash($hash); + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double'))) { + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + return !!$data; + } else { # hash(model) + my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + +__PACKAGE__->class_documentation({description => '', + class => 'ChildWithNullable', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'other_property' => { + datatype => 'string', + base_name => 'otherProperty', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->openapi_types( { + 'other_property' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'other_property' => 'otherProperty' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm new file mode 100644 index 00000000000..590c2782fa1 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm @@ -0,0 +1,242 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Object::DeprecatedObject; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + + +use base ("Class::Accessor", "Class::Data::Inheritable"); + +# +# +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. +# REF: https://openapi-generator.tech +# + +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('openapi_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new plain object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + $self->init(%args); + + return $self; +} + +# initialize the object +sub init +{ + my ($self, %args) = @_; + + foreach my $attribute (keys %{$self->attribute_map}) { + my $args_key = $self->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } +} + +# return perl hash +sub to_hash { + my $self = shift; + my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); + + return $_hash; +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + my $_json_attribute = $self->attribute_map->{$_key}; + my $_type = $self->openapi_types->{$_key}; + my $_value = $self->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + $_data->{$_json_attribute} = [ map { $self->_to_json_primitives($_subclass, $_) } @$_value ]; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$_value}) { + $_hash{$_key} = $self->_to_json_primitives($_subclass, $_element); + } + $_data->{$_json_attribute} = \%_hash; + } elsif ( grep( /^$_type$/, ('int', 'double', 'string', 'boolean', 'DATE', 'DATE_TIME'))) { + $_data->{$_json_attribute} = $self->_to_json_primitives($_type, $_value); + } else { + $_data->{$_json_attribute} = $_value; + } + } + } + + return $_data; +} + +# to_json non-array data +sub _to_json_primitives { + my ($self, $type, $data) = @_; + if ( grep( /^$type$/, ('int', 'double'))) { + # https://metacpan.org/pod/JSON#simple-scalars + # numify it, ensuring it will be dumped as a number + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + # https://metacpan.org/pod/JSON#simple-scalars + # stringified + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + # https://metacpan.org/pod/JSON#JSON::true,-JSON::false,-JSON::null + return $data ? \1 : \0; + } elsif ($type eq 'DATE') { + return undef unless defined $data; + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Eymd($optional_separator),-$dt-%3Emdy(...),-$dt-%3Edmy(...) + return $data->ymd; + } + return $data .q(); + } elsif ($type eq 'DATE_TIME') { + return undef unless defined $data; + # the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Erfc3339 + return $data->rfc3339; + } + return $data .q(); + } else { # hash (model), In this case, the TO_JSON of the $data object is executed + return $data; + } +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use openapi_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->openapi_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { + $_hash{$_key} = $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \%_hash; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double'))) { + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + return !!$data; + } else { # hash(model) + my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + +__PACKAGE__->class_documentation({description => '', + class => 'DeprecatedObject', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'name' => { + datatype => 'string', + base_name => 'name', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->openapi_types( { + 'name' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'name' => 'name' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm new file mode 100644 index 00000000000..41e0c7927f2 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm @@ -0,0 +1,251 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Object::ParentWithNullable; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + + +use base ("Class::Accessor", "Class::Data::Inheritable"); + +# +# +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. +# REF: https://openapi-generator.tech +# + +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('openapi_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new plain object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + $self->init(%args); + + return $self; +} + +# initialize the object +sub init +{ + my ($self, %args) = @_; + + foreach my $attribute (keys %{$self->attribute_map}) { + my $args_key = $self->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } +} + +# return perl hash +sub to_hash { + my $self = shift; + my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); + + return $_hash; +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + my $_json_attribute = $self->attribute_map->{$_key}; + my $_type = $self->openapi_types->{$_key}; + my $_value = $self->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + $_data->{$_json_attribute} = [ map { $self->_to_json_primitives($_subclass, $_) } @$_value ]; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$_value}) { + $_hash{$_key} = $self->_to_json_primitives($_subclass, $_element); + } + $_data->{$_json_attribute} = \%_hash; + } elsif ( grep( /^$_type$/, ('int', 'double', 'string', 'boolean', 'DATE', 'DATE_TIME'))) { + $_data->{$_json_attribute} = $self->_to_json_primitives($_type, $_value); + } else { + $_data->{$_json_attribute} = $_value; + } + } + } + + return $_data; +} + +# to_json non-array data +sub _to_json_primitives { + my ($self, $type, $data) = @_; + if ( grep( /^$type$/, ('int', 'double'))) { + # https://metacpan.org/pod/JSON#simple-scalars + # numify it, ensuring it will be dumped as a number + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + # https://metacpan.org/pod/JSON#simple-scalars + # stringified + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + # https://metacpan.org/pod/JSON#JSON::true,-JSON::false,-JSON::null + return $data ? \1 : \0; + } elsif ($type eq 'DATE') { + return undef unless defined $data; + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Eymd($optional_separator),-$dt-%3Emdy(...),-$dt-%3Edmy(...) + return $data->ymd; + } + return $data .q(); + } elsif ($type eq 'DATE_TIME') { + return undef unless defined $data; + # the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Erfc3339 + return $data->rfc3339; + } + return $data .q(); + } else { # hash (model), In this case, the TO_JSON of the $data object is executed + return $data; + } +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use openapi_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->openapi_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { + $_hash{$_key} = $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \%_hash; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double'))) { + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + return !!$data; + } else { # hash(model) + my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + +__PACKAGE__->class_documentation({description => '', + class => 'ParentWithNullable', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'type' => { + datatype => 'string', + base_name => 'type', + description => '', + format => '', + read_only => '', + }, + 'nullable_property' => { + datatype => 'string', + base_name => 'nullableProperty', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->openapi_types( { + 'type' => 'string', + 'nullable_property' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'type' => 'type', + 'nullable_property' => 'nullableProperty' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/t/ChildWithNullableTest.t b/samples/client/petstore/perl/t/ChildWithNullableTest.t new file mode 100644 index 00000000000..2823fc4b3cc --- /dev/null +++ b/samples/client/petstore/perl/t/ChildWithNullableTest.t @@ -0,0 +1,34 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the OpenAPI Generator +# Please update the test cases below to test the model. +# Ref: https://openapi-generator.tech +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::OpenAPIClient::Object::ChildWithNullable'); + +# uncomment below and update the test +#my $instance = WWW::OpenAPIClient::Object::ChildWithNullable->new(); +# +#isa_ok($instance, 'WWW::OpenAPIClient::Object::ChildWithNullable'); + diff --git a/samples/client/petstore/perl/t/DeprecatedObjectTest.t b/samples/client/petstore/perl/t/DeprecatedObjectTest.t new file mode 100644 index 00000000000..485a695b4bb --- /dev/null +++ b/samples/client/petstore/perl/t/DeprecatedObjectTest.t @@ -0,0 +1,34 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the OpenAPI Generator +# Please update the test cases below to test the model. +# Ref: https://openapi-generator.tech +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::OpenAPIClient::Object::DeprecatedObject'); + +# uncomment below and update the test +#my $instance = WWW::OpenAPIClient::Object::DeprecatedObject->new(); +# +#isa_ok($instance, 'WWW::OpenAPIClient::Object::DeprecatedObject'); + diff --git a/samples/client/petstore/perl/t/ParentWithNullableTest.t b/samples/client/petstore/perl/t/ParentWithNullableTest.t new file mode 100644 index 00000000000..8ee9800aa3c --- /dev/null +++ b/samples/client/petstore/perl/t/ParentWithNullableTest.t @@ -0,0 +1,34 @@ +=begin comment + +OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the OpenAPI Generator +# Please update the test cases below to test the model. +# Ref: https://openapi-generator.tech +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::OpenAPIClient::Object::ParentWithNullable'); + +# uncomment below and update the test +#my $instance = WWW::OpenAPIClient::Object::ParentWithNullable->new(); +# +#isa_ok($instance, 'WWW::OpenAPIClient::Object::ParentWithNullable'); + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES index 35ba332017c..b7160868e12 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES @@ -21,6 +21,7 @@ docs/Model/ArrayTest.md docs/Model/Capitalization.md docs/Model/Cat.md docs/Model/Category.md +docs/Model/ChildWithNullable.md docs/Model/ClassModel.md docs/Model/Client.md docs/Model/DeprecatedObject.md @@ -52,6 +53,7 @@ docs/Model/OuterEnumDefaultValue.md docs/Model/OuterEnumInteger.md docs/Model/OuterEnumIntegerDefaultValue.md docs/Model/OuterObjectWithEnumProperty.md +docs/Model/ParentWithNullable.md docs/Model/Pet.md docs/Model/ReadOnlyFirst.md docs/Model/SingleRefType.md @@ -80,6 +82,7 @@ src/Model/ArrayTest.php src/Model/Capitalization.php src/Model/Cat.php src/Model/Category.php +src/Model/ChildWithNullable.php src/Model/ClassModel.php src/Model/Client.php src/Model/DeprecatedObject.php @@ -112,6 +115,7 @@ src/Model/OuterEnumDefaultValue.php src/Model/OuterEnumInteger.php src/Model/OuterEnumIntegerDefaultValue.php src/Model/OuterObjectWithEnumProperty.php +src/Model/ParentWithNullable.php src/Model/Pet.php src/Model/ReadOnlyFirst.php src/Model/SingleRefType.php diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md index e64a5a4b49c..201cf56d7fb 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md @@ -90,6 +90,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/Api/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/Api/FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/Api/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -126,6 +127,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Model/Capitalization.md) - [Cat](docs/Model/Cat.md) - [Category](docs/Model/Category.md) +- [ChildWithNullable](docs/Model/ChildWithNullable.md) - [ClassModel](docs/Model/ClassModel.md) - [Client](docs/Model/Client.md) - [DeprecatedObject](docs/Model/DeprecatedObject.md) @@ -157,6 +159,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/Model/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/Model/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/Model/OuterObjectWithEnumProperty.md) +- [ParentWithNullable](docs/Model/ParentWithNullable.md) - [Pet](docs/Model/Pet.md) - [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md) - [SingleRefType](docs/Model/SingleRefType.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md index 6de683cdd9c..67f8694a75f 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati | [**testGroupParameters()**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties()**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData()**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable()**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat()**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1032,6 +1033,61 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `testNullable()` + +```php +testNullable($child_with_nullable) +``` + +test nullable parent property + + + +### Example + +```php +testNullable($child_with_nullable); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testNullable: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **child_with_nullable** | [**\OpenAPI\Client\Model\ChildWithNullable**](../Model/ChildWithNullable.md)| request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `testQueryParameterCollectionFormat()` ```php diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md new file mode 100644 index 00000000000..be4cea23a36 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md @@ -0,0 +1,9 @@ +# # ChildWithNullable + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**other_property** | **string** | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md new file mode 100644 index 00000000000..8f8080ef141 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md @@ -0,0 +1,10 @@ +# # ParentWithNullable + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | | [optional] +**nullable_property** | **string** | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php index 3ee2e738229..54e19d6cf9c 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php @@ -123,6 +123,9 @@ class FakeApi 'testJsonFormData' => [ 'application/x-www-form-urlencoded', ], + 'testNullable' => [ + 'application/json', + ], 'testQueryParameterCollectionFormat' => [ 'application/json', ], @@ -4803,6 +4806,234 @@ class FakeApi ); } + /** + * Operation testNullable + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testNullable($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + $this->testNullableWithHttpInfo($child_with_nullable, $contentType); + } + + /** + * Operation testNullableWithHttpInfo + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function testNullableWithHttpInfo($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + $request = $this->testNullableRequest($child_with_nullable, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation testNullableAsync + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testNullableAsync($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + return $this->testNullableAsyncWithHttpInfo($child_with_nullable, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testNullableAsyncWithHttpInfo + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testNullableAsyncWithHttpInfo($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + $returnType = ''; + $request = $this->testNullableRequest($child_with_nullable, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testNullable' + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function testNullableRequest($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + + // verify the required parameter 'child_with_nullable' is set + if ($child_with_nullable === null || (is_array($child_with_nullable) && count($child_with_nullable) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $child_with_nullable when calling testNullable' + ); + } + + + $resourcePath = '/fake/nullable'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($child_with_nullable)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($child_with_nullable)); + } else { + $httpBody = $child_with_nullable; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation testQueryParameterCollectionFormat * diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php new file mode 100644 index 00000000000..1dea6bea779 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php @@ -0,0 +1,403 @@ + + */ +class ChildWithNullable extends ParentWithNullable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChildWithNullable'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'other_property' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'other_property' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'other_property' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes + parent::openAPITypes(); + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats + parent::openAPIFormats(); + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'other_property' => 'otherProperty' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'other_property' => 'setOtherProperty' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'other_property' => 'getOtherProperty' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return parent::attributeMap() + self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return parent::setters() + self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return parent::getters() + self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + parent::__construct($data); + + $this->setIfExists('other_property', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = parent::listInvalidProperties(); + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets other_property + * + * @return string|null + */ + public function getOtherProperty() + { + return $this->container['other_property']; + } + + /** + * Sets other_property + * + * @param string|null $other_property other_property + * + * @return self + */ + public function setOtherProperty($other_property) + { + if (is_null($other_property)) { + throw new \InvalidArgumentException('non-nullable other_property cannot be null'); + } + $this->container['other_property'] = $other_property; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php new file mode 100644 index 00000000000..e000ef7cf5f --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php @@ -0,0 +1,485 @@ + + */ +class ParentWithNullable implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = 'type'; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParentWithNullable'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'nullable_property' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'nullable_property' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'nullable_property' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'nullable_property' => 'nullableProperty' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'nullable_property' => 'setNullableProperty' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'nullable_property' => 'getNullableProperty' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_CHILD_WITH_NULLABLE = 'ChildWithNullable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_CHILD_WITH_NULLABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('nullable_property', $data ?? [], null); + + // Initialize discriminator property with the model name. + $this->container['type'] = static::$openAPIModelName; + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets nullable_property + * + * @return string|null + */ + public function getNullableProperty() + { + return $this->container['nullable_property']; + } + + /** + * Sets nullable_property + * + * @param string|null $nullable_property nullable_property + * + * @return self + */ + public function setNullableProperty($nullable_property) + { + if (is_null($nullable_property)) { + array_push($this->openAPINullablesSetToNull, 'nullable_property'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('nullable_property', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['nullable_property'] = $nullable_property; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php new file mode 100644 index 00000000000..ec5f69960a5 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php @@ -0,0 +1,90 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "other_property" + */ + public function testPropertyOtherProperty() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php new file mode 100644 index 00000000000..05f491afca8 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php @@ -0,0 +1,99 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "nullable_property" + */ + public function testPropertyNullableProperty() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 new file mode 100644 index 00000000000..5ec4e8b92f1 --- /dev/null +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 @@ -0,0 +1,97 @@ +# +# OpenAPI Petstore +# This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: "" \ +# Version: 1.0.0 +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Name +No description available. +.OUTPUTS + +ModelMapping +#> + +function Initialize-PSModelMapping { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [String] + ${Name} + ) + + Process { + 'Creating PSCustomObject: PSPetstore => PSModelMapping' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "name" = ${Name} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to ModelMapping + +.DESCRIPTION + +Convert from JSON to ModelMapping + +.PARAMETER Json + +Json object + +.OUTPUTS + +ModelMapping +#> +function ConvertFrom-PSJsonToModelMapping { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSPetstore => PSModelMapping' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in PSModelMapping + $AllProperties = ("name") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found + $Name = $null + } else { + $Name = $JsonParameters.PSobject.Properties["name"].value + } + + $PSO = [PSCustomObject]@{ + "name" = ${Name} + } + + return $PSO + } + +} + diff --git a/samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 b/samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 new file mode 100644 index 00000000000..c6c051a88bd --- /dev/null +++ b/samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 @@ -0,0 +1,17 @@ +# +# OpenAPI Petstore +# This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: "" \ +# Version: 1.0.0 +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSPetstore' -name 'PSModelMapping' { + Context 'PSModelMapping' { + It 'Initialize-PSModelMapping' { + # a simple test to create an object + #$NewObject = Initialize-PSModelMapping -Name "TEST_VALUE" + #$NewObject | Should -BeOfType ModelMapping + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES index ed16a1e03d1..f005dcee552 100644 --- a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES @@ -17,6 +17,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -51,6 +52,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -82,6 +84,7 @@ lib/petstore/models/array_test.rb lib/petstore/models/capitalization.rb lib/petstore/models/cat.rb lib/petstore/models/category.rb +lib/petstore/models/child_with_nullable.rb lib/petstore/models/class_model.rb lib/petstore/models/client.rb lib/petstore/models/deprecated_object.rb @@ -113,6 +116,7 @@ lib/petstore/models/outer_enum_default_value.rb lib/petstore/models/outer_enum_integer.rb lib/petstore/models/outer_enum_integer_default_value.rb lib/petstore/models/outer_object_with_enum_property.rb +lib/petstore/models/parent_with_nullable.rb lib/petstore/models/pet.rb lib/petstore/models/read_only_first.rb lib/petstore/models/single_ref_type.rb diff --git a/samples/client/petstore/ruby-autoload/README.md b/samples/client/petstore/ruby-autoload/README.md index 24656471c4b..ee269a91bf6 100644 --- a/samples/client/petstore/ruby-autoload/README.md +++ b/samples/client/petstore/ruby-autoload/README.md @@ -94,6 +94,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*Petstore::FakeApi* | [**test_nullable**](docs/FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property *Petstore::FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store @@ -131,6 +132,7 @@ Class | Method | HTTP request | Description - [Petstore::Capitalization](docs/Capitalization.md) - [Petstore::Cat](docs/Cat.md) - [Petstore::Category](docs/Category.md) + - [Petstore::ChildWithNullable](docs/ChildWithNullable.md) - [Petstore::ClassModel](docs/ClassModel.md) - [Petstore::Client](docs/Client.md) - [Petstore::DeprecatedObject](docs/DeprecatedObject.md) @@ -162,6 +164,7 @@ Class | Method | HTTP request | Description - [Petstore::OuterEnumInteger](docs/OuterEnumInteger.md) - [Petstore::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [Petstore::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [Petstore::ParentWithNullable](docs/ParentWithNullable.md) - [Petstore::Pet](docs/Pet.md) - [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Petstore::SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md b/samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md new file mode 100644 index 00000000000..3e6ffffc4d3 --- /dev/null +++ b/samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md @@ -0,0 +1,18 @@ +# Petstore::ChildWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **other_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ChildWithNullable.new( + other_property: null +) +``` + diff --git a/samples/client/petstore/ruby-autoload/docs/FakeApi.md b/samples/client/petstore/ruby-autoload/docs/FakeApi.md index 505e754f5ed..3980b6c60d2 100644 --- a/samples/client/petstore/ruby-autoload/docs/FakeApi.md +++ b/samples/client/petstore/ruby-autoload/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**test_nullable**](FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property | | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | | @@ -1181,6 +1182,69 @@ No authorization required - **Accept**: Not defined +## test_nullable + +> test_nullable(child_with_nullable) + +test nullable parent property + + + +### Examples + +```ruby +require 'time' +require 'petstore' + +api_instance = Petstore::FakeApi.new +child_with_nullable = Petstore::ChildWithNullable.new # ChildWithNullable | request body + +begin + # test nullable parent property + api_instance.test_nullable(child_with_nullable) +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable: #{e}" +end +``` + +#### Using the test_nullable_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> test_nullable_with_http_info(child_with_nullable) + +```ruby +begin + # test nullable parent property + data, status_code, headers = api_instance.test_nullable_with_http_info(child_with_nullable) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **child_with_nullable** | [**ChildWithNullable**](ChildWithNullable.md) | request body | | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + ## test_query_parameter_collection_format > test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, opts) diff --git a/samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md b/samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md new file mode 100644 index 00000000000..0c77bf999dc --- /dev/null +++ b/samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md @@ -0,0 +1,20 @@ +# Petstore::ParentWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | [optional] | +| **nullable_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ParentWithNullable.new( + type: null, + nullable_property: null +) +``` + diff --git a/samples/client/petstore/ruby-autoload/lib/petstore.rb b/samples/client/petstore/ruby-autoload/lib/petstore.rb index 4fc54294b59..c4354c2b312 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore.rb @@ -27,6 +27,7 @@ Petstore.autoload :ArrayTest, 'petstore/models/array_test' Petstore.autoload :Capitalization, 'petstore/models/capitalization' Petstore.autoload :Cat, 'petstore/models/cat' Petstore.autoload :Category, 'petstore/models/category' +Petstore.autoload :ChildWithNullable, 'petstore/models/child_with_nullable' Petstore.autoload :ClassModel, 'petstore/models/class_model' Petstore.autoload :Client, 'petstore/models/client' Petstore.autoload :DeprecatedObject, 'petstore/models/deprecated_object' @@ -58,6 +59,7 @@ Petstore.autoload :OuterEnumDefaultValue, 'petstore/models/outer_enum_default_va Petstore.autoload :OuterEnumInteger, 'petstore/models/outer_enum_integer' Petstore.autoload :OuterEnumIntegerDefaultValue, 'petstore/models/outer_enum_integer_default_value' Petstore.autoload :OuterObjectWithEnumProperty, 'petstore/models/outer_object_with_enum_property' +Petstore.autoload :ParentWithNullable, 'petstore/models/parent_with_nullable' Petstore.autoload :Pet, 'petstore/models/pet' Petstore.autoload :ReadOnlyFirst, 'petstore/models/read_only_first' Petstore.autoload :SingleRefType, 'petstore/models/single_ref_type' diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb index 554b0a48bc0..06e12cd00e5 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb @@ -1294,6 +1294,72 @@ module Petstore return data, status_code, headers end + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [nil] + def test_nullable(child_with_nullable, opts = {}) + test_nullable_with_http_info(child_with_nullable, opts) + nil + end + + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_nullable_with_http_info(child_with_nullable, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_nullable ...' + end + # verify the required parameter 'child_with_nullable' is set + if @api_client.config.client_side_validation && child_with_nullable.nil? + fail ArgumentError, "Missing the required parameter 'child_with_nullable' when calling FakeApi.test_nullable" + end + # resource path + local_var_path = '/fake/nullable' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(child_with_nullable) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"FakeApi.test_nullable", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_nullable\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # To test the collection format in query parameters # @param pipe [Array] # @param ioutil [Array] diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb new file mode 100644 index 00000000000..e4027d5a7a0 --- /dev/null +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb @@ -0,0 +1,247 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ChildWithNullable < ParentWithNullable + attr_accessor :other_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'other_property' => :'otherProperty' + } + end + + # Returns all the JSON keys this model knows about, including the ones defined in its parent(s) + def self.acceptable_attributes + attribute_map.values.concat(superclass.acceptable_attributes) + end + + # Attribute type mapping. + def self.openapi_types + { + :'other_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ParentWithNullable' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ChildWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ChildWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + # call parent's initialize + super(attributes) + + if attributes.key?(:'other_property') + self.other_property = attributes[:'other_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = super + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true && super + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + other_property == o.other_property && super(o) + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [other_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + super(attributes) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = super + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb new file mode 100644 index 00000000000..80d5b087caa --- /dev/null +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb @@ -0,0 +1,263 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ParentWithNullable + attr_accessor :type + + attr_accessor :nullable_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'nullable_property' => :'nullableProperty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'nullable_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'nullable_property' + ]) + end + + # discriminator's property name in OpenAPI v3 + def self.openapi_discriminator_name + :'type' + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ParentWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ParentWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'nullable_property') + self.nullable_property = attributes[:'nullable_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + nullable_property == o.nullable_property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, nullable_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb b/samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb new file mode 100644 index 00000000000..2858c0502db --- /dev/null +++ b/samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb @@ -0,0 +1,34 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ChildWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ChildWithNullable do + let(:instance) { Petstore::ChildWithNullable.new } + + describe 'test an instance of ChildWithNullable' do + it 'should create an instance of ChildWithNullable' do + expect(instance).to be_instance_of(Petstore::ChildWithNullable) + end + end + describe 'test attribute "other_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb b/samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb new file mode 100644 index 00000000000..76382049704 --- /dev/null +++ b/samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb @@ -0,0 +1,44 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ParentWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ParentWithNullable do + let(:instance) { Petstore::ParentWithNullable.new } + + describe 'test an instance of ParentWithNullable' do + it 'should create an instance of ParentWithNullable' do + expect(instance).to be_instance_of(Petstore::ParentWithNullable) + end + end + describe 'test attribute "type"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["ChildWithNullable"]) + # validator.allowable_values.each do |value| + # expect { instance.type = value }.not_to raise_error + # end + end + end + + describe 'test attribute "nullable_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES index ed16a1e03d1..f005dcee552 100644 --- a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES @@ -17,6 +17,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -51,6 +52,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -82,6 +84,7 @@ lib/petstore/models/array_test.rb lib/petstore/models/capitalization.rb lib/petstore/models/cat.rb lib/petstore/models/category.rb +lib/petstore/models/child_with_nullable.rb lib/petstore/models/class_model.rb lib/petstore/models/client.rb lib/petstore/models/deprecated_object.rb @@ -113,6 +116,7 @@ lib/petstore/models/outer_enum_default_value.rb lib/petstore/models/outer_enum_integer.rb lib/petstore/models/outer_enum_integer_default_value.rb lib/petstore/models/outer_object_with_enum_property.rb +lib/petstore/models/parent_with_nullable.rb lib/petstore/models/pet.rb lib/petstore/models/read_only_first.rb lib/petstore/models/single_ref_type.rb diff --git a/samples/client/petstore/ruby-faraday/README.md b/samples/client/petstore/ruby-faraday/README.md index 24656471c4b..ee269a91bf6 100644 --- a/samples/client/petstore/ruby-faraday/README.md +++ b/samples/client/petstore/ruby-faraday/README.md @@ -94,6 +94,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*Petstore::FakeApi* | [**test_nullable**](docs/FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property *Petstore::FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store @@ -131,6 +132,7 @@ Class | Method | HTTP request | Description - [Petstore::Capitalization](docs/Capitalization.md) - [Petstore::Cat](docs/Cat.md) - [Petstore::Category](docs/Category.md) + - [Petstore::ChildWithNullable](docs/ChildWithNullable.md) - [Petstore::ClassModel](docs/ClassModel.md) - [Petstore::Client](docs/Client.md) - [Petstore::DeprecatedObject](docs/DeprecatedObject.md) @@ -162,6 +164,7 @@ Class | Method | HTTP request | Description - [Petstore::OuterEnumInteger](docs/OuterEnumInteger.md) - [Petstore::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [Petstore::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [Petstore::ParentWithNullable](docs/ParentWithNullable.md) - [Petstore::Pet](docs/Pet.md) - [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Petstore::SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md b/samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md new file mode 100644 index 00000000000..3e6ffffc4d3 --- /dev/null +++ b/samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md @@ -0,0 +1,18 @@ +# Petstore::ChildWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **other_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ChildWithNullable.new( + other_property: null +) +``` + diff --git a/samples/client/petstore/ruby-faraday/docs/FakeApi.md b/samples/client/petstore/ruby-faraday/docs/FakeApi.md index 505e754f5ed..3980b6c60d2 100644 --- a/samples/client/petstore/ruby-faraday/docs/FakeApi.md +++ b/samples/client/petstore/ruby-faraday/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**test_nullable**](FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property | | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | | @@ -1181,6 +1182,69 @@ No authorization required - **Accept**: Not defined +## test_nullable + +> test_nullable(child_with_nullable) + +test nullable parent property + + + +### Examples + +```ruby +require 'time' +require 'petstore' + +api_instance = Petstore::FakeApi.new +child_with_nullable = Petstore::ChildWithNullable.new # ChildWithNullable | request body + +begin + # test nullable parent property + api_instance.test_nullable(child_with_nullable) +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable: #{e}" +end +``` + +#### Using the test_nullable_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> test_nullable_with_http_info(child_with_nullable) + +```ruby +begin + # test nullable parent property + data, status_code, headers = api_instance.test_nullable_with_http_info(child_with_nullable) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **child_with_nullable** | [**ChildWithNullable**](ChildWithNullable.md) | request body | | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + ## test_query_parameter_collection_format > test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, opts) diff --git a/samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md b/samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md new file mode 100644 index 00000000000..0c77bf999dc --- /dev/null +++ b/samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md @@ -0,0 +1,20 @@ +# Petstore::ParentWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | [optional] | +| **nullable_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ParentWithNullable.new( + type: null, + nullable_property: null +) +``` + diff --git a/samples/client/petstore/ruby-faraday/lib/petstore.rb b/samples/client/petstore/ruby-faraday/lib/petstore.rb index 2a151767395..6c6330b609e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore.rb @@ -56,6 +56,7 @@ require 'petstore/models/outer_enum_default_value' require 'petstore/models/outer_enum_integer' require 'petstore/models/outer_enum_integer_default_value' require 'petstore/models/outer_object_with_enum_property' +require 'petstore/models/parent_with_nullable' require 'petstore/models/pet' require 'petstore/models/read_only_first' require 'petstore/models/single_ref_type' @@ -63,6 +64,7 @@ require 'petstore/models/special_model_name' require 'petstore/models/tag' require 'petstore/models/user' require 'petstore/models/cat' +require 'petstore/models/child_with_nullable' require 'petstore/models/dog' # APIs diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb index 554b0a48bc0..06e12cd00e5 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb @@ -1294,6 +1294,72 @@ module Petstore return data, status_code, headers end + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [nil] + def test_nullable(child_with_nullable, opts = {}) + test_nullable_with_http_info(child_with_nullable, opts) + nil + end + + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_nullable_with_http_info(child_with_nullable, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_nullable ...' + end + # verify the required parameter 'child_with_nullable' is set + if @api_client.config.client_side_validation && child_with_nullable.nil? + fail ArgumentError, "Missing the required parameter 'child_with_nullable' when calling FakeApi.test_nullable" + end + # resource path + local_var_path = '/fake/nullable' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(child_with_nullable) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"FakeApi.test_nullable", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_nullable\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # To test the collection format in query parameters # @param pipe [Array] # @param ioutil [Array] diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb new file mode 100644 index 00000000000..e4027d5a7a0 --- /dev/null +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb @@ -0,0 +1,247 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ChildWithNullable < ParentWithNullable + attr_accessor :other_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'other_property' => :'otherProperty' + } + end + + # Returns all the JSON keys this model knows about, including the ones defined in its parent(s) + def self.acceptable_attributes + attribute_map.values.concat(superclass.acceptable_attributes) + end + + # Attribute type mapping. + def self.openapi_types + { + :'other_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ParentWithNullable' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ChildWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ChildWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + # call parent's initialize + super(attributes) + + if attributes.key?(:'other_property') + self.other_property = attributes[:'other_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = super + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true && super + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + other_property == o.other_property && super(o) + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [other_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + super(attributes) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = super + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb new file mode 100644 index 00000000000..80d5b087caa --- /dev/null +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb @@ -0,0 +1,263 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ParentWithNullable + attr_accessor :type + + attr_accessor :nullable_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'nullable_property' => :'nullableProperty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'nullable_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'nullable_property' + ]) + end + + # discriminator's property name in OpenAPI v3 + def self.openapi_discriminator_name + :'type' + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ParentWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ParentWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'nullable_property') + self.nullable_property = attributes[:'nullable_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + nullable_property == o.nullable_property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, nullable_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb new file mode 100644 index 00000000000..2858c0502db --- /dev/null +++ b/samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb @@ -0,0 +1,34 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ChildWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ChildWithNullable do + let(:instance) { Petstore::ChildWithNullable.new } + + describe 'test an instance of ChildWithNullable' do + it 'should create an instance of ChildWithNullable' do + expect(instance).to be_instance_of(Petstore::ChildWithNullable) + end + end + describe 'test attribute "other_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb new file mode 100644 index 00000000000..76382049704 --- /dev/null +++ b/samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb @@ -0,0 +1,44 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +The version of the OpenAPI document: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ParentWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ParentWithNullable do + let(:instance) { Petstore::ParentWithNullable.new } + + describe 'test an instance of ParentWithNullable' do + it 'should create an instance of ParentWithNullable' do + expect(instance).to be_instance_of(Petstore::ParentWithNullable) + end + end + describe 'test attribute "type"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["ChildWithNullable"]) + # validator.allowable_values.each do |value| + # expect { instance.type = value }.not_to raise_error + # end + end + end + + describe 'test attribute "nullable_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES b/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES index cce4fef430c..f91496ca5b5 100644 --- a/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES +++ b/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -46,6 +47,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java index 723d5e8c348..537d7e748a6 100644 --- a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -321,6 +322,24 @@ public interface FakeApi { ); + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @HttpExchange( + method = "POST", + value = "/fake/nullable", + accept = "application/json", + contentType = "application/json" + ) + Mono> testNullable( + @RequestBody Mono childWithNullable + ); + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..dc42ffccaf9 --- /dev/null +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,111 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 00000000000..9b071569af2 --- /dev/null +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,163 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/spring-http-interface/.openapi-generator/FILES b/samples/client/petstore/spring-http-interface/.openapi-generator/FILES index 3dc47a34021..69906eac967 100644 --- a/samples/client/petstore/spring-http-interface/.openapi-generator/FILES +++ b/samples/client/petstore/spring-http-interface/.openapi-generator/FILES @@ -24,6 +24,7 @@ src/main/java/org/openapitools/model/BigCatDto.java src/main/java/org/openapitools/model/CapitalizationDto.java src/main/java/org/openapitools/model/CatDto.java src/main/java/org/openapitools/model/CategoryDto.java +src/main/java/org/openapitools/model/ChildWithNullableDto.java src/main/java/org/openapitools/model/ClassModelDto.java src/main/java/org/openapitools/model/ClientDto.java src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -45,6 +46,7 @@ src/main/java/org/openapitools/model/NumberOnlyDto.java src/main/java/org/openapitools/model/OrderDto.java src/main/java/org/openapitools/model/OuterCompositeDto.java src/main/java/org/openapitools/model/OuterEnumDto.java +src/main/java/org/openapitools/model/ParentWithNullableDto.java src/main/java/org/openapitools/model/PetDto.java src/main/java/org/openapitools/model/ReadOnlyFirstDto.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNamesDto.java diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java index cd1c35c6adb..de4747c2d4c 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullableDto; import org.openapitools.model.ClientDto; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClassDto; @@ -317,6 +318,24 @@ public interface FakeApi { ); + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullableDto request body (required) + * @return successful operation (status code 200) + */ + @HttpExchange( + method = "POST", + value = "/fake/nullable", + accept = "application/json", + contentType = "application/json" + ) + ResponseEntity testNullable( + @RequestBody ChildWithNullableDto childWithNullableDto + ); + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java new file mode 100644 index 00000000000..2a21344c37b --- /dev/null +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java @@ -0,0 +1,113 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullableDto; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ChildWithNullableDto + */ + + +@JsonTypeName("ChildWithNullable") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullableDto extends ParentWithNullableDto { + + private String otherProperty; + + public ChildWithNullableDto otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullableDto type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullableDto nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullableDto childWithNullable = (ChildWithNullableDto) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullableDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java new file mode 100644 index 00000000000..ee8d6b570d0 --- /dev/null +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -0,0 +1,164 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ParentWithNullableDto + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullableDto.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullableDto { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullableDto type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullableDto nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullableDto parentWithNullable = (ParentWithNullableDto) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullableDto {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES b/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES index 0015dca0c83..ac49dcd75a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES @@ -16,6 +16,7 @@ models/ArrayTest.ts models/Capitalization.ts models/Cat.ts models/Category.ts +models/ChildWithNullable.ts models/ClassModel.ts models/Client.ts models/DeprecatedObject.ts @@ -47,6 +48,7 @@ models/OuterEnumDefaultValue.ts models/OuterEnumInteger.ts models/OuterEnumIntegerDefaultValue.ts models/OuterObjectWithEnumProperty.ts +models/ParentWithNullable.ts models/Pet.ts models/ReadOnlyFirst.ts models/Return.ts diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts index 0d9ea6361d7..06eb695d3fa 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts @@ -15,6 +15,7 @@ import * as runtime from '../runtime'; import type { + ChildWithNullable, Client, EnumClass, FakeBigDecimalMap200Response, @@ -26,6 +27,8 @@ import type { User, } from '../models/index'; import { + ChildWithNullableFromJSON, + ChildWithNullableToJSON, ClientFromJSON, ClientToJSON, EnumClassFromJSON, @@ -136,6 +139,10 @@ export interface TestJsonFormDataRequest { param2: string; } +export interface TestNullableRequest { + childWithNullable: ChildWithNullable; +} + export interface TestQueryParameterCollectionFormatRequest { pipe: Array; ioutil: Array; @@ -901,6 +908,40 @@ export class FakeApi extends runtime.BaseAPI { await this.testJsonFormDataRaw(requestParameters, initOverrides); } + /** + * + * test nullable parent property + */ + async testNullableRaw(requestParameters: TestNullableRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.childWithNullable === null || requestParameters.childWithNullable === undefined) { + throw new runtime.RequiredError('childWithNullable','Required parameter requestParameters.childWithNullable was null or undefined when calling testNullable.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/fake/nullable`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: ChildWithNullableToJSON(requestParameters.childWithNullable), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * + * test nullable parent property + */ + async testNullable(requestParameters: TestNullableRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.testNullableRaw(requestParameters, initOverrides); + } + /** * To test the collection format in query parameters */ diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts new file mode 100644 index 00000000000..4f53b0070e4 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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. + */ + +import { exists, mapValues } from '../runtime'; +import type { ParentWithNullable } from './ParentWithNullable'; +import { + ParentWithNullableFromJSON, + ParentWithNullableFromJSONTyped, + ParentWithNullableToJSON, +} from './ParentWithNullable'; + +/** + * + * @export + * @interface ChildWithNullable + */ +export interface ChildWithNullable extends ParentWithNullable { + /** + * + * @type {string} + * @memberof ChildWithNullable + */ + otherProperty?: string; +} + + + +/** + * Check if a given object implements the ChildWithNullable interface. + */ +export function instanceOfChildWithNullable(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ChildWithNullableFromJSON(json: any): ChildWithNullable { + return ChildWithNullableFromJSONTyped(json, false); +} + +export function ChildWithNullableFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChildWithNullable { + if ((json === undefined) || (json === null)) { + return json; + } + return { + ...ParentWithNullableFromJSONTyped(json, ignoreDiscriminator), + 'otherProperty': !exists(json, 'otherProperty') ? undefined : json['otherProperty'], + }; +} + +export function ChildWithNullableToJSON(value?: ChildWithNullable | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + ...ParentWithNullableToJSON(value), + 'otherProperty': value.otherProperty, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts new file mode 100644 index 00000000000..67c7574c229 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts @@ -0,0 +1,92 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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. + */ + +import { exists, mapValues } from '../runtime'; +import { + ChildWithNullableFromJSONTyped +} from './index'; + +/** + * + * @export + * @interface ParentWithNullable + */ +export interface ParentWithNullable { + /** + * + * @type {string} + * @memberof ParentWithNullable + */ + type?: ParentWithNullableTypeEnum; + /** + * + * @type {string} + * @memberof ParentWithNullable + */ + nullableProperty?: string | null; +} + + +/** + * @export + */ +export const ParentWithNullableTypeEnum = { + ChildWithNullable: 'ChildWithNullable' +} as const; +export type ParentWithNullableTypeEnum = typeof ParentWithNullableTypeEnum[keyof typeof ParentWithNullableTypeEnum]; + + +/** + * Check if a given object implements the ParentWithNullable interface. + */ +export function instanceOfParentWithNullable(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ParentWithNullableFromJSON(json: any): ParentWithNullable { + return ParentWithNullableFromJSONTyped(json, false); +} + +export function ParentWithNullableFromJSONTyped(json: any, ignoreDiscriminator: boolean): ParentWithNullable { + if ((json === undefined) || (json === null)) { + return json; + } + if (!ignoreDiscriminator) { + if (json['type'] === 'ChildWithNullable') { + return ChildWithNullableFromJSONTyped(json, true); + } + } + return { + + 'type': !exists(json, 'type') ? undefined : json['type'], + 'nullableProperty': !exists(json, 'nullableProperty') ? undefined : json['nullableProperty'], + }; +} + +export function ParentWithNullableToJSON(value?: ParentWithNullable | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': value.type, + 'nullableProperty': value.nullableProperty, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts index 20b510f62cb..1789038a2d9 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts @@ -9,6 +9,7 @@ export * from './ArrayTest'; export * from './Capitalization'; export * from './Cat'; export * from './Category'; +export * from './ChildWithNullable'; export * from './ClassModel'; export * from './Client'; export * from './DeprecatedObject'; @@ -40,6 +41,7 @@ export * from './OuterEnumDefaultValue'; export * from './OuterEnumInteger'; export * from './OuterEnumIntegerDefaultValue'; export * from './OuterObjectWithEnumProperty'; +export * from './ParentWithNullable'; export * from './Pet'; export * from './ReadOnlyFirst'; export * from './Return'; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES index fd331c256c8..9507ce9ce3f 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES @@ -13,6 +13,7 @@ doc/ArrayTest.md doc/Capitalization.md doc/Cat.md doc/Category.md +doc/ChildWithNullable.md doc/ClassModel.md doc/DefaultApi.md doc/DeprecatedObject.md @@ -47,6 +48,7 @@ doc/OuterEnumDefaultValue.md doc/OuterEnumInteger.md doc/OuterEnumIntegerDefaultValue.md doc/OuterObjectWithEnumProperty.md +doc/ParentWithNullable.md doc/Pet.md doc/PetApi.md doc/ReadOnlyFirst.md @@ -81,6 +83,7 @@ lib/src/model/array_test.dart lib/src/model/capitalization.dart lib/src/model/cat.dart lib/src/model/category.dart +lib/src/model/child_with_nullable.dart lib/src/model/class_model.dart lib/src/model/deprecated_object.dart lib/src/model/dog.dart @@ -112,6 +115,7 @@ lib/src/model/outer_enum_default_value.dart lib/src/model/outer_enum_integer.dart lib/src/model/outer_enum_integer_default_value.dart lib/src/model/outer_object_with_enum_property.dart +lib/src/model/parent_with_nullable.dart lib/src/model/pet.dart lib/src/model/read_only_first.dart lib/src/model/single_ref_type.dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md index 8506db54bbf..42ba566440d 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md @@ -84,6 +84,7 @@ Class | Method | HTTP request | Description [*FakeApi*](doc/FakeApi.md) | [**testGroupParameters**](doc/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [*FakeApi*](doc/FakeApi.md) | [**testInlineAdditionalProperties**](doc/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [*FakeApi*](doc/FakeApi.md) | [**testJsonFormData**](doc/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[*FakeApi*](doc/FakeApi.md) | [**testNullable**](doc/FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [*FakeApi*](doc/FakeApi.md) | [**testQueryParameterCollectionFormat**](doc/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | [*FakeClassnameTags123Api*](doc/FakeClassnameTags123Api.md) | [**testClassname**](doc/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case [*PetApi*](doc/PetApi.md) | [**addPet**](doc/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -121,6 +122,7 @@ Class | Method | HTTP request | Description - [Capitalization](doc/Capitalization.md) - [Cat](doc/Cat.md) - [Category](doc/Category.md) + - [ChildWithNullable](doc/ChildWithNullable.md) - [ClassModel](doc/ClassModel.md) - [DeprecatedObject](doc/DeprecatedObject.md) - [Dog](doc/Dog.md) @@ -152,6 +154,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](doc/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](doc/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](doc/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](doc/ParentWithNullable.md) - [Pet](doc/Pet.md) - [ReadOnlyFirst](doc/ReadOnlyFirst.md) - [SingleRefType](doc/SingleRefType.md) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md new file mode 100644 index 00000000000..770494fcf4c --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md @@ -0,0 +1,17 @@ +# openapi.model.ChildWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] +**otherProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md index 1587283037e..41328617a63 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**testGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[**testNullable**](FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [**testQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | @@ -800,6 +801,48 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **testNullable** +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example +```dart +import 'package:openapi/api.dart'; + +final api = Openapi().getFakeApi(); +final ChildWithNullable childWithNullable = ; // ChildWithNullable | request body + +try { + api.testNullable(childWithNullable); +} catch on DioException (e) { + print('Exception when calling FakeApi->testNullable: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **testQueryParameterCollectionFormat** > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md new file mode 100644 index 00000000000..17aa5ca0294 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md @@ -0,0 +1,16 @@ +# openapi.model.ParentWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart index 48d2103d57d..81f241899a7 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart @@ -26,6 +26,7 @@ export 'package:openapi/src/model/array_test.dart'; export 'package:openapi/src/model/capitalization.dart'; export 'package:openapi/src/model/cat.dart'; export 'package:openapi/src/model/category.dart'; +export 'package:openapi/src/model/child_with_nullable.dart'; export 'package:openapi/src/model/class_model.dart'; export 'package:openapi/src/model/deprecated_object.dart'; export 'package:openapi/src/model/dog.dart'; @@ -57,6 +58,7 @@ export 'package:openapi/src/model/outer_enum_default_value.dart'; export 'package:openapi/src/model/outer_enum_integer.dart'; export 'package:openapi/src/model/outer_enum_integer_default_value.dart'; export 'package:openapi/src/model/outer_object_with_enum_property.dart'; +export 'package:openapi/src/model/parent_with_nullable.dart'; export 'package:openapi/src/model/pet.dart'; export 'package:openapi/src/model/read_only_first.dart'; export 'package:openapi/src/model/single_ref_type.dart'; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart index a6dd002c83c..8335114effd 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart @@ -9,6 +9,7 @@ import 'dart:convert'; import 'package:openapi/src/deserialize.dart'; import 'package:dio/dio.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/fake_big_decimal_map200_response.dart'; import 'package:openapi/src/model/file_schema_test_class.dart'; import 'package:openapi/src/model/health_check_result.dart'; @@ -1377,6 +1378,71 @@ _bodyData=jsonEncode(requestBody); return _response; } + /// test nullable parent property + /// + /// + /// Parameters: + /// * [childWithNullable] - request body + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] + /// Throws [DioException] if API call or serialization fails + Future> testNullable({ + required ChildWithNullable childWithNullable, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/fake/nullable'; + final _options = Options( + method: r'POST', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { +_bodyData=jsonEncode(childWithNullable); + } catch(error, stackTrace) { + throw DioException( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioExceptionType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + return _response; + } + /// testQueryParameterCollectionFormat /// To test the collection format in query parameters /// diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart index 8babb656e60..6a8bc0d4704 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart @@ -8,6 +8,7 @@ import 'package:openapi/src/model/array_test.dart'; import 'package:openapi/src/model/capitalization.dart'; import 'package:openapi/src/model/cat.dart'; import 'package:openapi/src/model/category.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/class_model.dart'; import 'package:openapi/src/model/deprecated_object.dart'; import 'package:openapi/src/model/dog.dart'; @@ -34,6 +35,7 @@ import 'package:openapi/src/model/object_with_deprecated_fields.dart'; import 'package:openapi/src/model/order.dart'; import 'package:openapi/src/model/outer_composite.dart'; import 'package:openapi/src/model/outer_object_with_enum_property.dart'; +import 'package:openapi/src/model/parent_with_nullable.dart'; import 'package:openapi/src/model/pet.dart'; import 'package:openapi/src/model/read_only_first.dart'; import 'package:openapi/src/model/special_model_name.dart'; @@ -78,6 +80,8 @@ final _regMap = RegExp(r'^Map$'); return Cat.fromJson(value as Map) as ReturnType; case 'Category': return Category.fromJson(value as Map) as ReturnType; + case 'ChildWithNullable': + return ChildWithNullable.fromJson(value as Map) as ReturnType; case 'ClassModel': return ClassModel.fromJson(value as Map) as ReturnType; case 'DeprecatedObject': @@ -145,6 +149,8 @@ final _regMap = RegExp(r'^Map$'); case 'OuterObjectWithEnumProperty': return OuterObjectWithEnumProperty.fromJson(value as Map) as ReturnType; + case 'ParentWithNullable': + return ParentWithNullable.fromJson(value as Map) as ReturnType; case 'Pet': return Pet.fromJson(value as Map) as ReturnType; case 'ReadOnlyFirst': diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart new file mode 100644 index 00000000000..674a58ca893 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart @@ -0,0 +1,98 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:openapi/src/model/parent_with_nullable.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'child_with_nullable.g.dart'; + +// ignore_for_file: unused_import + + +@JsonSerializable( + checked: true, + createToJson: true, + disallowUnrecognizedKeys: false, + explicitToJson: true, +) +class ChildWithNullable { + /// Returns a new [ChildWithNullable] instance. + ChildWithNullable({ + + this.type, + + this.nullableProperty, + + this.otherProperty, + }); + + @JsonKey( + + name: r'type', + required: false, + includeIfNull: false + ) + + + final ChildWithNullableTypeEnum? type; + + + + @JsonKey( + + name: r'nullableProperty', + required: false, + includeIfNull: false + ) + + + final String? nullableProperty; + + + + @JsonKey( + + name: r'otherProperty', + required: false, + includeIfNull: false + ) + + + final String? otherProperty; + + + + @override + bool operator ==(Object other) => identical(this, other) || other is ChildWithNullable && + other.type == type && + other.nullableProperty == nullableProperty && + other.otherProperty == otherProperty; + + @override + int get hashCode => + type.hashCode + + (nullableProperty == null ? 0 : nullableProperty.hashCode) + + otherProperty.hashCode; + + factory ChildWithNullable.fromJson(Map json) => _$ChildWithNullableFromJson(json); + + Map toJson() => _$ChildWithNullableToJson(this); + + @override + String toString() { + return toJson().toString(); + } + +} + + +enum ChildWithNullableTypeEnum { + @JsonValue(r'ChildWithNullable') + childWithNullable, + @JsonValue(r'unknown_default_open_api') + unknownDefaultOpenApi, +} + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart new file mode 100644 index 00000000000..0490c4b2b07 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart @@ -0,0 +1,79 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:json_annotation/json_annotation.dart'; + +part 'parent_with_nullable.g.dart'; + + +@JsonSerializable( + checked: true, + createToJson: true, + disallowUnrecognizedKeys: false, + explicitToJson: true, +) +class ParentWithNullable { + /// Returns a new [ParentWithNullable] instance. + ParentWithNullable({ + + this.type, + + this.nullableProperty, + }); + + @JsonKey( + + name: r'type', + required: false, + includeIfNull: false + ) + + + final ParentWithNullableTypeEnum? type; + + + + @JsonKey( + + name: r'nullableProperty', + required: false, + includeIfNull: false + ) + + + final String? nullableProperty; + + + + @override + bool operator ==(Object other) => identical(this, other) || other is ParentWithNullable && + other.type == type && + other.nullableProperty == nullableProperty; + + @override + int get hashCode => + type.hashCode + + (nullableProperty == null ? 0 : nullableProperty.hashCode); + + factory ParentWithNullable.fromJson(Map json) => _$ParentWithNullableFromJson(json); + + Map toJson() => _$ParentWithNullableToJson(this); + + @override + String toString() { + return toJson().toString(); + } + +} + + +enum ParentWithNullableTypeEnum { + @JsonValue(r'ChildWithNullable') + childWithNullable, + @JsonValue(r'unknown_default_open_api') + unknownDefaultOpenApi, +} + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart new file mode 100644 index 00000000000..ce2afd9a8a6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart @@ -0,0 +1,26 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ChildWithNullable +void main() { + final ChildWithNullable? instance = /* ChildWithNullable(...) */ null; + // TODO add properties to the entity + + group(ChildWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + // String otherProperty + test('to test the property `otherProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart new file mode 100644 index 00000000000..b501d422062 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart @@ -0,0 +1,21 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ParentWithNullable +void main() { + final ParentWithNullable? instance = /* ParentWithNullable(...) */ null; + // TODO add properties to the entity + + group(ParentWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES index 1172e4bb425..b6f2734cf3f 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES @@ -12,6 +12,7 @@ doc/ArrayTest.md doc/Capitalization.md doc/Cat.md doc/Category.md +doc/ChildWithNullable.md doc/ClassModel.md doc/DefaultApi.md doc/DeprecatedObject.md @@ -46,6 +47,7 @@ doc/OuterEnumDefaultValue.md doc/OuterEnumInteger.md doc/OuterEnumIntegerDefaultValue.md doc/OuterObjectWithEnumProperty.md +doc/ParentWithNullable.md doc/Pet.md doc/PetApi.md doc/ReadOnlyFirst.md @@ -81,6 +83,7 @@ lib/src/model/array_test.dart lib/src/model/capitalization.dart lib/src/model/cat.dart lib/src/model/category.dart +lib/src/model/child_with_nullable.dart lib/src/model/class_model.dart lib/src/model/date.dart lib/src/model/deprecated_object.dart @@ -113,6 +116,7 @@ lib/src/model/outer_enum_default_value.dart lib/src/model/outer_enum_integer.dart lib/src/model/outer_enum_integer_default_value.dart lib/src/model/outer_object_with_enum_property.dart +lib/src/model/parent_with_nullable.dart lib/src/model/pet.dart lib/src/model/read_only_first.dart lib/src/model/single_ref_type.dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md index db7ed486d76..489ec4bec47 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md @@ -83,6 +83,7 @@ Class | Method | HTTP request | Description [*FakeApi*](doc/FakeApi.md) | [**testGroupParameters**](doc/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [*FakeApi*](doc/FakeApi.md) | [**testInlineAdditionalProperties**](doc/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [*FakeApi*](doc/FakeApi.md) | [**testJsonFormData**](doc/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[*FakeApi*](doc/FakeApi.md) | [**testNullable**](doc/FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [*FakeApi*](doc/FakeApi.md) | [**testQueryParameterCollectionFormat**](doc/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | [*FakeClassnameTags123Api*](doc/FakeClassnameTags123Api.md) | [**testClassname**](doc/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case [*PetApi*](doc/PetApi.md) | [**addPet**](doc/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -120,6 +121,7 @@ Class | Method | HTTP request | Description - [Capitalization](doc/Capitalization.md) - [Cat](doc/Cat.md) - [Category](doc/Category.md) + - [ChildWithNullable](doc/ChildWithNullable.md) - [ClassModel](doc/ClassModel.md) - [DeprecatedObject](doc/DeprecatedObject.md) - [Dog](doc/Dog.md) @@ -151,6 +153,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](doc/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](doc/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](doc/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](doc/ParentWithNullable.md) - [Pet](doc/Pet.md) - [ReadOnlyFirst](doc/ReadOnlyFirst.md) - [SingleRefType](doc/SingleRefType.md) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md new file mode 100644 index 00000000000..770494fcf4c --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md @@ -0,0 +1,17 @@ +# openapi.model.ChildWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] +**otherProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md index da73b9acb51..5caf751f1f4 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**testGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[**testNullable**](FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [**testQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | @@ -800,6 +801,48 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **testNullable** +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example +```dart +import 'package:openapi/api.dart'; + +final api = Openapi().getFakeApi(); +final ChildWithNullable childWithNullable = ; // ChildWithNullable | request body + +try { + api.testNullable(childWithNullable); +} catch on DioException (e) { + print('Exception when calling FakeApi->testNullable: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **testQueryParameterCollectionFormat** > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md new file mode 100644 index 00000000000..17aa5ca0294 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md @@ -0,0 +1,16 @@ +# openapi.model.ParentWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart index 76140c466d3..1c2b397af32 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart @@ -27,6 +27,7 @@ export 'package:openapi/src/model/array_test.dart'; export 'package:openapi/src/model/capitalization.dart'; export 'package:openapi/src/model/cat.dart'; export 'package:openapi/src/model/category.dart'; +export 'package:openapi/src/model/child_with_nullable.dart'; export 'package:openapi/src/model/class_model.dart'; export 'package:openapi/src/model/deprecated_object.dart'; export 'package:openapi/src/model/dog.dart'; @@ -58,6 +59,7 @@ export 'package:openapi/src/model/outer_enum_default_value.dart'; export 'package:openapi/src/model/outer_enum_integer.dart'; export 'package:openapi/src/model/outer_enum_integer_default_value.dart'; export 'package:openapi/src/model/outer_object_with_enum_property.dart'; +export 'package:openapi/src/model/parent_with_nullable.dart'; export 'package:openapi/src/model/pet.dart'; export 'package:openapi/src/model/read_only_first.dart'; export 'package:openapi/src/model/single_ref_type.dart'; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart index de710128f4b..da3ce4b0768 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart @@ -10,6 +10,7 @@ import 'package:dio/dio.dart'; import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:openapi/src/api_util.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/date.dart'; import 'package:openapi/src/model/fake_big_decimal_map200_response.dart'; import 'package:openapi/src/model/file_schema_test_class.dart'; @@ -1446,6 +1447,73 @@ class FakeApi { return _response; } + /// test nullable parent property + /// + /// + /// Parameters: + /// * [childWithNullable] - request body + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] + /// Throws [DioException] if API call or serialization fails + Future> testNullable({ + required ChildWithNullable childWithNullable, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/fake/nullable'; + final _options = Options( + method: r'POST', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(ChildWithNullable); + _bodyData = _serializers.serialize(childWithNullable, specifiedType: _type); + + } catch(error, stackTrace) { + throw DioException( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioExceptionType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + return _response; + } + /// testQueryParameterCollectionFormat /// To test the collection format in query parameters /// diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart new file mode 100644 index 00000000000..8e40eb1d237 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart @@ -0,0 +1,156 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:openapi/src/model/parent_with_nullable.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'child_with_nullable.g.dart'; + +/// ChildWithNullable +/// +/// Properties: +/// * [type] +/// * [nullableProperty] +/// * [otherProperty] +@BuiltValue() +abstract class ChildWithNullable implements ParentWithNullable, Built { + @BuiltValueField(wireName: r'otherProperty') + String? get otherProperty; + + ChildWithNullable._(); + + factory ChildWithNullable([void updates(ChildWithNullableBuilder b)]) = _$ChildWithNullable; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(ChildWithNullableBuilder b) => b..type=b.discriminatorValue; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ChildWithNullableSerializer(); +} + +class _$ChildWithNullableSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ChildWithNullable, _$ChildWithNullable]; + + @override + final String wireName = r'ChildWithNullable'; + + Iterable _serializeProperties( + Serializers serializers, + ChildWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.type != null) { + yield r'type'; + yield serializers.serialize( + object.type, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ); + } + if (object.nullableProperty != null) { + yield r'nullableProperty'; + yield serializers.serialize( + object.nullableProperty, + specifiedType: const FullType.nullable(String), + ); + } + if (object.otherProperty != null) { + yield r'otherProperty'; + yield serializers.serialize( + object.otherProperty, + specifiedType: const FullType(String), + ); + } + } + + @override + Object serialize( + Serializers serializers, + ChildWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ChildWithNullableBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'type': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ) as ParentWithNullableTypeEnum; + result.type = valueDes; + break; + case r'nullableProperty': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType.nullable(String), + ) as String?; + if (valueDes == null) continue; + result.nullableProperty = valueDes; + break; + case r'otherProperty': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.otherProperty = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + ChildWithNullable deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = ChildWithNullableBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + +class ChildWithNullableTypeEnum extends EnumClass { + + @BuiltValueEnumConst(wireName: r'ChildWithNullable') + static const ChildWithNullableTypeEnum childWithNullable = _$childWithNullableTypeEnum_childWithNullable; + @BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true) + static const ChildWithNullableTypeEnum unknownDefaultOpenApi = _$childWithNullableTypeEnum_unknownDefaultOpenApi; + + static Serializer get serializer => _$childWithNullableTypeEnumSerializer; + + const ChildWithNullableTypeEnum._(String name): super(name); + + static BuiltSet get values => _$childWithNullableTypeEnumValues; + static ChildWithNullableTypeEnum valueOf(String name) => _$childWithNullableTypeEnumValueOf(name); +} + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart new file mode 100644 index 00000000000..bf1252135cd --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart @@ -0,0 +1,212 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'parent_with_nullable.g.dart'; + +/// ParentWithNullable +/// +/// Properties: +/// * [type] +/// * [nullableProperty] +@BuiltValue(instantiable: false) +abstract class ParentWithNullable { + @BuiltValueField(wireName: r'type') + ParentWithNullableTypeEnum? get type; + // enum typeEnum { ChildWithNullable, }; + + @BuiltValueField(wireName: r'nullableProperty') + String? get nullableProperty; + + static const String discriminatorFieldName = r'type'; + + static const Map discriminatorMapping = { + r'ChildWithNullable': ChildWithNullable, + }; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ParentWithNullableSerializer(); +} + +extension ParentWithNullableDiscriminatorExt on ParentWithNullable { + String? get discriminatorValue { + if (this is ChildWithNullable) { + return r'ChildWithNullable'; + } + return null; + } +} +extension ParentWithNullableBuilderDiscriminatorExt on ParentWithNullableBuilder { + String? get discriminatorValue { + if (this is ChildWithNullableBuilder) { + return r'ChildWithNullable'; + } + return null; + } +} + +class _$ParentWithNullableSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ParentWithNullable]; + + @override + final String wireName = r'ParentWithNullable'; + + Iterable _serializeProperties( + Serializers serializers, + ParentWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.type != null) { + yield r'type'; + yield serializers.serialize( + object.type, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ); + } + if (object.nullableProperty != null) { + yield r'nullableProperty'; + yield serializers.serialize( + object.nullableProperty, + specifiedType: const FullType.nullable(String), + ); + } + } + + @override + Object serialize( + Serializers serializers, + ParentWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) { + if (object is ChildWithNullable) { + return serializers.serialize(object, specifiedType: FullType(ChildWithNullable))!; + } + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + @override + ParentWithNullable deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final serializedList = (serialized as Iterable).toList(); + final discIndex = serializedList.indexOf(ParentWithNullable.discriminatorFieldName) + 1; + final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String; + switch (discValue) { + case r'ChildWithNullable': + return serializers.deserialize(serialized, specifiedType: FullType(ChildWithNullable)) as ChildWithNullable; + default: + return serializers.deserialize(serialized, specifiedType: FullType($ParentWithNullable)) as $ParentWithNullable; + } + } +} + +/// a concrete implementation of [ParentWithNullable], since [ParentWithNullable] is not instantiable +@BuiltValue(instantiable: true) +abstract class $ParentWithNullable implements ParentWithNullable, Built<$ParentWithNullable, $ParentWithNullableBuilder> { + $ParentWithNullable._(); + + factory $ParentWithNullable([void Function($ParentWithNullableBuilder)? updates]) = _$$ParentWithNullable; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults($ParentWithNullableBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer<$ParentWithNullable> get serializer => _$$ParentWithNullableSerializer(); +} + +class _$$ParentWithNullableSerializer implements PrimitiveSerializer<$ParentWithNullable> { + @override + final Iterable types = const [$ParentWithNullable, _$$ParentWithNullable]; + + @override + final String wireName = r'$ParentWithNullable'; + + @override + Object serialize( + Serializers serializers, + $ParentWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) { + return serializers.serialize(object, specifiedType: FullType(ParentWithNullable))!; + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ParentWithNullableBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'type': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ) as ParentWithNullableTypeEnum; + result.type = valueDes; + break; + case r'nullableProperty': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType.nullable(String), + ) as String?; + if (valueDes == null) continue; + result.nullableProperty = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + $ParentWithNullable deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = $ParentWithNullableBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + +class ParentWithNullableTypeEnum extends EnumClass { + + @BuiltValueEnumConst(wireName: r'ChildWithNullable') + static const ParentWithNullableTypeEnum childWithNullable = _$parentWithNullableTypeEnum_childWithNullable; + @BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true) + static const ParentWithNullableTypeEnum unknownDefaultOpenApi = _$parentWithNullableTypeEnum_unknownDefaultOpenApi; + + static Serializer get serializer => _$parentWithNullableTypeEnumSerializer; + + const ParentWithNullableTypeEnum._(String name): super(name); + + static BuiltSet get values => _$parentWithNullableTypeEnumValues; + static ParentWithNullableTypeEnum valueOf(String name) => _$parentWithNullableTypeEnumValueOf(name); +} + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart index ca163ddac10..d4d742a42c2 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart @@ -24,6 +24,7 @@ import 'package:openapi/src/model/array_test.dart'; import 'package:openapi/src/model/capitalization.dart'; import 'package:openapi/src/model/cat.dart'; import 'package:openapi/src/model/category.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/class_model.dart'; import 'package:openapi/src/model/deprecated_object.dart'; import 'package:openapi/src/model/dog.dart'; @@ -55,6 +56,7 @@ import 'package:openapi/src/model/outer_enum_default_value.dart'; import 'package:openapi/src/model/outer_enum_integer.dart'; import 'package:openapi/src/model/outer_enum_integer_default_value.dart'; import 'package:openapi/src/model/outer_object_with_enum_property.dart'; +import 'package:openapi/src/model/parent_with_nullable.dart'; import 'package:openapi/src/model/pet.dart'; import 'package:openapi/src/model/read_only_first.dart'; import 'package:openapi/src/model/single_ref_type.dart'; @@ -75,6 +77,7 @@ part 'serializers.g.dart'; Capitalization, Cat, Category, + ChildWithNullable, ClassModel, DeprecatedObject, Dog, @@ -106,6 +109,7 @@ part 'serializers.g.dart'; OuterEnumInteger, OuterEnumIntegerDefaultValue, OuterObjectWithEnumProperty, + ParentWithNullable,$ParentWithNullable, Pet, ReadOnlyFirst, SingleRefType, @@ -147,6 +151,7 @@ Serializers serializers = (_$serializers.toBuilder() () => ListBuilder(), ) ..add(Animal.serializer) + ..add(ParentWithNullable.serializer) ..add(const OneOfSerializer()) ..add(const AnyOfSerializer()) ..add(const DateSerializer()) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart new file mode 100644 index 00000000000..88361dff20e --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart @@ -0,0 +1,26 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ChildWithNullable +void main() { + final instance = ChildWithNullableBuilder(); + // TODO add properties to the builder and call build() + + group(ChildWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + // String otherProperty + test('to test the property `otherProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart new file mode 100644 index 00000000000..68edeb52bc2 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart @@ -0,0 +1,21 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ParentWithNullable +void main() { + //final instance = ParentWithNullableBuilder(); + // TODO add properties to the builder and call build() + + group(ParentWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES index 727a5ef352b..f9f1005bc08 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES @@ -13,6 +13,7 @@ doc/ArrayTest.md doc/Capitalization.md doc/Cat.md doc/Category.md +doc/ChildWithNullable.md doc/ClassModel.md doc/DefaultApi.md doc/DeprecatedObject.md @@ -47,6 +48,7 @@ doc/OuterEnumDefaultValue.md doc/OuterEnumInteger.md doc/OuterEnumIntegerDefaultValue.md doc/OuterObjectWithEnumProperty.md +doc/ParentWithNullable.md doc/Pet.md doc/PetApi.md doc/ReadOnlyFirst.md @@ -83,6 +85,7 @@ lib/model/array_test.dart lib/model/capitalization.dart lib/model/cat.dart lib/model/category.dart +lib/model/child_with_nullable.dart lib/model/class_model.dart lib/model/deprecated_object.dart lib/model/dog.dart @@ -114,6 +117,7 @@ lib/model/outer_enum_default_value.dart lib/model/outer_enum_integer.dart lib/model/outer_enum_integer_default_value.dart lib/model/outer_object_with_enum_property.dart +lib/model/parent_with_nullable.dart lib/model/pet.dart lib/model/read_only_first.dart lib/model/single_ref_type.dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md index 940295f3df9..9d0fed4ca85 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md @@ -77,6 +77,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](doc//FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](doc//FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](doc//FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](doc//FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](doc//FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](doc//FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](doc//PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -114,6 +115,7 @@ Class | Method | HTTP request | Description - [Capitalization](doc//Capitalization.md) - [Cat](doc//Cat.md) - [Category](doc//Category.md) + - [ChildWithNullable](doc//ChildWithNullable.md) - [ClassModel](doc//ClassModel.md) - [DeprecatedObject](doc//DeprecatedObject.md) - [Dog](doc//Dog.md) @@ -145,6 +147,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](doc//OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](doc//OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](doc//OuterObjectWithEnumProperty.md) + - [ParentWithNullable](doc//ParentWithNullable.md) - [Pet](doc//Pet.md) - [ReadOnlyFirst](doc//ReadOnlyFirst.md) - [SingleRefType](doc//SingleRefType.md) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md new file mode 100644 index 00000000000..770494fcf4c --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md @@ -0,0 +1,17 @@ +# openapi.model.ChildWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] +**otherProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md index 5998db8502d..ee87ce7bafd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**testGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[**testNullable**](FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [**testQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | @@ -806,6 +807,48 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **testNullable** +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example +```dart +import 'package:openapi/api.dart'; + +final api_instance = FakeApi(); +final childWithNullable = ChildWithNullable(); // ChildWithNullable | request body + +try { + api_instance.testNullable(childWithNullable); +} catch (e) { + print('Exception when calling FakeApi->testNullable: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **testQueryParameterCollectionFormat** > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md new file mode 100644 index 00000000000..17aa5ca0294 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md @@ -0,0 +1,16 @@ +# openapi.model.ParentWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart index c48f9bf6a26..167a8a32b6c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart @@ -46,6 +46,7 @@ part 'model/array_test.dart'; part 'model/capitalization.dart'; part 'model/cat.dart'; part 'model/category.dart'; +part 'model/child_with_nullable.dart'; part 'model/class_model.dart'; part 'model/deprecated_object.dart'; part 'model/dog.dart'; @@ -77,6 +78,7 @@ part 'model/outer_enum_default_value.dart'; part 'model/outer_enum_integer.dart'; part 'model/outer_enum_integer_default_value.dart'; part 'model/outer_object_with_enum_property.dart'; +part 'model/parent_with_nullable.dart'; part 'model/pet.dart'; part 'model/read_only_first.dart'; part 'model/single_ref_type.dart'; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index f808cb0cf33..2873d1bcd75 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -1131,6 +1131,56 @@ class FakeApi { } } + /// test nullable parent property + /// + /// + /// + /// Note: This method returns the HTTP [Response]. + /// + /// Parameters: + /// + /// * [ChildWithNullable] childWithNullable (required): + /// request body + Future testNullableWithHttpInfo(ChildWithNullable childWithNullable,) async { + // ignore: prefer_const_declarations + final path = r'/fake/nullable'; + + // ignore: prefer_final_locals + Object? postBody = childWithNullable; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + const contentTypes = ['application/json']; + + + return apiClient.invokeAPI( + path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentTypes.isEmpty ? null : contentTypes.first, + ); + } + + /// test nullable parent property + /// + /// + /// + /// Parameters: + /// + /// * [ChildWithNullable] childWithNullable (required): + /// request body + Future testNullable(ChildWithNullable childWithNullable,) async { + final response = await testNullableWithHttpInfo(childWithNullable,); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + } + /// To test the collection format in query parameters /// /// Note: This method returns the HTTP [Response]. diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart index d494ed9f13f..7f4bd6b0567 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart @@ -202,6 +202,8 @@ class ApiClient { return Cat.fromJson(value); case 'Category': return Category.fromJson(value); + case 'ChildWithNullable': + return ChildWithNullable.fromJson(value); case 'ClassModel': return ClassModel.fromJson(value); case 'DeprecatedObject': @@ -264,6 +266,8 @@ class ApiClient { return OuterEnumIntegerDefaultValueTypeTransformer().decode(value); case 'OuterObjectWithEnumProperty': return OuterObjectWithEnumProperty.fromJson(value); + case 'ParentWithNullable': + return ParentWithNullable.fromJson(value); case 'Pet': return Pet.fromJson(value); case 'ReadOnlyFirst': diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart new file mode 100644 index 00000000000..7ade7785fc7 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart @@ -0,0 +1,211 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class ChildWithNullable { + /// Returns a new [ChildWithNullable] instance. + ChildWithNullable({ + this.type, + this.nullableProperty, + this.otherProperty, + }); + + ChildWithNullableTypeEnum? type; + + String? nullableProperty; + + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + String? otherProperty; + + @override + bool operator ==(Object other) => identical(this, other) || other is ChildWithNullable && + other.type == type && + other.nullableProperty == nullableProperty && + other.otherProperty == otherProperty; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (type == null ? 0 : type!.hashCode) + + (nullableProperty == null ? 0 : nullableProperty!.hashCode) + + (otherProperty == null ? 0 : otherProperty!.hashCode); + + @override + String toString() => 'ChildWithNullable[type=$type, nullableProperty=$nullableProperty, otherProperty=$otherProperty]'; + + Map toJson() { + final json = {}; + if (this.type != null) { + json[r'type'] = this.type; + } else { + json[r'type'] = null; + } + if (this.nullableProperty != null) { + json[r'nullableProperty'] = this.nullableProperty; + } else { + json[r'nullableProperty'] = null; + } + if (this.otherProperty != null) { + json[r'otherProperty'] = this.otherProperty; + } else { + json[r'otherProperty'] = null; + } + return json; + } + + /// Returns a new [ChildWithNullable] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ChildWithNullable? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + // Ensure that the map contains the required keys. + // Note 1: the values aren't checked for validity beyond being non-null. + // Note 2: this code is stripped in release mode! + assert(() { + requiredKeys.forEach((key) { + assert(json.containsKey(key), 'Required key "ChildWithNullable[$key]" is missing from JSON.'); + assert(json[key] != null, 'Required key "ChildWithNullable[$key]" has a null value in JSON.'); + }); + return true; + }()); + + return ChildWithNullable( + type: ChildWithNullableTypeEnum.fromJson(json[r'type']), + nullableProperty: mapValueOfType(json, r'nullableProperty'), + otherProperty: mapValueOfType(json, r'otherProperty'), + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ChildWithNullable.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = ChildWithNullable.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of ChildWithNullable-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = ChildWithNullable.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + }; +} + + +class ChildWithNullableTypeEnum { + /// Instantiate a new enum with the provided [value]. + const ChildWithNullableTypeEnum._(this.value); + + /// The underlying value of this enum member. + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const childWithNullable = ChildWithNullableTypeEnum._(r'ChildWithNullable'); + + /// List of all possible values in this [enum][ChildWithNullableTypeEnum]. + static const values = [ + childWithNullable, + ]; + + static ChildWithNullableTypeEnum? fromJson(dynamic value) => ChildWithNullableTypeEnumTypeTransformer().decode(value); + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ChildWithNullableTypeEnum.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } +} + +/// Transformation class that can [encode] an instance of [ChildWithNullableTypeEnum] to String, +/// and [decode] dynamic data back to [ChildWithNullableTypeEnum]. +class ChildWithNullableTypeEnumTypeTransformer { + factory ChildWithNullableTypeEnumTypeTransformer() => _instance ??= const ChildWithNullableTypeEnumTypeTransformer._(); + + const ChildWithNullableTypeEnumTypeTransformer._(); + + String encode(ChildWithNullableTypeEnum data) => data.value; + + /// Decodes a [dynamic value][data] to a ChildWithNullableTypeEnum. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + ChildWithNullableTypeEnum? decode(dynamic data, {bool allowNull = true}) { + if (data != null) { + switch (data) { + case r'ChildWithNullable': return ChildWithNullableTypeEnum.childWithNullable; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } + return null; + } + + /// Singleton [ChildWithNullableTypeEnumTypeTransformer] instance. + static ChildWithNullableTypeEnumTypeTransformer? _instance; +} + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart new file mode 100644 index 00000000000..24f4ee75874 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart @@ -0,0 +1,194 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class ParentWithNullable { + /// Returns a new [ParentWithNullable] instance. + ParentWithNullable({ + this.type, + this.nullableProperty, + }); + + ParentWithNullableTypeEnum? type; + + String? nullableProperty; + + @override + bool operator ==(Object other) => identical(this, other) || other is ParentWithNullable && + other.type == type && + other.nullableProperty == nullableProperty; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (type == null ? 0 : type!.hashCode) + + (nullableProperty == null ? 0 : nullableProperty!.hashCode); + + @override + String toString() => 'ParentWithNullable[type=$type, nullableProperty=$nullableProperty]'; + + Map toJson() { + final json = {}; + if (this.type != null) { + json[r'type'] = this.type; + } else { + json[r'type'] = null; + } + if (this.nullableProperty != null) { + json[r'nullableProperty'] = this.nullableProperty; + } else { + json[r'nullableProperty'] = null; + } + return json; + } + + /// Returns a new [ParentWithNullable] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ParentWithNullable? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + // Ensure that the map contains the required keys. + // Note 1: the values aren't checked for validity beyond being non-null. + // Note 2: this code is stripped in release mode! + assert(() { + requiredKeys.forEach((key) { + assert(json.containsKey(key), 'Required key "ParentWithNullable[$key]" is missing from JSON.'); + assert(json[key] != null, 'Required key "ParentWithNullable[$key]" has a null value in JSON.'); + }); + return true; + }()); + + return ParentWithNullable( + type: ParentWithNullableTypeEnum.fromJson(json[r'type']), + nullableProperty: mapValueOfType(json, r'nullableProperty'), + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ParentWithNullable.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = ParentWithNullable.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of ParentWithNullable-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = ParentWithNullable.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + }; +} + + +class ParentWithNullableTypeEnum { + /// Instantiate a new enum with the provided [value]. + const ParentWithNullableTypeEnum._(this.value); + + /// The underlying value of this enum member. + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const childWithNullable = ParentWithNullableTypeEnum._(r'ChildWithNullable'); + + /// List of all possible values in this [enum][ParentWithNullableTypeEnum]. + static const values = [ + childWithNullable, + ]; + + static ParentWithNullableTypeEnum? fromJson(dynamic value) => ParentWithNullableTypeEnumTypeTransformer().decode(value); + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ParentWithNullableTypeEnum.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } +} + +/// Transformation class that can [encode] an instance of [ParentWithNullableTypeEnum] to String, +/// and [decode] dynamic data back to [ParentWithNullableTypeEnum]. +class ParentWithNullableTypeEnumTypeTransformer { + factory ParentWithNullableTypeEnumTypeTransformer() => _instance ??= const ParentWithNullableTypeEnumTypeTransformer._(); + + const ParentWithNullableTypeEnumTypeTransformer._(); + + String encode(ParentWithNullableTypeEnum data) => data.value; + + /// Decodes a [dynamic value][data] to a ParentWithNullableTypeEnum. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + ParentWithNullableTypeEnum? decode(dynamic data, {bool allowNull = true}) { + if (data != null) { + switch (data) { + case r'ChildWithNullable': return ParentWithNullableTypeEnum.childWithNullable; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } + return null; + } + + /// Singleton [ParentWithNullableTypeEnumTypeTransformer] instance. + static ParentWithNullableTypeEnumTypeTransformer? _instance; +} + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart new file mode 100644 index 00000000000..30d4588bd80 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart @@ -0,0 +1,37 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for ChildWithNullable +void main() { + // final instance = ChildWithNullable(); + + group('test ChildWithNullable', () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + // String otherProperty + test('to test the property `otherProperty`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart new file mode 100644 index 00000000000..3d16052226f --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart @@ -0,0 +1,32 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for ParentWithNullable +void main() { + // final instance = ParentWithNullable(); + + group('test ParentWithNullable', () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES index 13cc68d7366..e233021944a 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES @@ -22,6 +22,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -45,6 +46,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java index 9d8480d8fde..72d45bdee9e 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -451,6 +452,32 @@ public interface FakeApi { ); + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = "application/json" + ) + ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ); + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..fb169e0b74a --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..7ddb5ac9fb7 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES index 440528a91a4..8e12e3455c0 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES @@ -40,6 +40,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -63,6 +64,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index ae12a17eb3b..47db3311b8a 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -506,6 +507,34 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return getDelegate().testNullable(childWithNullable); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java index b88f6171955..c0125b8d57d 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java index c8b380f33c0..e04c34be3b0 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -299,6 +300,19 @@ public interface FakeApiDelegate { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default ResponseEntity testNullable(ChildWithNullable childWithNullable) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..fb169e0b74a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..7ddb5ac9fb7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES index f9623c283a2..8e1c754a6cd 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -57,6 +58,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index 8933208533c..48b273fb6fc 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -551,6 +552,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java index 9121a395182..4f901db76d7 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..fb169e0b74a --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..7ddb5ac9fb7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/schema/petstore/mysql/.openapi-generator/FILES b/samples/schema/petstore/mysql/.openapi-generator/FILES index 0a914acd736..a70d72bf53b 100644 --- a/samples/schema/petstore/mysql/.openapi-generator/FILES +++ b/samples/schema/petstore/mysql/.openapi-generator/FILES @@ -9,6 +9,7 @@ Model/ArrayTest.sql Model/Capitalization.sql Model/Cat.sql Model/Category.sql +Model/ChildWithNullable.sql Model/ClassModel.sql Model/Client.sql Model/DeprecatedObject.sql @@ -38,6 +39,7 @@ Model/OuterEnumDefaultValue.sql Model/OuterEnumInteger.sql Model/OuterEnumIntegerDefaultValue.sql Model/OuterObjectWithEnumProperty.sql +Model/ParentWithNullable.sql Model/Pet.sql Model/ReadOnlyFirst.sql Model/Return.sql diff --git a/samples/schema/petstore/mysql/Model/ChildWithNullable.sql b/samples/schema/petstore/mysql/Model/ChildWithNullable.sql new file mode 100644 index 00000000000..1ebeb48d32a --- /dev/null +++ b/samples/schema/petstore/mysql/Model/ChildWithNullable.sql @@ -0,0 +1,26 @@ +-- +-- OpenAPI Petstore. +-- Prepared SQL queries for 'ChildWithNullable' definition. +-- + + +-- +-- SELECT template for table `ChildWithNullable` +-- +SELECT `type`, `nullableProperty`, `otherProperty` FROM `ChildWithNullable` WHERE 1; + +-- +-- INSERT template for table `ChildWithNullable` +-- +INSERT INTO `ChildWithNullable`(`type`, `nullableProperty`, `otherProperty`) VALUES (?, ?, ?); + +-- +-- UPDATE template for table `ChildWithNullable` +-- +UPDATE `ChildWithNullable` SET `type` = ?, `nullableProperty` = ?, `otherProperty` = ? WHERE 1; + +-- +-- DELETE template for table `ChildWithNullable` +-- +DELETE FROM `ChildWithNullable` WHERE 0; + diff --git a/samples/schema/petstore/mysql/Model/ParentWithNullable.sql b/samples/schema/petstore/mysql/Model/ParentWithNullable.sql new file mode 100644 index 00000000000..bea4e901ca0 --- /dev/null +++ b/samples/schema/petstore/mysql/Model/ParentWithNullable.sql @@ -0,0 +1,26 @@ +-- +-- OpenAPI Petstore. +-- Prepared SQL queries for 'ParentWithNullable' definition. +-- + + +-- +-- SELECT template for table `ParentWithNullable` +-- +SELECT `type`, `nullableProperty` FROM `ParentWithNullable` WHERE 1; + +-- +-- INSERT template for table `ParentWithNullable` +-- +INSERT INTO `ParentWithNullable`(`type`, `nullableProperty`) VALUES (?, ?); + +-- +-- UPDATE template for table `ParentWithNullable` +-- +UPDATE `ParentWithNullable` SET `type` = ?, `nullableProperty` = ? WHERE 1; + +-- +-- DELETE template for table `ParentWithNullable` +-- +DELETE FROM `ParentWithNullable` WHERE 0; + diff --git a/samples/schema/petstore/mysql/mysql_schema.sql b/samples/schema/petstore/mysql/mysql_schema.sql index 46629b42730..30257267116 100644 --- a/samples/schema/petstore/mysql/mysql_schema.sql +++ b/samples/schema/petstore/mysql/mysql_schema.sql @@ -110,6 +110,16 @@ CREATE TABLE IF NOT EXISTS `Category` ( `name` TEXT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `ChildWithNullable` generated from model 'ChildWithNullable' +-- + +CREATE TABLE IF NOT EXISTS `ChildWithNullable` ( + `type` ENUM('ChildWithNullable') DEFAULT NULL, + `nullableProperty` TEXT DEFAULT NULL, + `otherProperty` TEXT DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `ClassModel` generated from model 'ClassModel' -- Model for testing model with \"_class\" property @@ -363,6 +373,15 @@ CREATE TABLE IF NOT EXISTS `OuterObjectWithEnumProperty` ( `value` TEXT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `ParentWithNullable` generated from model 'ParentWithNullable' +-- + +CREATE TABLE IF NOT EXISTS `ParentWithNullable` ( + `type` ENUM('ChildWithNullable') DEFAULT NULL, + `nullableProperty` TEXT DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `Pet` generated from model 'Pet' -- diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES b/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES index 538c54f0c20..97c17ae836f 100644 --- a/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES +++ b/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES @@ -37,6 +37,8 @@ model/Cat.cpp model/Cat.h model/Category.cpp model/Category.h +model/ChildWithNullable.cpp +model/ChildWithNullable.h model/ClassModel.cpp model/ClassModel.h model/Client.cpp @@ -93,6 +95,8 @@ model/OuterEnumIntegerDefaultValue.cpp model/OuterEnumIntegerDefaultValue.h model/OuterObjectWithEnumProperty.cpp model/OuterObjectWithEnumProperty.h +model/ParentWithNullable.cpp +model/ParentWithNullable.h model/Pet.cpp model/Pet.h model/ReadOnlyFirst.cpp diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp index c0cf18be8bd..28c0d4e0ba3 100644 --- a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp +++ b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp @@ -1903,6 +1903,119 @@ std::string FakeJsonFormDataResource::extractFormParamsFromBody(const std::strin } return ""; } +FakeNullableResource::FakeNullableResource(const std::string& context /* = "/v2" */) +{ + this->set_path(context + "/fake/nullable"); + this->set_method_handler("POST", + std::bind(&FakeNullableResource::handler_POST_internal, this, + std::placeholders::_1)); +} + +std::pair FakeNullableResource::handleFakeApiException(const FakeApiException& e) +{ + return std::make_pair(e.getStatus(), e.what()); +} + +std::pair FakeNullableResource::handleStdException(const std::exception& e) +{ + return std::make_pair(500, e.what()); +} + +std::pair FakeNullableResource::handleUnspecifiedException() +{ + return std::make_pair(500, "Unknown exception occurred"); +} + +void FakeNullableResource::setResponseHeader(const std::shared_ptr& session, const std::string& header) +{ + session->set_header(header, ""); +} + +void FakeNullableResource::returnResponse(const std::shared_ptr& session, const int status, const std::string& result, std::multimap& responseHeaders) +{ + responseHeaders.insert(std::make_pair("Connection", "close")); + session->close(status, result, responseHeaders); +} + +void FakeNullableResource::defaultSessionClose(const std::shared_ptr& session, const int status, const std::string& result) +{ + session->close(status, result, { {"Connection", "close"} }); +} + +void FakeNullableResource::handler_POST_internal(const std::shared_ptr session) +{ + const auto request = session->get_request(); + // body params or form params here from the body content string + std::string bodyContent = extractBodyContent(session); + auto childWithNullable = extractJsonModelBodyParam(bodyContent); + + int status_code = 500; + std::string result = ""; + + try { + status_code = + handler_POST(childWithNullable); + } + catch(const FakeApiException& e) { + std::tie(status_code, result) = handleFakeApiException(e); + } + catch(const std::exception& e) { + std::tie(status_code, result) = handleStdException(e); + } + catch(...) { + std::tie(status_code, result) = handleUnspecifiedException(); + } + + std::multimap< std::string, std::string > responseHeaders {}; + static const std::vector contentTypes{ + "application/json" + }; + static const std::string acceptTypes{ + "application/json, " + }; + + if (status_code == 200) { + responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes))); + if (!acceptTypes.empty()) { + responseHeaders.insert(std::make_pair("Accept", acceptTypes)); + } + + returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders); + return; + } + defaultSessionClose(session, status_code, result); +} + + +int FakeNullableResource::handler_POST( + ChildWithNullable & childWithNullable) +{ + return handler_POST_func(childWithNullable); +} + + +std::string FakeNullableResource::extractBodyContent(const std::shared_ptr& session) { + const auto request = session->get_request(); + int content_length = request->get_header("Content-Length", 0); + std::string bodyContent; + session->fetch(content_length, + [&bodyContent](const std::shared_ptr session, + const restbed::Bytes &body) { + bodyContent = restbed::String::format( + "%.*s\n", (int)body.size(), body.data()); + }); + return bodyContent; +} + +std::string FakeNullableResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) { + const auto uri = restbed::Uri("urlencoded?" + body, true); + const auto params = uri.get_query_parameters(); + const auto result = params.find(paramName); + if (result != params.cend()) { + return result->second; + } + return ""; +} FakeTest_query_parametersResource::FakeTest_query_parametersResource(const std::string& context /* = "/v2" */) { this->set_path(context + "/fake/test-query-parameters"); @@ -2140,6 +2253,12 @@ std::shared_ptr FakeApi::getFakeJson } return m_spFakeJsonFormDataResource; } +std::shared_ptr FakeApi::getFakeNullableResource() { + if (!m_spFakeNullableResource) { + setResource(std::make_shared()); + } + return m_spFakeNullableResource; +} std::shared_ptr FakeApi::getFakeTest_query_parametersResource() { if (!m_spFakeTest_query_parametersResource) { setResource(std::make_shared()); @@ -2202,6 +2321,10 @@ void FakeApi::setResource(std::shared_ptrpublish(m_spFakeJsonFormDataResource); } +void FakeApi::setResource(std::shared_ptr resource) { + m_spFakeNullableResource = resource; + m_service->publish(m_spFakeNullableResource); +} void FakeApi::setResource(std::shared_ptr resource) { m_spFakeTest_query_parametersResource = resource; m_service->publish(m_spFakeTest_query_parametersResource); @@ -2262,6 +2385,10 @@ void FakeApi::setFakeApiFakeJsonFormDataResource(std::shared_ptrpublish(m_spFakeJsonFormDataResource); } +void FakeApi::setFakeApiFakeNullableResource(std::shared_ptr spFakeNullableResource) { + m_spFakeNullableResource = spFakeNullableResource; + m_service->publish(m_spFakeNullableResource); +} void FakeApi::setFakeApiFakeTest_query_parametersResource(std::shared_ptr spFakeTest_query_parametersResource) { m_spFakeTest_query_parametersResource = spFakeTest_query_parametersResource; m_service->publish(m_spFakeTest_query_parametersResource); @@ -2311,6 +2438,9 @@ void FakeApi::publishDefaultResources() { if (!m_spFakeJsonFormDataResource) { setResource(std::make_shared()); } + if (!m_spFakeNullableResource) { + setResource(std::make_shared()); + } if (!m_spFakeTest_query_parametersResource) { setResource(std::make_shared()); } diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h index 17f76507ffb..46dc5181826 100644 --- a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h +++ b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h @@ -31,6 +31,7 @@ #include #include +#include "ChildWithNullable.h" #include "Client.h" #include "EnumClass.h" #include "FakeBigDecimalMap_200_response.h" @@ -960,6 +961,68 @@ private: void handler_GET_internal(const std::shared_ptr session); }; +/// +/// test nullable parent property +/// +/// +/// +/// +class FakeNullableResource: public restbed::Resource +{ +public: + FakeNullableResource(const std::string& context = "/v2"); + virtual ~FakeNullableResource() = default; + + FakeNullableResource( + const FakeNullableResource& other) = default; // copy constructor + FakeNullableResource(FakeNullableResource&& other) noexcept = default; // move constructor + + FakeNullableResource& operator=(const FakeNullableResource& other) = default; // copy assignment + FakeNullableResource& operator=(FakeNullableResource&& other) noexcept = default; // move assignment + + ///////////////////////////////////////////////////// + // Set these to implement the server functionality // + ///////////////////////////////////////////////////// + std::function handler_POST_func = + [](ChildWithNullable &) -> int + { throw FakeApiException(501, "Not implemented"); }; + + +protected: + ////////////////////////////////////////////////////////// + // As an alternative to setting the `std::function`s // + // override these to implement the server functionality // + ////////////////////////////////////////////////////////// + + virtual int handler_POST( + ChildWithNullable & childWithNullable); + + +protected: + ////////////////////////////////////// + // Override these for customization // + ////////////////////////////////////// + + virtual std::string extractBodyContent(const std::shared_ptr& session); + virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body); + + virtual std::pair handleFakeApiException(const FakeApiException& e); + virtual std::pair handleStdException(const std::exception& e); + virtual std::pair handleUnspecifiedException(); + + virtual void setResponseHeader(const std::shared_ptr& session, + const std::string& header); + + virtual void returnResponse(const std::shared_ptr& session, + const int status, const std::string& result, std::multimap& contentType); + virtual void defaultSessionClose(const std::shared_ptr& session, + const int status, const std::string& result); + +private: + void handler_POST_internal(const std::shared_ptr session); +}; + /// /// /// @@ -1038,6 +1101,7 @@ using FakeApiFakeBody_with_query_paramsResource [[deprecated]] = FakeApiResource using FakeApiFakeResource [[deprecated]] = FakeApiResources::FakeResource; using FakeApiFakeInline_additionalPropertiesResource [[deprecated]] = FakeApiResources::FakeInline_additionalPropertiesResource; using FakeApiFakeJsonFormDataResource [[deprecated]] = FakeApiResources::FakeJsonFormDataResource; +using FakeApiFakeNullableResource [[deprecated]] = FakeApiResources::FakeNullableResource; using FakeApiFakeTest_query_parametersResource [[deprecated]] = FakeApiResources::FakeTest_query_parametersResource; // @@ -1063,6 +1127,7 @@ public: std::shared_ptr getFakeResource(); std::shared_ptr getFakeInline_additionalPropertiesResource(); std::shared_ptr getFakeJsonFormDataResource(); + std::shared_ptr getFakeNullableResource(); std::shared_ptr getFakeTest_query_parametersResource(); void setResource(std::shared_ptr resource); @@ -1079,6 +1144,7 @@ public: void setResource(std::shared_ptr resource); void setResource(std::shared_ptr resource); void setResource(std::shared_ptr resource); + void setResource(std::shared_ptr resource); void setResource(std::shared_ptr resource); [[deprecated("use setResource()")]] virtual void setFakeApiFakeBigDecimalMapResource(std::shared_ptr spFakeApiFakeBigDecimalMapResource); @@ -1109,6 +1175,8 @@ public: [[deprecated("use setResource()")]] virtual void setFakeApiFakeJsonFormDataResource(std::shared_ptr spFakeApiFakeJsonFormDataResource); [[deprecated("use setResource()")]] + virtual void setFakeApiFakeNullableResource(std::shared_ptr spFakeApiFakeNullableResource); + [[deprecated("use setResource()")]] virtual void setFakeApiFakeTest_query_parametersResource(std::shared_ptr spFakeApiFakeTest_query_parametersResource); virtual void publishDefaultResources(); @@ -1130,6 +1198,7 @@ protected: std::shared_ptr m_spFakeResource; std::shared_ptr m_spFakeInline_additionalPropertiesResource; std::shared_ptr m_spFakeJsonFormDataResource; + std::shared_ptr m_spFakeNullableResource; std::shared_ptr m_spFakeTest_query_parametersResource; private: diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp new file mode 100644 index 00000000000..48dd4b6314b --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp @@ -0,0 +1,140 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "ChildWithNullable.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "helpers.h" + +using boost::property_tree::ptree; +using boost::property_tree::read_json; +using boost::property_tree::write_json; + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +ChildWithNullable::ChildWithNullable(boost::property_tree::ptree const& pt) +{ + fromPropertyTree(pt); +} + + +std::string ChildWithNullable::toJsonString(bool prettyJson /* = false */) const +{ + std::stringstream ss; + write_json(ss, this->toPropertyTree(), prettyJson); + // workaround inspired by: https://stackoverflow.com/a/56395440 + std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); + std::string result = std::regex_replace(ss.str(), reg, "$1"); + return result; +} + +void ChildWithNullable::fromJsonString(std::string const& jsonString) +{ + std::stringstream ss(jsonString); + ptree pt; + read_json(ss,pt); + this->fromPropertyTree(pt); +} + +ptree ChildWithNullable::toPropertyTree() const +{ + ptree pt; + ptree tmp_node; + pt.put("type", m_Type); + pt.put("nullableProperty", m_NullableProperty); + pt.put("otherProperty", m_OtherProperty); + return pt; +} + +void ChildWithNullable::fromPropertyTree(ptree const &pt) +{ + ptree tmp_node; + setType(pt.get("type", "")); + m_NullableProperty = pt.get("nullableProperty", ""); + m_OtherProperty = pt.get("otherProperty", ""); +} + +std::string ChildWithNullable::getType() const +{ + return m_Type; +} + +void ChildWithNullable::setType(std::string value) +{ + static const std::array allowedValues = { + "ChildWithNullable" + }; + + if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) { + m_Type = value; + } else { + throw std::runtime_error("Value " + boost::lexical_cast(value) + " not allowed"); + } +} + + +std::string ChildWithNullable::getNullableProperty() const +{ + return m_NullableProperty; +} + +void ChildWithNullable::setNullableProperty(std::string value) +{ + m_NullableProperty = value; +} + + +std::string ChildWithNullable::getOtherProperty() const +{ + return m_OtherProperty; +} + +void ChildWithNullable::setOtherProperty(std::string value) +{ + m_OtherProperty = value; +} + + + +std::vector createChildWithNullableVectorFromJsonString(const std::string& json) +{ + std::stringstream sstream(json); + boost::property_tree::ptree pt; + boost::property_tree::json_parser::read_json(sstream,pt); + + auto vec = std::vector(); + for (const auto& child: pt) { + vec.emplace_back(ChildWithNullable(child.second)); + } + + return vec; +} + +} +} +} +} + diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h new file mode 100644 index 00000000000..7044b8204ee --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h @@ -0,0 +1,106 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ChildWithNullable.h + * + * + */ + +#ifndef ChildWithNullable_H_ +#define ChildWithNullable_H_ + + + +#include "ParentWithNullable.h" +#include +#include +#include +#include +#include +#include "ParentWithNullable.h" +#include "helpers.h" + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +/// +/// +/// +class ChildWithNullable : public ParentWithNullable +{ +public: + ChildWithNullable() = default; + explicit ChildWithNullable(boost::property_tree::ptree const& pt); + virtual ~ChildWithNullable() = default; + + ChildWithNullable(const ChildWithNullable& other) = default; // copy constructor + ChildWithNullable(ChildWithNullable&& other) noexcept = default; // move constructor + + ChildWithNullable& operator=(const ChildWithNullable& other) = default; // copy assignment + ChildWithNullable& operator=(ChildWithNullable&& other) noexcept = default; // move assignment + + std::string toJsonString(bool prettyJson = false) const; + void fromJsonString(std::string const& jsonString); + boost::property_tree::ptree toPropertyTree() const; + void fromPropertyTree(boost::property_tree::ptree const& pt); + + + ///////////////////////////////////////////// + /// ChildWithNullable members + + /// + /// + /// + std::string getType() const; + void setType(std::string value); + + /// + /// + /// + std::string getNullableProperty() const; + void setNullableProperty(std::string value); + + /// + /// + /// + std::string getOtherProperty() const; + void setOtherProperty(std::string value); + +protected: + std::string m_Type = ""; + std::string m_NullableProperty = ""; + std::string m_OtherProperty = ""; +}; + +std::vector createChildWithNullableVectorFromJsonString(const std::string& json); + +template<> +inline boost::property_tree::ptree toPt(const ChildWithNullable& val) { + return val.toPropertyTree(); +} + +template<> +inline ChildWithNullable fromPt(const boost::property_tree::ptree& pt) { + ChildWithNullable ret; + ret.fromPropertyTree(pt); + return ret; +} + +} +} +} +} + +#endif /* ChildWithNullable_H_ */ diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp new file mode 100644 index 00000000000..28226e76d8a --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp @@ -0,0 +1,127 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "ParentWithNullable.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "helpers.h" + +using boost::property_tree::ptree; +using boost::property_tree::read_json; +using boost::property_tree::write_json; + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +ParentWithNullable::ParentWithNullable(boost::property_tree::ptree const& pt) +{ + fromPropertyTree(pt); +} + + +std::string ParentWithNullable::toJsonString(bool prettyJson /* = false */) const +{ + std::stringstream ss; + write_json(ss, this->toPropertyTree(), prettyJson); + // workaround inspired by: https://stackoverflow.com/a/56395440 + std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); + std::string result = std::regex_replace(ss.str(), reg, "$1"); + return result; +} + +void ParentWithNullable::fromJsonString(std::string const& jsonString) +{ + std::stringstream ss(jsonString); + ptree pt; + read_json(ss,pt); + this->fromPropertyTree(pt); +} + +ptree ParentWithNullable::toPropertyTree() const +{ + ptree pt; + ptree tmp_node; + pt.put("type", m_Type); + pt.put("nullableProperty", m_NullableProperty); + return pt; +} + +void ParentWithNullable::fromPropertyTree(ptree const &pt) +{ + ptree tmp_node; + setType(pt.get("type", "")); + m_NullableProperty = pt.get("nullableProperty", ""); +} + +std::string ParentWithNullable::getType() const +{ + return m_Type; +} + +void ParentWithNullable::setType(std::string value) +{ + static const std::array allowedValues = { + "ChildWithNullable" + }; + + if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) { + m_Type = value; + } else { + throw std::runtime_error("Value " + boost::lexical_cast(value) + " not allowed"); + } +} + + +std::string ParentWithNullable::getNullableProperty() const +{ + return m_NullableProperty; +} + +void ParentWithNullable::setNullableProperty(std::string value) +{ + m_NullableProperty = value; +} + + + +std::vector createParentWithNullableVectorFromJsonString(const std::string& json) +{ + std::stringstream sstream(json); + boost::property_tree::ptree pt; + boost::property_tree::json_parser::read_json(sstream,pt); + + auto vec = std::vector(); + for (const auto& child: pt) { + vec.emplace_back(ParentWithNullable(child.second)); + } + + return vec; +} + +} +} +} +} + diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h new file mode 100644 index 00000000000..adb872bbee3 --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h @@ -0,0 +1,97 @@ +/** + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ParentWithNullable.h + * + * + */ + +#ifndef ParentWithNullable_H_ +#define ParentWithNullable_H_ + + + +#include +#include +#include +#include +#include +#include "helpers.h" + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +/// +/// +/// +class ParentWithNullable +{ +public: + ParentWithNullable() = default; + explicit ParentWithNullable(boost::property_tree::ptree const& pt); + virtual ~ParentWithNullable() = default; + + ParentWithNullable(const ParentWithNullable& other) = default; // copy constructor + ParentWithNullable(ParentWithNullable&& other) noexcept = default; // move constructor + + ParentWithNullable& operator=(const ParentWithNullable& other) = default; // copy assignment + ParentWithNullable& operator=(ParentWithNullable&& other) noexcept = default; // move assignment + + std::string toJsonString(bool prettyJson = false) const; + void fromJsonString(std::string const& jsonString); + boost::property_tree::ptree toPropertyTree() const; + void fromPropertyTree(boost::property_tree::ptree const& pt); + + + ///////////////////////////////////////////// + /// ParentWithNullable members + + /// + /// + /// + std::string getType() const; + void setType(std::string value); + + /// + /// + /// + std::string getNullableProperty() const; + void setNullableProperty(std::string value); + +protected: + std::string m_Type = ""; + std::string m_NullableProperty = ""; +}; + +std::vector createParentWithNullableVectorFromJsonString(const std::string& json); + +template<> +inline boost::property_tree::ptree toPt(const ParentWithNullable& val) { + return val.toPropertyTree(); +} + +template<> +inline ParentWithNullable fromPt(const boost::property_tree::ptree& pt) { + ParentWithNullable ret; + ret.fromPropertyTree(pt); + return ret; +} + +} +} +} +} + +#endif /* ParentWithNullable_H_ */ diff --git a/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES b/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES index 5aaf8ee8e3a..7fb08618a07 100644 --- a/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES +++ b/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES @@ -26,6 +26,7 @@ src/main/java/org/openapitools/server/model/ArrayTest.java src/main/java/org/openapitools/server/model/Capitalization.java src/main/java/org/openapitools/server/model/Cat.java src/main/java/org/openapitools/server/model/Category.java +src/main/java/org/openapitools/server/model/ChildWithNullable.java src/main/java/org/openapitools/server/model/ClassModel.java src/main/java/org/openapitools/server/model/Client.java src/main/java/org/openapitools/server/model/DeprecatedObject.java @@ -58,6 +59,7 @@ src/main/java/org/openapitools/server/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/server/model/OuterEnumInteger.java src/main/java/org/openapitools/server/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/server/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/server/model/ParentWithNullable.java src/main/java/org/openapitools/server/model/Pet.java src/main/java/org/openapitools/server/model/ReadOnlyFirst.java src/main/java/org/openapitools/server/model/SingleRefType.java diff --git a/samples/server/petstore/java-helidon-server/mp/README.md b/samples/server/petstore/java-helidon-server/mp/README.md index 8f4d37807e6..5fcf51dcd37 100644 --- a/samples/server/petstore/java-helidon-server/mp/README.md +++ b/samples/server/petstore/java-helidon-server/mp/README.md @@ -30,6 +30,7 @@ curl -X GET http://petstore.swagger.io:80/v2 curl -X DELETE http://petstore.swagger.io:80/v2 curl -X POST http://petstore.swagger.io:80/v2/inline-additionalProperties curl -X GET http://petstore.swagger.io:80/v2/jsonFormData +curl -X POST http://petstore.swagger.io:80/v2/nullable curl -X PUT http://petstore.swagger.io:80/v2/test-query-parameters curl -X PATCH http://petstore.swagger.io:80/v2 curl -X POST http://petstore.swagger.io:80/v2/pet diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java index 83b858b3d8a..fdc92a3bb8d 100644 --- a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java @@ -13,6 +13,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -126,6 +127,11 @@ public interface FakeService { @Consumes({ "application/x-www-form-urlencoded" }) void testJsonFormData(@FormParam(value = "param") String param, @FormParam(value = "param2") String param2); + @POST + @Path("/nullable") + @Consumes({ "application/json" }) + void testNullable(@Valid @NotNull ChildWithNullable childWithNullable); + @PUT @Path("/test-query-parameters") void testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List pipe, @QueryParam("ioutil") @NotNull List ioutil, @QueryParam("http") @NotNull List http, @QueryParam("url") @NotNull List url, @QueryParam("context") @NotNull List context, @QueryParam("allowEmpty") @NotNull String allowEmpty, @QueryParam("language") Map language); diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java index e20e96c568b..74dae73bfa0 100644 --- a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java @@ -13,6 +13,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -160,6 +161,12 @@ public class FakeServiceImpl implements FakeService { public void testJsonFormData(@FormParam(value = "param") String param,@FormParam(value = "param2") String param2) { } + @POST + @Path("/nullable") + @Consumes({ "application/json" }) + public void testNullable(@Valid @NotNull ChildWithNullable childWithNullable) { + } + @PUT @Path("/test-query-parameters") public void testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List pipe,@QueryParam("ioutil") @NotNull List ioutil,@QueryParam("http") @NotNull List http,@QueryParam("url") @NotNull List url,@QueryParam("context") @NotNull List context,@QueryParam("allowEmpty") @NotNull String allowEmpty,@QueryParam("language") Map language) { diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java new file mode 100644 index 00000000000..abe443a27f8 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java @@ -0,0 +1,80 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Get otherProperty + * @return otherProperty + **/ + public String getOtherProperty() { + return otherProperty; + } + + /** + * Set otherProperty + **/ + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java new file mode 100644 index 00000000000..beb88e89ed5 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java @@ -0,0 +1,149 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + +public class ParentWithNullable { + +public enum TypeEnum { + + CHILDWITHNULLABLE(String.valueOf("ChildWithNullable")); + + + private String value; + + TypeEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + /** + * Convert a String into String, as specified in the + * See JAX RS 2.0 Specification, section 3.2, p. 12 + */ + public static TypeEnum fromString(String s) { + for (TypeEnum b : TypeEnum.values()) { + // using Objects.toString() to be safe if value type non-object type + // because types like 'int' etc. will be auto-boxed + if (java.util.Objects.toString(b.value).equals(s)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected string value '" + s + "'"); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private TypeEnum type; + + private String nullableProperty; + + /** + * Get type + * @return type + **/ + public TypeEnum getType() { + return type; + } + + /** + * Set type + **/ + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set nullableProperty + **/ + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml b/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml index 66bea57fa64..59328fa022d 100644 --- a/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml +++ b/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..6246621383e --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..466dc910f55 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java @@ -0,0 +1,53 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES b/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES index c3c751515ab..7202c2d2cdc 100644 --- a/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES +++ b/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES @@ -27,6 +27,7 @@ src/main/java/org/openapitools/server/model/ArrayTest.java src/main/java/org/openapitools/server/model/Capitalization.java src/main/java/org/openapitools/server/model/Cat.java src/main/java/org/openapitools/server/model/Category.java +src/main/java/org/openapitools/server/model/ChildWithNullable.java src/main/java/org/openapitools/server/model/ClassModel.java src/main/java/org/openapitools/server/model/Client.java src/main/java/org/openapitools/server/model/DeprecatedObject.java @@ -59,6 +60,7 @@ src/main/java/org/openapitools/server/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/server/model/OuterEnumInteger.java src/main/java/org/openapitools/server/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/server/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/server/model/ParentWithNullable.java src/main/java/org/openapitools/server/model/Pet.java src/main/java/org/openapitools/server/model/ReadOnlyFirst.java src/main/java/org/openapitools/server/model/SingleRefType.java diff --git a/samples/server/petstore/java-helidon-server/se/README.md b/samples/server/petstore/java-helidon-server/se/README.md index 6bf2ea9caa7..3eda86a8663 100644 --- a/samples/server/petstore/java-helidon-server/se/README.md +++ b/samples/server/petstore/java-helidon-server/se/README.md @@ -30,6 +30,7 @@ curl -X GET http://petstore.swagger.io:80/v2/fake curl -X DELETE http://petstore.swagger.io:80/v2/fake curl -X POST http://petstore.swagger.io:80/v2/fake/inline-additionalProperties curl -X GET http://petstore.swagger.io:80/v2/fake/jsonFormData +curl -X POST http://petstore.swagger.io:80/v2/fake/nullable curl -X PUT http://petstore.swagger.io:80/v2/fake/test-query-parameters curl -X PATCH http://petstore.swagger.io:80/v2/fake_classname_test curl -X POST http://petstore.swagger.io:80/v2/pet diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java index bdcf915f1b5..16e4aa15e8b 100644 --- a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java @@ -1,6 +1,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -48,6 +49,7 @@ public interface FakeService extends Service { rules.delete("/fake", this::testGroupParameters); rules.post("/fake/inline-additionalProperties", this::testInlineAdditionalProperties); rules.get("/fake/jsonFormData", this::testJsonFormData); + rules.post("/fake/nullable", Handler.create(ChildWithNullable.class, this::testNullable)); rules.put("/fake/test-query-parameters", this::testQueryParameterCollectionFormat); } @@ -177,6 +179,14 @@ public interface FakeService extends Service { */ void testJsonFormData(ServerRequest request, ServerResponse response); + /** + * POST /fake/nullable : test nullable parent property. + * @param request the server request + * @param response the server response + * @param childWithNullable request body + */ + void testNullable(ServerRequest request, ServerResponse response, ChildWithNullable childWithNullable); + /** * PUT /fake/test-query-parameters. * @param request the server request diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java index 05a148cdbcc..11eb9fb2c68 100644 --- a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java @@ -1,6 +1,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -97,6 +98,10 @@ public class FakeServiceImpl implements FakeService { response.status(HTTP_CODE_NOT_IMPLEMENTED).send(); } + public void testNullable(ServerRequest request, ServerResponse response, ChildWithNullable childWithNullable) { + response.status(HTTP_CODE_NOT_IMPLEMENTED).send(); + } + public void testQueryParameterCollectionFormat(ServerRequest request, ServerResponse response) { response.status(HTTP_CODE_NOT_IMPLEMENTED).send(); } diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java new file mode 100644 index 00000000000..aced0bb7a9e --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java @@ -0,0 +1,73 @@ +package org.openapitools.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; + + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Default constructor. + */ + public ChildWithNullable() { + // JSON-B / Jackson + } + + /** + * Create ChildWithNullable. + * + * @param otherProperty otherProperty + */ + public ChildWithNullable( + String otherProperty + ) { + this.otherProperty = otherProperty; + } + + + + /** + * Get otherProperty + * @return otherProperty + */ + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java new file mode 100644 index 00000000000..22a7bc13fce --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java @@ -0,0 +1,125 @@ +package org.openapitools.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; + + + +public class ParentWithNullable { + + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + + @JsonCreator + public static TypeEnum fromValue(String text) { + for (TypeEnum b : TypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + text + "'"); + } + } + + + private TypeEnum type; + private String nullableProperty; + + /** + * Default constructor. + */ + public ParentWithNullable() { + // JSON-B / Jackson + } + + /** + * Create ParentWithNullable. + * + * @param type type + * @param nullableProperty nullableProperty + */ + public ParentWithNullable( + TypeEnum type, + String nullableProperty + ) { + this.type = type; + this.nullableProperty = nullableProperty; + } + + + + /** + * Get type + * @return type + */ + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + public String getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml b/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml index 66bea57fa64..59328fa022d 100644 --- a/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml +++ b/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java new file mode 100644 index 00000000000..6246621383e --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java new file mode 100644 index 00000000000..466dc910f55 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java @@ -0,0 +1,53 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES b/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES index c991a1e399e..d76f1d408eb 100644 --- a/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES +++ b/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES @@ -30,6 +30,7 @@ src/gen/java/org/openapitools/model/ArrayTest.java src/gen/java/org/openapitools/model/Capitalization.java src/gen/java/org/openapitools/model/Cat.java src/gen/java/org/openapitools/model/Category.java +src/gen/java/org/openapitools/model/ChildWithNullable.java src/gen/java/org/openapitools/model/ClassModel.java src/gen/java/org/openapitools/model/Client.java src/gen/java/org/openapitools/model/DeprecatedObject.java @@ -62,6 +63,7 @@ src/gen/java/org/openapitools/model/OuterEnumDefaultValue.java src/gen/java/org/openapitools/model/OuterEnumInteger.java src/gen/java/org/openapitools/model/OuterEnumIntegerDefaultValue.java src/gen/java/org/openapitools/model/OuterObjectWithEnumProperty.java +src/gen/java/org/openapitools/model/ParentWithNullable.java src/gen/java/org/openapitools/model/Pet.java src/gen/java/org/openapitools/model/ReadOnlyFirst.java src/gen/java/org/openapitools/model/SingleRefType.java diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java index b65155e0d45..6ec67df2d1a 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.jaxrs.*; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import java.util.Date; import org.openapitools.model.EnumClass; @@ -280,6 +281,18 @@ public class FakeApi { throws NotFoundException { return delegate.testJsonFormData(param, param2, securityContext); } + @javax.ws.rs.POST + @Path("/nullable") + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "test nullable parent property", notes = "", response = Void.class, tags={ "fake", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) + }) + public Response testNullable(@ApiParam(value = "request body", required = true) @NotNull @Valid ChildWithNullable childWithNullable,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.testNullable(childWithNullable, securityContext); + } @javax.ws.rs.PUT @Path("/test-query-parameters") diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java index 8fbf2434e37..6675105bdc6 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java @@ -5,6 +5,7 @@ import org.openapitools.api.*; import org.glassfish.jersey.media.multipart.FormDataBodyPart; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import java.util.Date; import org.openapitools.model.EnumClass; @@ -46,6 +47,7 @@ public abstract class FakeApiService { public abstract Response testGroupParameters( @NotNull Integer requiredStringGroup, @NotNull Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group,Integer stringGroup,Boolean booleanGroup,Long int64Group,SecurityContext securityContext) throws NotFoundException; public abstract Response testInlineAdditionalProperties(Map requestBody,SecurityContext securityContext) throws NotFoundException; public abstract Response testJsonFormData(String param,String param2,SecurityContext securityContext) throws NotFoundException; + public abstract Response testNullable(ChildWithNullable childWithNullable,SecurityContext securityContext) throws NotFoundException; public abstract Response testQueryParameterCollectionFormat( @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context, @NotNull String allowEmpty,Map language,SecurityContext securityContext) throws NotFoundException; public abstract Response uploadFileWithRequiredFile(Long petId,FormDataBodyPart requiredFileBodypart,String additionalMetadata,SecurityContext securityContext) throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..371f22123bc --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,98 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.openapitools.model.ParentWithNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import javax.validation.constraints.*; +import javax.validation.Valid; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen") +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @JsonProperty(value = "otherProperty") + @ApiModelProperty(value = "") + + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return super.equals(o) && Objects.equals(otherProperty, childWithNullable.otherProperty); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), otherProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 00000000000..eedfd014e9c --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,160 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * 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.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import javax.validation.constraints.*; +import javax.validation.Valid; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen")@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + @JsonProperty(JSON_PROPERTY_TYPE) + private TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + private String nullableProperty; + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @JsonProperty(value = "type") + @ApiModelProperty(value = "") + + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @JsonProperty(value = "nullableProperty") + @ApiModelProperty(value = "") + + public String getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(type, parentWithNullable.type) && + Objects.equals(nullableProperty, parentWithNullable.nullableProperty); + } + + @Override + public int hashCode() { + return Objects.hash(type, nullableProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java index 1f513684a47..8f60cba30a6 100644 --- a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java @@ -2,6 +2,7 @@ package org.openapitools.api.impl; import org.openapitools.api.*; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import java.util.Date; import org.openapitools.model.EnumClass; @@ -114,6 +115,11 @@ public class FakeApiServiceImpl extends FakeApiService { return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } @Override + public Response testNullable(ChildWithNullable childWithNullable, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override public Response testQueryParameterCollectionFormat( @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context, @NotNull String allowEmpty, Map language, SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); diff --git a/samples/server/petstore/php-laravel/.openapi-generator/FILES b/samples/server/petstore/php-laravel/.openapi-generator/FILES index dbd3b18a17d..b962dea822e 100644 --- a/samples/server/petstore/php-laravel/.openapi-generator/FILES +++ b/samples/server/petstore/php-laravel/.openapi-generator/FILES @@ -32,6 +32,7 @@ lib/app/Models/ArrayTest.php lib/app/Models/Capitalization.php lib/app/Models/Cat.php lib/app/Models/Category.php +lib/app/Models/ChildWithNullable.php lib/app/Models/ClassModel.php lib/app/Models/Client.php lib/app/Models/DeprecatedObject.php @@ -63,6 +64,7 @@ lib/app/Models/OuterEnumDefaultValue.php lib/app/Models/OuterEnumInteger.php lib/app/Models/OuterEnumIntegerDefaultValue.php lib/app/Models/OuterObjectWithEnumProperty.php +lib/app/Models/ParentWithNullable.php lib/app/Models/Pet.php lib/app/Models/ReadOnlyFirst.php lib/app/Models/SingleRefType.php diff --git a/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php b/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php index 2aadf9fe902..486d313b45d 100644 --- a/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php +++ b/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php @@ -426,6 +426,30 @@ class FakeController extends Controller return response('How about implementing testJsonFormData as a get method ?'); } + /** + * Operation testNullable + * + * test nullable parent property. + * + * + * @return Http response + */ + public function testNullable() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['childWithNullable'])) { + throw new \InvalidArgumentException('Missing the required parameter $childWithNullable when calling testNullable'); + } + $childWithNullable = $input['childWithNullable']; + + + return response('How about implementing testNullable as a post method ?'); + } /** * Operation fakeOuterBooleanSerialize * diff --git a/samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php b/samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php new file mode 100644 index 00000000000..f1354195cb4 --- /dev/null +++ b/samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php @@ -0,0 +1,21 @@ +post('/v2/fake/inline-additionalProperties', 'FakeApi@testInlineAdditio */ $router->get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData'); +/** + * post testNullable + * Summary: test nullable parent property + * Notes: + */ +$router->post('/v2/fake/nullable', 'FakeApi@testNullable'); + /** * post fakeOuterBooleanSerialize * Summary: diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES index 2f3e054109b..eb1a4d69db4 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -46,6 +47,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java index 1b881b2651d..173ca2a6405 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -478,6 +479,32 @@ public interface FakeApi { ) throws Exception; + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) throws Exception; + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..fb169e0b74a --- /dev/null +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 00000000000..7ddb5ac9fb7 --- /dev/null +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES b/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES index 2863ea22e3b..f3691a72bd4 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -57,6 +58,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java index 2223eaece42..ac40279c670 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java index 9121a395182..4f901db76d7 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..3ce936a5302 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,101 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.openapitools.model.ParentWithNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..8c57b73ad6b --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,153 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private String nullableProperty = null; + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public String getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + Objects.equals(this.nullableProperty, parentWithNullable.nullableProperty); + } + + @Override + public int hashCode() { + return Objects.hash(type, nullableProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES b/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES index d757e50ecff..3ac88a992f9 100644 --- a/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -57,6 +58,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java index 2223eaece42..ac40279c670 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java index 9121a395182..4f901db76d7 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES b/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES index a0317e15579..fc1d5a0fa9e 100644 --- a/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES @@ -40,6 +40,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -63,6 +64,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java index b06abb7467f..601013398be 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -499,6 +500,34 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return getDelegate().testNullable(childWithNullable); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java index b88f6171955..c0125b8d57d 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java index c8b380f33c0..e04c34be3b0 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -299,6 +300,19 @@ public interface FakeApiDelegate { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default ResponseEntity testNullable(ChildWithNullable childWithNullable) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-delegate/.openapi-generator/FILES b/samples/server/petstore/springboot-delegate/.openapi-generator/FILES index a0317e15579..fc1d5a0fa9e 100644 --- a/samples/server/petstore/springboot-delegate/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-delegate/.openapi-generator/FILES @@ -40,6 +40,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -63,6 +64,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index b06abb7467f..601013398be 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -499,6 +500,34 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return getDelegate().testNullable(childWithNullable); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java index b88f6171955..c0125b8d57d 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java index c8b380f33c0..e04c34be3b0 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -299,6 +300,19 @@ public interface FakeApiDelegate { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default ResponseEntity testNullable(ChildWithNullable childWithNullable) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES b/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES index 2863ea22e3b..f3691a72bd4 100644 --- a/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -57,6 +58,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index 3cb28e2bcc1..21a90acea53 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java index 9121a395182..4f901db76d7 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES b/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES index 65881ecd936..64711ce4717 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES @@ -39,6 +39,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -62,6 +63,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java index c007639214d..c9470e15a9f 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ package org.openapitools.api; import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -532,6 +533,36 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + @ResponseStatus(HttpStatus.OK) + default Mono testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody Mono childWithNullable, + @ApiIgnore final ServerWebExchange exchange + ) { + return getDelegate().testNullable(childWithNullable, exchange); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java index 159a5330fcb..26840ffb0ea 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java @@ -2,6 +2,7 @@ package org.openapitools.api; import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java index 5392a1a9baf..e606ecfe26a 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -2,6 +2,7 @@ package org.openapitools.api; import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -339,6 +340,22 @@ public interface FakeApiDelegate { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default Mono testNullable(Mono childWithNullable, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(childWithNullable).then(Mono.empty()); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-reactive/.openapi-generator/FILES b/samples/server/petstore/springboot-reactive/.openapi-generator/FILES index 65881ecd936..64711ce4717 100644 --- a/samples/server/petstore/springboot-reactive/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-reactive/.openapi-generator/FILES @@ -39,6 +39,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -62,6 +63,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java index a957c78388c..1ce75cf7586 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ package org.openapitools.api; import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -518,6 +519,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default Mono> testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody Mono childWithNullable, + @ApiIgnore final ServerWebExchange exchange + ) { + return getDelegate().testNullable(childWithNullable, exchange); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java index ea2bb662956..cb1695a319e 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java @@ -2,6 +2,7 @@ package org.openapitools.api; import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java index 8fa3ade1077..e1303c31937 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -2,6 +2,7 @@ package org.openapitools.api; import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -340,6 +341,22 @@ public interface FakeApiDelegate { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default Mono> testNullable(Mono childWithNullable, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(childWithNullable).then(Mono.empty()); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES b/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES index 2863ea22e3b..f3691a72bd4 100644 --- a/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -57,6 +58,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java index eb001348b4e..19bcbf722b6 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java index 9121a395182..4f901db76d7 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 00000000000..49094e267a2 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..88477c887c2 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES b/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES index 68986fd2794..1f44133fbd0 100644 --- a/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/virtualan/model/BigCat.java src/main/java/org/openapitools/virtualan/model/Capitalization.java src/main/java/org/openapitools/virtualan/model/Cat.java src/main/java/org/openapitools/virtualan/model/Category.java +src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java src/main/java/org/openapitools/virtualan/model/ClassModel.java src/main/java/org/openapitools/virtualan/model/Client.java src/main/java/org/openapitools/virtualan/model/ContainerDefaultValue.java @@ -57,6 +58,7 @@ src/main/java/org/openapitools/virtualan/model/NumberOnly.java src/main/java/org/openapitools/virtualan/model/Order.java src/main/java/org/openapitools/virtualan/model/OuterComposite.java src/main/java/org/openapitools/virtualan/model/OuterEnum.java +src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java src/main/java/org/openapitools/virtualan/model/Pet.java src/main/java/org/openapitools/virtualan/model/ReadOnlyFirst.java src/main/java/org/openapitools/virtualan/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java index 8f23a56bccb..9410ee5fea1 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.virtualan.api; import java.math.BigDecimal; +import org.openapitools.virtualan.model.ChildWithNullable; import org.openapitools.virtualan.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.virtualan.model.FileSchemaTestClass; @@ -568,6 +569,36 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiVirtual + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java index 6745966de43..2073874d33c 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.virtualan.api; import java.math.BigDecimal; +import org.openapitools.virtualan.model.ChildWithNullable; import org.openapitools.virtualan.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.virtualan.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java new file mode 100644 index 00000000000..040cd5c6afe --- /dev/null +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.virtualan.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.virtualan.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/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 new file mode 100644 index 00000000000..3ef9d3cff29 --- /dev/null +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.virtualan.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml index 17951cb6c3f..3ebfb97645f 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot/.openapi-generator/FILES b/samples/server/petstore/springboot/.openapi-generator/FILES index 849ad35dca3..17c1e122b6b 100644 --- a/samples/server/petstore/springboot/.openapi-generator/FILES +++ b/samples/server/petstore/springboot/.openapi-generator/FILES @@ -35,6 +35,7 @@ src/main/java/org/openapitools/model/BigCatDto.java src/main/java/org/openapitools/model/CapitalizationDto.java src/main/java/org/openapitools/model/CatDto.java src/main/java/org/openapitools/model/CategoryDto.java +src/main/java/org/openapitools/model/ChildWithNullableDto.java src/main/java/org/openapitools/model/ClassModelDto.java src/main/java/org/openapitools/model/ClientDto.java src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/model/NumberOnlyDto.java src/main/java/org/openapitools/model/OrderDto.java src/main/java/org/openapitools/model/OuterCompositeDto.java src/main/java/org/openapitools/model/OuterEnumDto.java +src/main/java/org/openapitools/model/ParentWithNullableDto.java src/main/java/org/openapitools/model/PetDto.java src/main/java/org/openapitools/model/ReadOnlyFirstDto.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNamesDto.java diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java index e4f57a07a06..72ec8da42af 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ package org.openapitools.api; import org.openapitools.model.ApiResponseDto; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullableDto; import org.openapitools.model.ClientDto; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClassDto; @@ -544,6 +545,35 @@ public interface FakeApi { } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullableDto request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullableDto childWithNullableDto + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java index ad3ca0f55b6..47ca2590812 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java @@ -2,6 +2,7 @@ package org.openapitools.api; import org.openapitools.model.ApiResponseDto; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullableDto; import org.openapitools.model.ClientDto; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClassDto; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java new file mode 100644 index 00000000000..d954f197094 --- /dev/null +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java @@ -0,0 +1,117 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullableDto; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullableDto + */ + + +@JsonTypeName("ChildWithNullable") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullableDto extends ParentWithNullableDto { + + private String otherProperty; + + public ChildWithNullableDto otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullableDto type(TypeEnum type) { + super.type(type); + return this; + } + + public ChildWithNullableDto nullableProperty(String nullableProperty) { + super.nullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullableDto childWithNullable = (ChildWithNullableDto) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullableDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java new file mode 100644 index 00000000000..5a76b286e6b --- /dev/null +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -0,0 +1,169 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullableDto + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullableDto.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullableDto { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullableDto type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullableDto nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullableDto parentWithNullable = (ParentWithNullableDto) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullableDto {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot/src/main/resources/openapi.yaml b/samples/server/petstore/springboot/src/main/resources/openapi.yaml index 7e70129174a..42dd7db5f53 100644 --- a/samples/server/petstore/springboot/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean