From 36a48592bc7ea30bd042d555d4e0cb9fe1b7167b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Rodr=C3=ADguez=20Mart=C3=ADn?= Date: Fri, 17 Feb 2023 13:53:07 +0100 Subject: [PATCH 1/5] Fix serialization when there is a discriminator with mapping --- .../src/main/resources/Java/pojo.mustache | 2 + .../main/resources/JavaSpring/pojo.mustache | 2 + .../codegen/java/JavaClientCodegenTest.java | 82 +++++++++++++ .../java/spring/SpringCodegenTest.java | 79 +++++++++++++ .../src/test/resources/bugs/issue_14731.yaml | 109 ++++++++++++++++++ 5 files changed, 274 insertions(+) create mode 100644 modules/openapi-generator/src/test/resources/bugs/issue_14731.yaml diff --git a/modules/openapi-generator/src/main/resources/Java/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/pojo.mustache index 3313a2cbdc3e..e8d4dc8ee21c 100644 --- a/modules/openapi-generator/src/main/resources/Java/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/pojo.mustache @@ -15,7 +15,9 @@ {{/vars}} }) {{#isClassnameSanitized}} +{{^hasDiscriminatorWithNonEmptyMapping}} @JsonTypeName("{{name}}") +{{/hasDiscriminatorWithNonEmptyMapping}} {{/isClassnameSanitized}} {{/jackson}} {{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache index 6217ac15abf0..a41cb8eac753 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache @@ -15,7 +15,9 @@ {{/discriminator}} {{#jackson}} {{#isClassnameSanitized}} +{{^hasDiscriminatorWithNonEmptyMapping}} @JsonTypeName("{{name}}") +{{/hasDiscriminatorWithNonEmptyMapping}} {{/isClassnameSanitized}} {{/jackson}} {{#withXml}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index b046fd2a344f..847eb43b2635 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -18,6 +18,7 @@ package org.openapitools.codegen.java; import com.google.common.collect.ImmutableMap; +import io.swagger.parser.OpenAPIParser; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.media.ArraySchema; @@ -30,6 +31,7 @@ import io.swagger.v3.oas.models.media.StringSchema; import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.responses.ApiResponse; +import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.util.SchemaTypeUtil; import org.openapitools.codegen.ClientOptInput; import org.openapitools.codegen.CodegenConstants; @@ -75,6 +77,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import static org.openapitools.codegen.TestUtils.assertFileContains; +import static org.openapitools.codegen.TestUtils.assertFileNotContains; import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -1752,4 +1756,82 @@ public void testJdkHttpClientWithAndWithoutParentExtension() throws Exception { TestUtils.assertFileContains(Paths.get(output + "/src/main/java/xyz/abcdef/model/AnotherChild.java"), "public class AnotherChild {"); } + + @Test + public void testDiscriminatorWithMappingIssue14731() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI(); + + JavaClientCodegen codegen = new JavaClientCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + codegen.setUseOneOfInterfaces(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false"); + + + codegen.setUseOneOfInterfaces(true); + codegen.setLegacyDiscriminatorBehavior(false); + codegen.setUseJakartaEe(true); + codegen.setModelNameSuffix("DTO"); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + + generator.opts(input).generate(); + + assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/ChildWithMappingADTO.java"), "@JsonTypeName"); + assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/ChildWithMappingBDTO.java"), "@JsonTypeName"); + } + + @Test + public void testDiscriminatorWithoutMappingIssue14731() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI(); + + JavaClientCodegen codegen = new JavaClientCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + codegen.setUseOneOfInterfaces(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false"); + + + codegen.setUseOneOfInterfaces(true); + codegen.setLegacyDiscriminatorBehavior(false); + codegen.setUseJakartaEe(true); + codegen.setModelNameSuffix("DTO"); + codegen.setLibrary(JavaClientCodegen.RESTTEMPLATE); + + + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + + generator.opts(input).generate(); + + assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/ChildWithoutMappingADTO.java"), "@JsonTypeName"); + assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/model/ChildWithoutMappingBDTO.java"), "@JsonTypeName"); + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index c86200fe85c3..4a0b10b11e3e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -1141,6 +1141,85 @@ public void testOneOfAndAllOf() throws IOException { assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/PizzaSpeziale.java"), "import java.math.BigDecimal"); } + @Test + public void testDiscriminatorWithMappingIssue14731() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + codegen.setUseOneOfInterfaces(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + codegen.setHateoas(true); + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false"); + + + codegen.setUseOneOfInterfaces(true); + codegen.setLegacyDiscriminatorBehavior(false); + codegen.setUseSpringBoot3(true); + codegen.setModelNameSuffix("DTO"); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + + generator.opts(input).generate(); + + assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/ChildWithMappingADTO.java"), "@JsonTypeName"); + assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/ChildWithMappingBDTO.java"), "@JsonTypeName"); + } + + @Test + public void testDiscriminatorWithoutMappingIssue14731() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + codegen.setUseOneOfInterfaces(true); + + ClientOptInput input = new ClientOptInput(); + input.openAPI(openAPI); + input.config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + codegen.setHateoas(true); + generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "false"); + + + codegen.setUseOneOfInterfaces(true); + codegen.setLegacyDiscriminatorBehavior(false); + codegen.setUseSpringBoot3(true); + codegen.setModelNameSuffix("DTO"); + + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false"); + generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true"); + generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false"); + + generator.opts(input).generate(); + + + assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/ChildWithoutMappingADTO.java"), "@JsonTypeName"); + assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/ChildWithoutMappingBDTO.java"), "@JsonTypeName"); + } + @Test public void testTypeMappings() { final SpringCodegen codegen = new SpringCodegen(); diff --git a/modules/openapi-generator/src/test/resources/bugs/issue_14731.yaml b/modules/openapi-generator/src/test/resources/bugs/issue_14731.yaml new file mode 100644 index 000000000000..7aac956d3e21 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/bugs/issue_14731.yaml @@ -0,0 +1,109 @@ +openapi: '3.0.0' +info: + version: '1.0.0' + title: 'FooService' +paths: + /parentWithMapping: + put: + tags: + - pet + summary: put parent + operationId: putParentWithMapping + requestBody: + description: The updated account definition to save. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ParentWithMapping' + responses: + '200': + $ref: '#/components/responses/ParentWithMapping' + /parentWithoutMapping: + put: + tags: + - pet + summary: put parent + operationId: putParentWithoutMapping + requestBody: + description: The updated account definition to save. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ParentWithoutMapping' + responses: + '200': + $ref: '#/components/responses/ParentWithoutMapping' +components: + schemas: + ParentWithMapping: + type: object + description: Defines an account by name. + properties: + childType: + $ref: '#/components/schemas/ChildType' + required: + - type + discriminator: + propertyName: childType + mapping: + child_a: '#/components/schemas/ChildWithMappingA' + child_b: '#/components/schemas/ChildWithMappingB' + + ChildWithMappingA: + allOf: + - $ref: "#/components/schemas/ParentWithMapping" + - type: object + properties: + nameA: + type: string + ChildWithMappingB: + allOf: + - $ref: "#/components/schemas/ParentWithMapping" + - type: object + properties: + nameB: + type: string + ChildType: + type: string + x-extensible-enum: + - child_a + - child_b + ParentWithoutMapping: + type: object + description: Defines an account by name. + properties: + childType: + $ref: '#/components/schemas/ChildType' + required: + - type + discriminator: + propertyName: childType + ChildWithoutMappingA: + allOf: + - $ref: "#/components/schemas/ParentWithoutMapping" + - type: object + properties: + nameA: + type: string + ChildWithoutMappingB: + allOf: + - $ref: "#/components/schemas/ParentWithoutMapping" + - type: object + properties: + nameB: + type: string + responses: + ParentWithMapping: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ParentWithMapping' + ParentWithoutMapping: + description: The saved account definition. + content: + application/json: + schema: + $ref: '#/components/schemas/ParentWithoutMapping' \ No newline at end of file From d6affde263d6c539e32a7f38dc984cf5948ab322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Rodr=C3=ADguez=20Mart=C3=ADn?= Date: Fri, 17 Feb 2023 14:14:23 +0100 Subject: [PATCH 2/5] Update samples --- .../java/apache-httpclient/docs/DataQuery.md | 12 + .../org/openapitools/client/model/Bird.java | 66 +---- .../openapitools/client/model/Category.java | 66 +---- .../openapitools/client/model/DataQuery.java | 221 +++++++++-------- .../client/model/DataQueryAllOf.java | 78 +----- .../client/model/DefaultValue.java | 168 ++----------- .../org/openapitools/client/model/Pet.java | 113 +-------- .../org/openapitools/client/model/Bird.java | 39 ++- .../openapitools/client/model/Category.java | 39 ++- .../openapitools/client/model/DataQuery.java | 166 +++++++++++-- .../client/model/DataQueryAllOf.java | 50 ++-- .../client/model/DefaultValue.java | 171 ++++++++----- .../org/openapitools/client/model/Pet.java | 95 ++++--- .../echo_api/java/native/docs/DataQuery.md | 12 + .../org/openapitools/client/model/Bird.java | 56 +---- .../openapitools/client/model/Category.java | 56 +---- .../openapitools/client/model/DataQuery.java | 193 +++++++++------ .../client/model/DataQueryAllOf.java | 63 +---- .../client/model/DefaultValue.java | 125 ++-------- .../java/okhttp-gson/docs/DataQuery.md | 12 + .../org/openapitools/client/model/Bird.java | 8 +- .../openapitools/client/model/Category.java | 8 +- .../openapitools/client/model/DataQuery.java | 134 +++++++++- .../client/model/DataQueryAllOf.java | 10 +- .../client/model/DefaultValue.java | 39 +-- .../org/openapitools/client/model/Pet.java | 16 +- .../org/openapitools/client/StringUtil.java | 2 +- .../org/openapitools/client/api/PingApi.java | 2 +- .../openapitools/client/auth/ApiKeyAuth.java | 2 +- .../client/auth/HttpBearerAuth.java | 2 +- .../openapitools/client/model/SomeObj.java | 14 +- .../org/openapitools/client/model/Order.java | 20 -- .../org/openapitools/client/model/Pet.java | 20 -- .../org/openapitools/client/model/Order.java | 20 -- .../org/openapitools/client/model/Pet.java | 20 -- .../openapitools/client/model/Category.java | 56 +---- .../client/model/ModelApiResponse.java | 63 +---- .../org/openapitools/client/model/Order.java | 84 +------ .../org/openapitools/client/model/Pet.java | 93 +------ .../org/openapitools/client/model/Tag.java | 56 +---- .../openapitools/client/model/Category.java | 8 +- .../client/model/ModelApiResponse.java | 10 +- .../org/openapitools/client/model/Order.java | 16 +- .../org/openapitools/client/model/Pet.java | 16 +- .../org/openapitools/client/model/Tag.java | 8 +- .../org/openapitools/client/model/User.java | 20 +- .../openapitools/client/model/Category.java | 8 +- .../client/model/ModelApiResponse.java | 10 +- .../org/openapitools/client/model/Order.java | 16 +- .../org/openapitools/client/model/Pet.java | 16 +- .../org/openapitools/client/model/Tag.java | 8 +- .../openapitools/client/model/Category.java | 9 +- .../client/model/ModelApiResponse.java | 12 +- .../org/openapitools/client/model/Order.java | 21 +- .../org/openapitools/client/model/Pet.java | 21 +- .../org/openapitools/client/model/Tag.java | 9 +- .../org/openapitools/client/model/User.java | 27 +- .../org/openapitools/client/ApiClient.java | 34 +-- .../client/JavaTimeFormatter.java | 2 +- .../org/openapitools/client/StringUtil.java | 2 +- .../org/openapitools/client/api/UsageApi.java | 4 +- .../client/auth/HttpBasicAuth.java | 2 +- .../client/auth/HttpBearerAuth.java | 2 +- .../openapitools/client/api/DefaultApi.java | 4 +- .../client/model/ChildSchema.java | 7 +- .../client/model/ChildSchemaAllOf.java | 6 +- .../client/model/MySchemaNameCharacters.java | 7 +- .../model/MySchemaNameCharactersAllOf.java | 6 +- .../org/openapitools/client/model/Parent.java | 6 +- .../openapitools/client/model/Category.java | 9 +- .../client/model/ModelApiResponse.java | 12 +- .../org/openapitools/client/model/Order.java | 21 +- .../org/openapitools/client/model/Pet.java | 21 +- .../org/openapitools/client/model/Tag.java | 9 +- .../org/openapitools/client/model/User.java | 27 +- .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 17 ++ .../CustomInstantDeserializer.java | 232 ++++++++++++++++++ .../configuration/JacksonConfiguration.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 73 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../java/org/openapitools/model/Category.java | 4 +- .../openapitools/model/ModelApiResponse.java | 6 +- .../java/org/openapitools/model/Order.java | 12 +- .../main/java/org/openapitools/model/Pet.java | 12 +- .../main/java/org/openapitools/model/Tag.java | 4 +- .../java/org/openapitools/model/User.java | 16 +- .../java/org/openapitools/model/Category.java | 4 +- .../openapitools/model/ModelApiResponse.java | 6 +- .../java/org/openapitools/model/Order.java | 12 +- .../main/java/org/openapitools/model/Pet.java | 12 +- .../main/java/org/openapitools/model/Tag.java | 4 +- .../java/org/openapitools/model/User.java | 16 +- .../org/openapitools/OpenAPI2SpringBoot.java | 17 ++ .../CustomInstantDeserializer.java | 232 ++++++++++++++++++ .../configuration/JacksonConfiguration.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../CustomInstantDeserializer.java | 232 ++++++++++++++++++ .../configuration/JacksonConfiguration.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../CustomInstantDeserializer.java | 232 ++++++++++++++++++ .../configuration/JacksonConfiguration.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 73 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ .../org/openapitools/OpenAPI2SpringBoot.java | 23 ++ .../OpenAPIDocumentationConfig.java | 71 ++++++ 139 files changed, 4238 insertions(+), 1788 deletions(-) create mode 100644 samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java create mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java create mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java create mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java create mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java create mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java create mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java create mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java create mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java diff --git a/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md b/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md index 338c467b2d56..5beb983af973 100644 --- a/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md +++ b/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md @@ -10,6 +10,18 @@ |**suffix** | **String** | test suffix | [optional] | |**text** | **String** | Some text containing white spaces | [optional] | |**date** | **OffsetDateTime** | A date | [optional] | +|**id** | **Long** | Query | [optional] | +|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | + + + +## Enum: List<OutcomesEnum> + +| Name | Value | +|---- | -----| +| SUCCESS | "SUCCESS" | +| FAILURE | "FAILURE" | +| SKIPPED | "SKIPPED" | diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java index a42433b9d5cd..c04e23293647 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java @@ -20,11 +20,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; /** * Bird @@ -33,7 +32,7 @@ Bird.JSON_PROPERTY_SIZE, Bird.JSON_PROPERTY_COLOR }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { public static final String JSON_PROPERTY_SIZE = "size"; private String size; @@ -54,7 +53,7 @@ public Bird size(String size) { * Get size * @return size **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SIZE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +79,7 @@ public Bird color(String color) { * Get color * @return color **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_COLOR) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -135,60 +134,5 @@ private String toIndentedString(Object o) { 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 `size` to the URL query string - if (getSize() != null) { - try { - joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `color` to the URL query string - if (getColor() != null) { - try { - joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java index 9d205aa629e4..e278b76dfad6 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java @@ -20,11 +20,10 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; /** * Category @@ -33,7 +32,7 @@ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -54,7 +53,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +79,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -135,60 +134,5 @@ private String toIndentedString(Object o) { 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 `id` to the URL query string - if (getId() != null) { - try { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `name` to the URL query string - if (getName() != null) { - try { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java index 482cc9c32464..c8eedf63c08c 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java @@ -20,15 +20,15 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; /** * DataQuery @@ -36,10 +36,12 @@ @JsonPropertyOrder({ DataQuery.JSON_PROPERTY_SUFFIX, DataQuery.JSON_PROPERTY_TEXT, - DataQuery.JSON_PROPERTY_DATE + DataQuery.JSON_PROPERTY_DATE, + DataQuery.JSON_PROPERTY_ID, + DataQuery.JSON_PROPERTY_OUTCOMES }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery extends Query { +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -49,8 +51,50 @@ public class DataQuery extends Query { public static final String JSON_PROPERTY_DATE = "date"; private OffsetDateTime date; - public DataQuery() { + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + /** + * Gets or Sets outcomes + */ + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; + private List outcomes = new ArrayList<>(); + + public DataQuery() { } public DataQuery suffix(String suffix) { @@ -63,7 +107,7 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -89,7 +133,7 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -115,7 +159,7 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -131,6 +175,66 @@ public void setDate(OffsetDateTime date) { } + public DataQuery id(Long id) { + + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(Long id) { + this.id = id; + } + + + public DataQuery outcomes(List outcomes) { + + this.outcomes = outcomes; + return this; + } + + public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public List getOutcomes() { + return outcomes; + } + + + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + @Override public boolean equals(Object o) { if (this == o) { @@ -143,22 +247,24 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - super.equals(o); + Objects.equals(this.id, dataQuery.id) && + Objects.equals(this.outcomes, dataQuery.outcomes); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, super.hashCode()); + return Objects.hash(suffix, text, date, id, outcomes); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } @@ -174,94 +280,5 @@ private String toIndentedString(Object o) { 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 `suffix` to the URL query string - if (getSuffix() != null) { - try { - joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `text` to the URL query string - if (getText() != null) { - try { - joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `date` to the URL query string - if (getDate() != null) { - try { - joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `id` to the URL query string - if (getId() != null) { - try { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `outcomes` to the URL query string - if (getOutcomes() != null) { - for (int i = 0; i < getOutcomes().size(); i++) { - try { - joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getOutcomes().get(i)), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 971198bc3559..15d00cff792a 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -20,12 +20,11 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; /** * DataQueryAllOf @@ -36,7 +35,7 @@ DataQueryAllOf.JSON_PROPERTY_DATE }) @JsonTypeName("DataQuery_allOf") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -60,7 +59,7 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -86,7 +85,7 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -112,7 +111,7 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -169,70 +168,5 @@ private String toIndentedString(Object o) { 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 `suffix` to the URL query string - if (getSuffix() != null) { - try { - joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `text` to the URL query string - if (getText() != null) { - try { - joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `date` to the URL query string - if (getDate() != null) { - try { - joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java index 859afd7a9816..9d7f2fe5617d 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -20,6 +20,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.StringEnumRef; @@ -29,9 +31,6 @@ import java.util.NoSuchElementException; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; /** * to test the default value of properties @@ -45,10 +44,10 @@ DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE, DefaultValue.JSON_PROPERTY_STRING_NULLABLE }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; - private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + private List arrayStringEnumRefDefault = new ArrayList<>(); /** * Gets or Sets arrayStringEnumDefault @@ -88,13 +87,13 @@ public static ArrayStringEnumDefaultEnum fromValue(String value) { } public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; - private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + private List arrayStringEnumDefault = new ArrayList<>(); public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default"; - private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + private List arrayStringDefault = new ArrayList<>(); public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default"; - private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + private List arrayIntegerDefault = new ArrayList<>(); public static final String JSON_PROPERTY_ARRAY_STRING = "array_string"; private List arrayString = new ArrayList<>(); @@ -116,7 +115,7 @@ public DefaultValue arrayStringEnumRefDefault(List arrayStringEnu public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) { if (this.arrayStringEnumRefDefault == null) { - this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + this.arrayStringEnumRefDefault = new ArrayList<>(); } this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem); return this; @@ -126,7 +125,7 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -150,7 +149,7 @@ public DefaultValue arrayStringEnumDefault(List arra public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) { if (this.arrayStringEnumDefault == null) { - this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + this.arrayStringEnumDefault = new ArrayList<>(); } this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem); return this; @@ -160,7 +159,7 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -184,7 +183,7 @@ public DefaultValue arrayStringDefault(List arrayStringDefault) { public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { if (this.arrayStringDefault == null) { - this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + this.arrayStringDefault = new ArrayList<>(); } this.arrayStringDefault.add(arrayStringDefaultItem); return this; @@ -194,7 +193,7 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -218,7 +217,7 @@ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) { public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) { if (this.arrayIntegerDefault == null) { - this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + this.arrayIntegerDefault = new ArrayList<>(); } this.arrayIntegerDefault.add(arrayIntegerDefaultItem); return this; @@ -228,7 +227,7 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -262,7 +261,7 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -300,7 +299,7 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonIgnore public List getArrayStringNullable() { @@ -334,7 +333,7 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonIgnore public String getStringNullable() { @@ -418,136 +417,5 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `array_string_enum_ref_default` to the URL query string - if (getArrayStringEnumRefDefault() != null) { - for (int i = 0; i < getArrayStringEnumRefDefault().size(); i++) { - if (getArrayStringEnumRefDefault().get(i) != null) { - try { - joiner.add(String.format("%sarray_string_enum_ref_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringEnumRefDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - } - - // add `array_string_enum_default` to the URL query string - if (getArrayStringEnumDefault() != null) { - for (int i = 0; i < getArrayStringEnumDefault().size(); i++) { - try { - joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - - // add `array_string_default` to the URL query string - if (getArrayStringDefault() != null) { - for (int i = 0; i < getArrayStringDefault().size(); i++) { - try { - joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - - // add `array_integer_default` to the URL query string - if (getArrayIntegerDefault() != null) { - for (int i = 0; i < getArrayIntegerDefault().size(); i++) { - try { - joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - - // add `array_string` to the URL query string - if (getArrayString() != null) { - for (int i = 0; i < getArrayString().size(); i++) { - try { - joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayString().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - - // add `array_string_nullable` to the URL query string - if (getArrayStringNullable() != null) { - for (int i = 0; i < getArrayStringNullable().size(); i++) { - try { - joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - - // add `string_nullable` to the URL query string - if (getStringNullable() != null) { - try { - joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - return joiner.toString(); - } - } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java index ffb0408d05b2..dab63f7571e7 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java @@ -20,15 +20,14 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.Category; import org.openapitools.client.model.Tag; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; /** * Pet @@ -41,7 +40,7 @@ Pet.JSON_PROPERTY_TAGS, Pet.JSON_PROPERTY_STATUS }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -111,7 +110,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,7 +136,7 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull + @.annotation.Nonnull @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -163,7 +162,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -194,7 +193,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull + @.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -228,7 +227,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -254,7 +253,7 @@ public Pet status(StatusEnum status) { * pet status in the store * @return status **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -317,99 +316,5 @@ private String toIndentedString(Object o) { 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 `id` to the URL query string - if (getId() != null) { - try { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `name` to the URL query string - if (getName() != null) { - try { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - - // add `category` to the URL query string - if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); - } - - // add `photoUrls` to the URL query string - if (getPhotoUrls() != null) { - for (int i = 0; i < getPhotoUrls().size(); i++) { - try { - joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), "UTF-8").replaceAll("\\+", "%20"))); - } catch (UnsupportedEncodingException e) { - // Should never happen, UTF-8 is always supported - throw new RuntimeException(e); - } - } - } - - // add `tags` to the URL query string - if (getTags() != null) { - for (int i = 0; i < getTags().size(); i++) { - if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - // add `status` to the URL query string - if (getStatus() != null) { - try { - joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), "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/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java index 39ed6122578f..c04e23293647 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java @@ -15,24 +15,29 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; /** * Bird */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonPropertyOrder({ + Bird.JSON_PROPERTY_SIZE, + Bird.JSON_PROPERTY_COLOR +}) +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { - public static final String SERIALIZED_NAME_SIZE = "size"; - @SerializedName(SERIALIZED_NAME_SIZE) + public static final String JSON_PROPERTY_SIZE = "size"; private String size; - public static final String SERIALIZED_NAME_COLOR = "color"; - @SerializedName(SERIALIZED_NAME_COLOR) + public static final String JSON_PROPERTY_COLOR = "color"; private String color; public Bird() { @@ -48,13 +53,17 @@ public Bird size(String size) { * Get size * @return size **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getSize() { return size; } + @JsonProperty(JSON_PROPERTY_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSize(String size) { this.size = size; } @@ -70,13 +79,17 @@ public Bird color(String color) { * Get color * @return color **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COLOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getColor() { return color; } + @JsonProperty(JSON_PROPERTY_COLOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setColor(String color) { this.color = color; } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java index 236c8190bb81..e278b76dfad6 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java @@ -15,24 +15,29 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; /** * Category */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonPropertyOrder({ + Category.JSON_PROPERTY_ID, + Category.JSON_PROPERTY_NAME +}) +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private Long id; - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) + public static final String JSON_PROPERTY_NAME = "name"; private String name; public Category() { @@ -48,13 +53,17 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(Long id) { this.id = id; } @@ -70,13 +79,17 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java index 1e0355bab78f..c8eedf63c08c 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java @@ -15,36 +15,86 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; /** * DataQuery */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery extends Query { - public static final String SERIALIZED_NAME_SUFFIX = "suffix"; - @SerializedName(SERIALIZED_NAME_SUFFIX) +@JsonPropertyOrder({ + DataQuery.JSON_PROPERTY_SUFFIX, + DataQuery.JSON_PROPERTY_TEXT, + DataQuery.JSON_PROPERTY_DATE, + DataQuery.JSON_PROPERTY_ID, + DataQuery.JSON_PROPERTY_OUTCOMES +}) +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery { + public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; - public static final String SERIALIZED_NAME_TEXT = "text"; - @SerializedName(SERIALIZED_NAME_TEXT) + public static final String JSON_PROPERTY_TEXT = "text"; private String text; - public static final String SERIALIZED_NAME_DATE = "date"; - @SerializedName(SERIALIZED_NAME_DATE) + public static final String JSON_PROPERTY_DATE = "date"; private OffsetDateTime date; - public DataQuery() { + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + /** + * Gets or Sets outcomes + */ + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; + private List outcomes = new ArrayList<>(); + public DataQuery() { } public DataQuery suffix(String suffix) { @@ -57,13 +107,17 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getSuffix() { return suffix; } + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSuffix(String suffix) { this.suffix = suffix; } @@ -79,13 +133,17 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getText() { return text; } + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setText(String text) { this.text = text; } @@ -101,18 +159,82 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public OffsetDateTime getDate() { return date; } + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDate(OffsetDateTime date) { this.date = date; } + public DataQuery id(Long id) { + + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(Long id) { + this.id = id; + } + + + public DataQuery outcomes(List outcomes) { + + this.outcomes = outcomes; + return this; + } + + public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public List getOutcomes() { + return outcomes; + } + + + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + @Override public boolean equals(Object o) { if (this == o) { @@ -125,22 +247,24 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - super.equals(o); + Objects.equals(this.id, dataQuery.id) && + Objects.equals(this.outcomes, dataQuery.outcomes); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, super.hashCode()); + return Objects.hash(suffix, text, date, id, outcomes); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 08b9865487cc..15d00cff792a 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -15,29 +15,35 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; /** * DataQueryAllOf */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonPropertyOrder({ + DataQueryAllOf.JSON_PROPERTY_SUFFIX, + DataQueryAllOf.JSON_PROPERTY_TEXT, + DataQueryAllOf.JSON_PROPERTY_DATE +}) +@JsonTypeName("DataQuery_allOf") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { - public static final String SERIALIZED_NAME_SUFFIX = "suffix"; - @SerializedName(SERIALIZED_NAME_SUFFIX) + public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; - public static final String SERIALIZED_NAME_TEXT = "text"; - @SerializedName(SERIALIZED_NAME_TEXT) + public static final String JSON_PROPERTY_TEXT = "text"; private String text; - public static final String SERIALIZED_NAME_DATE = "date"; - @SerializedName(SERIALIZED_NAME_DATE) + public static final String JSON_PROPERTY_DATE = "date"; private OffsetDateTime date; public DataQueryAllOf() { @@ -53,13 +59,17 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getSuffix() { return suffix; } + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSuffix(String suffix) { this.suffix = suffix; } @@ -75,13 +85,17 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getText() { return text; } + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setText(String text) { this.text = text; } @@ -97,13 +111,17 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public OffsetDateTime getDate() { return date; } + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDate(OffsetDateTime date) { this.date = date; } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java index 84ac9669049f..9d7f2fe5617d 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -15,30 +15,43 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import org.openapitools.client.model.StringEnumRef; 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; /** * to test the default value of properties */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonPropertyOrder({ + DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT, + DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT, + DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT, + DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT, + DefaultValue.JSON_PROPERTY_ARRAY_STRING, + DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE, + DefaultValue.JSON_PROPERTY_STRING_NULLABLE +}) +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { - public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; - @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT) - private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; + private List arrayStringEnumRefDefault = new ArrayList<>(); /** * Gets or Sets arrayStringEnumDefault */ - @JsonAdapter(ArrayStringEnumDefaultEnum.Adapter.class) public enum ArrayStringEnumDefaultEnum { SUCCESS("success"), @@ -52,6 +65,7 @@ public enum ArrayStringEnumDefaultEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -61,6 +75,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static ArrayStringEnumDefaultEnum fromValue(String value) { for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) { if (b.value.equals(value)) { @@ -69,44 +84,25 @@ public static ArrayStringEnumDefaultEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final ArrayStringEnumDefaultEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return ArrayStringEnumDefaultEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; - @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT) - private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; + private List arrayStringEnumDefault = new ArrayList<>(); - public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default"; - @SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT) - private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default"; + private List arrayStringDefault = new ArrayList<>(); - public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default"; - @SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT) - private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default"; + private List arrayIntegerDefault = new ArrayList<>(); - public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string"; - @SerializedName(SERIALIZED_NAME_ARRAY_STRING) + public static final String JSON_PROPERTY_ARRAY_STRING = "array_string"; private List arrayString = new ArrayList<>(); - public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable"; - @SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE) - private List arrayStringNullable; + public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable"; + private JsonNullable> arrayStringNullable = JsonNullable.>undefined(); - public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable"; - @SerializedName(SERIALIZED_NAME_STRING_NULLABLE) - private String stringNullable; + public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable"; + private JsonNullable stringNullable = JsonNullable.undefined(); public DefaultValue() { } @@ -119,7 +115,7 @@ public DefaultValue arrayStringEnumRefDefault(List arrayStringEnu public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) { if (this.arrayStringEnumRefDefault == null) { - this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + this.arrayStringEnumRefDefault = new ArrayList<>(); } this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem); return this; @@ -129,13 +125,17 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getArrayStringEnumRefDefault() { return arrayStringEnumRefDefault; } + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayStringEnumRefDefault(List arrayStringEnumRefDefault) { this.arrayStringEnumRefDefault = arrayStringEnumRefDefault; } @@ -149,7 +149,7 @@ public DefaultValue arrayStringEnumDefault(List arra public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) { if (this.arrayStringEnumDefault == null) { - this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + this.arrayStringEnumDefault = new ArrayList<>(); } this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem); return this; @@ -159,13 +159,17 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getArrayStringEnumDefault() { return arrayStringEnumDefault; } + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayStringEnumDefault(List arrayStringEnumDefault) { this.arrayStringEnumDefault = arrayStringEnumDefault; } @@ -179,7 +183,7 @@ public DefaultValue arrayStringDefault(List arrayStringDefault) { public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { if (this.arrayStringDefault == null) { - this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + this.arrayStringDefault = new ArrayList<>(); } this.arrayStringDefault.add(arrayStringDefaultItem); return this; @@ -189,13 +193,17 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getArrayStringDefault() { return arrayStringDefault; } + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayStringDefault(List arrayStringDefault) { this.arrayStringDefault = arrayStringDefault; } @@ -209,7 +217,7 @@ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) { public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) { if (this.arrayIntegerDefault == null) { - this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + this.arrayIntegerDefault = new ArrayList<>(); } this.arrayIntegerDefault.add(arrayIntegerDefaultItem); return this; @@ -219,13 +227,17 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getArrayIntegerDefault() { return arrayIntegerDefault; } + @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayIntegerDefault(List arrayIntegerDefault) { this.arrayIntegerDefault = arrayIntegerDefault; } @@ -249,26 +261,37 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ARRAY_STRING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getArrayString() { return arrayString; } + @JsonProperty(JSON_PROPERTY_ARRAY_STRING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayString(List arrayString) { this.arrayString = arrayString; } public DefaultValue arrayStringNullable(List arrayStringNullable) { + this.arrayStringNullable = JsonNullable.>of(arrayStringNullable); - this.arrayStringNullable = arrayStringNullable; return this; } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - this.arrayStringNullable.add(arrayStringNullableItem); + if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) { + this.arrayStringNullable = JsonNullable.>of(new ArrayList<>()); + } + try { + this.arrayStringNullable.get().add(arrayStringNullableItem); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } return this; } @@ -276,21 +299,33 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonIgnore public List getArrayStringNullable() { - return arrayStringNullable; + return arrayStringNullable.orElse(null); } + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setArrayStringNullable(List arrayStringNullable) { + public JsonNullable> getArrayStringNullable_JsonNullable() { + return arrayStringNullable; + } + + @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE) + public void setArrayStringNullable_JsonNullable(JsonNullable> arrayStringNullable) { this.arrayStringNullable = arrayStringNullable; } + public void setArrayStringNullable(List arrayStringNullable) { + this.arrayStringNullable = JsonNullable.>of(arrayStringNullable); + } + public DefaultValue stringNullable(String stringNullable) { + this.stringNullable = JsonNullable.of(stringNullable); - this.stringNullable = stringNullable; return this; } @@ -298,17 +333,29 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonIgnore public String getStringNullable() { - return stringNullable; + return stringNullable.orElse(null); } + @JsonProperty(JSON_PROPERTY_STRING_NULLABLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setStringNullable(String stringNullable) { + public JsonNullable getStringNullable_JsonNullable() { + return stringNullable; + } + + @JsonProperty(JSON_PROPERTY_STRING_NULLABLE) + public void setStringNullable_JsonNullable(JsonNullable stringNullable) { this.stringNullable = stringNullable; } + public void setStringNullable(String stringNullable) { + this.stringNullable = JsonNullable.of(stringNullable); + } + @Override public boolean equals(Object o) { @@ -324,8 +371,8 @@ public boolean equals(Object o) { Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) && Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) && Objects.equals(this.arrayString, defaultValue.arrayString) && - Objects.equals(this.arrayStringNullable, defaultValue.arrayStringNullable) && - Objects.equals(this.stringNullable, defaultValue.stringNullable); + equalsNullable(this.arrayStringNullable, defaultValue.arrayStringNullable) && + equalsNullable(this.stringNullable, defaultValue.stringNullable); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -334,7 +381,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable); + return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable)); } private static int hashCodeNullable(JsonNullable a) { diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java index 23b255c290d0..dab63f7571e7 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java @@ -15,46 +15,51 @@ import java.util.Objects; import java.util.Arrays; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import org.openapitools.client.model.Category; import org.openapitools.client.model.Tag; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; /** * Pet */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonPropertyOrder({ + Pet.JSON_PROPERTY_ID, + Pet.JSON_PROPERTY_NAME, + Pet.JSON_PROPERTY_CATEGORY, + Pet.JSON_PROPERTY_PHOTO_URLS, + Pet.JSON_PROPERTY_TAGS, + Pet.JSON_PROPERTY_STATUS +}) +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) + public static final String JSON_PROPERTY_ID = "id"; private Long id; - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) + public static final String JSON_PROPERTY_NAME = "name"; private String name; - public static final String SERIALIZED_NAME_CATEGORY = "category"; - @SerializedName(SERIALIZED_NAME_CATEGORY) + public static final String JSON_PROPERTY_CATEGORY = "category"; private Category category; - public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls"; - @SerializedName(SERIALIZED_NAME_PHOTO_URLS) + public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls"; private List photoUrls = new ArrayList<>(); - public static final String SERIALIZED_NAME_TAGS = "tags"; - @SerializedName(SERIALIZED_NAME_TAGS) + public static final String JSON_PROPERTY_TAGS = "tags"; private List tags = new ArrayList<>(); /** * pet status in the store */ - @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { AVAILABLE("available"), @@ -68,6 +73,7 @@ public enum StatusEnum { this.value = value; } + @JsonValue public String getValue() { return value; } @@ -77,6 +83,7 @@ public String toString() { return String.valueOf(value); } + @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { @@ -85,23 +92,9 @@ public static StatusEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } - } } - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) + public static final String JSON_PROPERTY_STATUS = "status"; private StatusEnum status; public Pet() { @@ -117,13 +110,17 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(Long id) { this.id = id; } @@ -139,13 +136,17 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull + @.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setName(String name) { this.name = name; } @@ -161,13 +162,17 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Category getCategory() { return category; } + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCategory(Category category) { this.category = category; } @@ -188,13 +193,17 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull + @.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public List getPhotoUrls() { return photoUrls; } + @JsonProperty(JSON_PROPERTY_PHOTO_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } @@ -218,13 +227,17 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getTags() { return tags; } + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTags(List tags) { this.tags = tags; } @@ -240,13 +253,17 @@ public Pet status(StatusEnum status) { * pet status in the store * @return status **/ - @javax.annotation.Nullable + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { return status; } + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStatus(StatusEnum status) { this.status = status; } diff --git a/samples/client/echo_api/java/native/docs/DataQuery.md b/samples/client/echo_api/java/native/docs/DataQuery.md index 338c467b2d56..5beb983af973 100644 --- a/samples/client/echo_api/java/native/docs/DataQuery.md +++ b/samples/client/echo_api/java/native/docs/DataQuery.md @@ -10,6 +10,18 @@ |**suffix** | **String** | test suffix | [optional] | |**text** | **String** | Some text containing white spaces | [optional] | |**date** | **OffsetDateTime** | A date | [optional] | +|**id** | **Long** | Query | [optional] | +|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | + + + +## Enum: List<OutcomesEnum> + +| Name | Value | +|---- | -----| +| SUCCESS | "SUCCESS" | +| FAILURE | "FAILURE" | +| SKIPPED | "SKIPPED" | diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java index 7bc3649a8631..e4161a695bb6 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -35,7 +34,7 @@ Bird.JSON_PROPERTY_SIZE, Bird.JSON_PROPERTY_COLOR }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { public static final String JSON_PROPERTY_SIZE = "size"; private String size; @@ -55,7 +54,7 @@ public Bird size(String size) { * Get size * @return size **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SIZE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +79,7 @@ public Bird color(String color) { * Get color * @return color **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_COLOR) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,50 +136,5 @@ private String toIndentedString(Object o) { } 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 `size` to the URL query string - if (getSize() != null) { - joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `color` to the URL query string - if (getColor() != null) { - joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java index d647aea29bf4..0aaed79d4809 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -35,7 +34,7 @@ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -55,7 +54,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +79,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,50 +136,5 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java index 23fd24cf1790..e9f24440745c 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,9 +22,12 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -38,10 +38,12 @@ @JsonPropertyOrder({ DataQuery.JSON_PROPERTY_SUFFIX, DataQuery.JSON_PROPERTY_TEXT, - DataQuery.JSON_PROPERTY_DATE + DataQuery.JSON_PROPERTY_DATE, + DataQuery.JSON_PROPERTY_ID, + DataQuery.JSON_PROPERTY_OUTCOMES }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery extends Query { +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -51,6 +53,49 @@ public class DataQuery extends Query { public static final String JSON_PROPERTY_DATE = "date"; private OffsetDateTime date; + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + /** + * Gets or Sets outcomes + */ + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; + private List outcomes = new ArrayList<>(); + public DataQuery() { } @@ -63,7 +108,7 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -88,7 +133,7 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -113,7 +158,7 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -129,6 +174,64 @@ public void setDate(OffsetDateTime date) { } + public DataQuery id(Long id) { + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(Long id) { + this.id = id; + } + + + public DataQuery outcomes(List outcomes) { + this.outcomes = outcomes; + return this; + } + + public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public List getOutcomes() { + return outcomes; + } + + + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + /** * Return true if this DataQuery object is equal to o. */ @@ -144,22 +247,24 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - super.equals(o); + Objects.equals(this.id, dataQuery.id) && + Objects.equals(this.outcomes, dataQuery.outcomes); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, super.hashCode()); + return Objects.hash(suffix, text, date, id, outcomes); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } @@ -174,69 +279,5 @@ private String toIndentedString(Object o) { } 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 `suffix` to the URL query string - if (getSuffix() != null) { - joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `text` to the URL query string - if (getText() != null) { - joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `date` to the URL query string - if (getDate() != null) { - joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `outcomes` to the URL query string - if (getOutcomes() != null) { - for (int i = 0; i < getOutcomes().size(); i++) { - joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getOutcomes().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - return joiner.toString(); - } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 16f726a615b7..08ae093dbee6 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -37,7 +36,7 @@ DataQueryAllOf.JSON_PROPERTY_TEXT, DataQueryAllOf.JSON_PROPERTY_DATE }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -60,7 +59,7 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -85,7 +84,7 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -110,7 +109,7 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -169,55 +168,5 @@ private String toIndentedString(Object o) { } 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 `suffix` to the URL query string - if (getSuffix() != null) { - joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `text` to the URL query string - if (getText() != null) { - joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `date` to the URL query string - if (getDate() != null) { - joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java index 28f3c70e6346..08a062454228 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.StringEnumRef; @@ -47,10 +46,10 @@ DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE, DefaultValue.JSON_PROPERTY_STRING_NULLABLE }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; - private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + private List arrayStringEnumRefDefault = new ArrayList<>(); /** * Gets or Sets arrayStringEnumDefault @@ -90,13 +89,13 @@ public static ArrayStringEnumDefaultEnum fromValue(String value) { } public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; - private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + private List arrayStringEnumDefault = new ArrayList<>(); public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default"; - private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + private List arrayStringDefault = new ArrayList<>(); public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default"; - private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + private List arrayIntegerDefault = new ArrayList<>(); public static final String JSON_PROPERTY_ARRAY_STRING = "array_string"; private List arrayString = new ArrayList<>(); @@ -127,7 +126,7 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -160,7 +159,7 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -193,7 +192,7 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -226,7 +225,7 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -259,7 +258,7 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -296,7 +295,7 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonIgnore public List getArrayStringNullable() { @@ -329,7 +328,7 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonIgnore public String getStringNullable() { @@ -415,101 +414,5 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `array_string_enum_ref_default` to the URL query string - if (getArrayStringEnumRefDefault() != null) { - for (int i = 0; i < getArrayStringEnumRefDefault().size(); i++) { - if (getArrayStringEnumRefDefault().get(i) != null) { - joiner.add(String.format("%sarray_string_enum_ref_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringEnumRefDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - } - - // add `array_string_enum_default` to the URL query string - if (getArrayStringEnumDefault() != null) { - for (int i = 0; i < getArrayStringEnumDefault().size(); i++) { - joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - // add `array_string_default` to the URL query string - if (getArrayStringDefault() != null) { - for (int i = 0; i < getArrayStringDefault().size(); i++) { - joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - // add `array_integer_default` to the URL query string - if (getArrayIntegerDefault() != null) { - for (int i = 0; i < getArrayIntegerDefault().size(); i++) { - joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - // add `array_string` to the URL query string - if (getArrayString() != null) { - for (int i = 0; i < getArrayString().size(); i++) { - joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - // add `array_string_nullable` to the URL query string - if (getArrayStringNullable() != null) { - for (int i = 0; i < getArrayStringNullable().size(); i++) { - joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - // add `string_nullable` to the URL query string - if (getStringNullable() != null) { - joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md b/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md index 338c467b2d56..5beb983af973 100644 --- a/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md +++ b/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md @@ -10,6 +10,18 @@ |**suffix** | **String** | test suffix | [optional] | |**text** | **String** | Some text containing white spaces | [optional] | |**date** | **OffsetDateTime** | A date | [optional] | +|**id** | **Long** | Query | [optional] | +|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | + + + +## Enum: List<OutcomesEnum> + +| Name | Value | +|---- | -----| +| SUCCESS | "SUCCESS" | +| FAILURE | "FAILURE" | +| SKIPPED | "SKIPPED" | diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java index 0e54b8e21a8c..b56b91c263c5 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * Bird */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { public static final String SERIALIZED_NAME_SIZE = "size"; @SerializedName(SERIALIZED_NAME_SIZE) @@ -69,7 +71,7 @@ public Bird size(String size) { * Get size * @return size **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getSize() { return size; @@ -91,7 +93,7 @@ public Bird color(String color) { * Get color * @return color **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getColor() { return color; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java index 9b9f3df7d1f1..5ae560afa09f 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * Category */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -69,7 +71,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -91,7 +93,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java index 52c90035ee57..93b1cbe7903a 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java @@ -20,10 +20,13 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; +import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; import com.google.gson.Gson; @@ -50,8 +53,8 @@ /** * DataQuery */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery extends Query { +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery { public static final String SERIALIZED_NAME_SUFFIX = "suffix"; @SerializedName(SERIALIZED_NAME_SUFFIX) private String suffix; @@ -64,6 +67,63 @@ public class DataQuery extends Query { @SerializedName(SERIALIZED_NAME_DATE) private OffsetDateTime date; + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private Long id; + + /** + * Gets or Sets outcomes + */ + @JsonAdapter(OutcomesEnum.Adapter.class) + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OutcomesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public OutcomesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return OutcomesEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_OUTCOMES = "outcomes"; + @SerializedName(SERIALIZED_NAME_OUTCOMES) + private List outcomes = new ArrayList<>(); + public DataQuery() { } @@ -77,7 +137,7 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getSuffix() { return suffix; @@ -99,7 +159,7 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getText() { return text; @@ -121,7 +181,7 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable public OffsetDateTime getDate() { return date; @@ -133,6 +193,58 @@ public void setDate(OffsetDateTime date) { } + public DataQuery id(Long id) { + + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @.annotation.Nullable + + public Long getId() { + return id; + } + + + public void setId(Long id) { + this.id = id; + } + + + public DataQuery outcomes(List outcomes) { + + this.outcomes = outcomes; + return this; + } + + public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @.annotation.Nullable + + public List getOutcomes() { + return outcomes; + } + + + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + @Override public boolean equals(Object o) { @@ -146,22 +258,24 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - super.equals(o); + Objects.equals(this.id, dataQuery.id) && + Objects.equals(this.outcomes, dataQuery.outcomes); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, super.hashCode()); + return Objects.hash(suffix, text, date, id, outcomes); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } @@ -220,6 +334,10 @@ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); } + // ensure the optional json data is an array if present + if (jsonObj.get("outcomes") != null && !jsonObj.get("outcomes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `outcomes` to be an array in the JSON string but got `%s`", jsonObj.get("outcomes").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 950251095b3e..9d7b2600a144 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; @@ -47,7 +49,7 @@ /** * DataQueryAllOf */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { public static final String SERIALIZED_NAME_SUFFIX = "suffix"; @SerializedName(SERIALIZED_NAME_SUFFIX) @@ -74,7 +76,7 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getSuffix() { return suffix; @@ -96,7 +98,7 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getText() { return text; @@ -118,7 +120,7 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @javax.annotation.Nullable + @.annotation.Nullable public OffsetDateTime getDate() { return date; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java index 420af1f7ff6c..7d64b77146af 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -50,11 +52,11 @@ /** * to test the default value of properties */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT) - private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + private List arrayStringEnumRefDefault = new ArrayList<>(); /** * Gets or Sets arrayStringEnumDefault @@ -107,15 +109,15 @@ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOExc public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT) - private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + private List arrayStringEnumDefault = new ArrayList<>(); public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT) - private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + private List arrayStringDefault = new ArrayList<>(); public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default"; @SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT) - private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + private List arrayIntegerDefault = new ArrayList<>(); public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING) @@ -123,7 +125,7 @@ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOExc public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE) - private List arrayStringNullable; + private List arrayStringNullable = new ArrayList<>(); public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable"; @SerializedName(SERIALIZED_NAME_STRING_NULLABLE) @@ -140,7 +142,7 @@ public DefaultValue arrayStringEnumRefDefault(List arrayStringEnu public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) { if (this.arrayStringEnumRefDefault == null) { - this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); + this.arrayStringEnumRefDefault = new ArrayList<>(); } this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem); return this; @@ -150,7 +152,7 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getArrayStringEnumRefDefault() { return arrayStringEnumRefDefault; @@ -170,7 +172,7 @@ public DefaultValue arrayStringEnumDefault(List arra public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) { if (this.arrayStringEnumDefault == null) { - this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); + this.arrayStringEnumDefault = new ArrayList<>(); } this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem); return this; @@ -180,7 +182,7 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getArrayStringEnumDefault() { return arrayStringEnumDefault; @@ -200,7 +202,7 @@ public DefaultValue arrayStringDefault(List arrayStringDefault) { public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { if (this.arrayStringDefault == null) { - this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); + this.arrayStringDefault = new ArrayList<>(); } this.arrayStringDefault.add(arrayStringDefaultItem); return this; @@ -210,7 +212,7 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getArrayStringDefault() { return arrayStringDefault; @@ -230,7 +232,7 @@ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) { public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) { if (this.arrayIntegerDefault == null) { - this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); + this.arrayIntegerDefault = new ArrayList<>(); } this.arrayIntegerDefault.add(arrayIntegerDefaultItem); return this; @@ -240,7 +242,7 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getArrayIntegerDefault() { return arrayIntegerDefault; @@ -270,7 +272,7 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getArrayString() { return arrayString; @@ -289,6 +291,9 @@ public DefaultValue arrayStringNullable(List arrayStringNullable) { } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { + if (this.arrayStringNullable == null) { + this.arrayStringNullable = new ArrayList<>(); + } this.arrayStringNullable.add(arrayStringNullableItem); return this; } @@ -297,7 +302,7 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getArrayStringNullable() { return arrayStringNullable; @@ -319,7 +324,7 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getStringNullable() { return stringNullable; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java index c3aa75d476bf..abf95ac4da6d 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -50,7 +52,7 @@ /** * Pet */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -138,7 +140,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -160,7 +162,7 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull + @.annotation.Nonnull public String getName() { return name; @@ -182,7 +184,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable + @.annotation.Nullable public Category getCategory() { return category; @@ -209,7 +211,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull + @.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -239,7 +241,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getTags() { return tags; @@ -261,7 +263,7 @@ public Pet status(StatusEnum status) { * pet status in the store * @return status **/ - @javax.annotation.Nullable + @.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java index 275a49dcf429..122b562fff7f 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.Iterator; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java index 72a4e7910c96..3d0a2b1f6d79 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java @@ -35,7 +35,7 @@ import java.util.List; import java.util.Map; import java.io.InputStream; -import javax.ws.rs.core.GenericType; +import .ws.rs.core.GenericType; public class PingApi { private ApiClient localVarApiClient; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java index d41b8a58391c..a060052c9771 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java index 96f57427e9fd..aa9ee01f9136 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBearerAuth implements Authentication { private final String scheme; private String bearerToken; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java index dde198e60683..f71b3d6745d8 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * SomeObj */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SomeObj { /** * Gets or Sets $type @@ -126,7 +128,7 @@ public SomeObj() { * Get $type * @return $type **/ - @javax.annotation.Nullable + @.annotation.Nullable public TypeEnum get$Type() { return $type; @@ -148,7 +150,7 @@ public SomeObj id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -170,7 +172,7 @@ public SomeObj name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getName() { return name; @@ -192,7 +194,7 @@ public SomeObj active(Boolean active) { * Get active * @return active **/ - @javax.annotation.Nullable + @.annotation.Nullable public Boolean getActive() { return active; @@ -214,7 +216,7 @@ public SomeObj type(String type) { * Get type * @return type **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getType() { return type; diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java index 7d5241198622..b93958095133 100644 --- a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java @@ -43,8 +43,6 @@ public class Order { @JsonbProperty("shipDate") private Date shipDate; - @JsonbTypeSerializer(StatusEnum.Serializer.class) - @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); @@ -65,24 +63,6 @@ public String toString() { return String.valueOf(value); } - public static final class Deserializer implements JsonbDeserializer { - @Override - public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(parser.getString())) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); - } - } - - public static final class Serializer implements JsonbSerializer { - @Override - public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { - generator.write(obj.value); - } - } } /** diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java index d39f45d721e0..895e50c3025b 100644 --- a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java @@ -49,8 +49,6 @@ public class Pet { @JsonbProperty("tags") private List tags = null; - @JsonbTypeSerializer(StatusEnum.Serializer.class) - @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); @@ -71,24 +69,6 @@ public String toString() { return String.valueOf(value); } - public static final class Deserializer implements JsonbDeserializer { - @Override - public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(parser.getString())) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); - } - } - - public static final class Serializer implements JsonbSerializer { - @Override - public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { - generator.write(obj.value); - } - } } /** diff --git a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java index b775633f6ce7..e245de60ca08 100644 --- a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java @@ -43,8 +43,6 @@ public class Order { @JsonbProperty("shipDate") private Date shipDate; - @JsonbTypeSerializer(StatusEnum.Serializer.class) - @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); @@ -65,24 +63,6 @@ public String toString() { return String.valueOf(value); } - public static final class Deserializer implements JsonbDeserializer { - @Override - public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(parser.getString())) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); - } - } - - public static final class Serializer implements JsonbSerializer { - @Override - public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { - generator.write(obj.value); - } - } } /** diff --git a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java index 9b415336ac06..7c6a4fbfd3fd 100644 --- a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java @@ -49,8 +49,6 @@ public class Pet { @JsonbProperty("tags") private List tags = null; - @JsonbTypeSerializer(StatusEnum.Serializer.class) - @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); @@ -71,24 +69,6 @@ public String toString() { return String.valueOf(value); } - public static final class Deserializer implements JsonbDeserializer { - @Override - public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(parser.getString())) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); - } - } - - public static final class Serializer implements JsonbSerializer { - @Override - public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { - generator.write(obj.value); - } - } } /** diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java index 098d777d9942..9d044c36ff23 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -35,7 +34,7 @@ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -55,7 +54,7 @@ public Category id(Long id) { * Get id * @return id **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +79,7 @@ public Category name(String name) { * Get name * @return name **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,50 +136,5 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 1ac8d3f977e7..3d19ee41161e 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -36,7 +35,7 @@ ModelApiResponse.JSON_PROPERTY_TYPE, ModelApiResponse.JSON_PROPERTY_MESSAGE }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String JSON_PROPERTY_CODE = "code"; private Integer code; @@ -59,7 +58,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -84,7 +83,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -109,7 +108,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -168,55 +167,5 @@ private String toIndentedString(Object o) { } 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 `code` to the URL query string - if (getCode() != null) { - joiner.add(String.format("%scode%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `type` to the URL query string - if (getType() != null) { - joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `message` to the URL query string - if (getMessage() != null) { - joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java index c64c67c42aba..902d45a51602 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -40,7 +39,7 @@ Order.JSON_PROPERTY_STATUS, Order.JSON_PROPERTY_COMPLETE }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -109,7 +108,7 @@ public Order id(Long id) { * Get id * @return id **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -134,7 +133,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -159,7 +158,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -184,7 +183,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -209,7 +208,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -234,7 +233,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -299,70 +298,5 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `petId` to the URL query string - if (getPetId() != null) { - joiner.add(String.format("%spetId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `quantity` to the URL query string - if (getQuantity() != null) { - joiner.add(String.format("%squantity%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `shipDate` to the URL query string - if (getShipDate() != null) { - joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `status` to the URL query string - if (getStatus() != null) { - joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `complete` to the URL query string - if (getComplete() != null) { - joiner.add(String.format("%scomplete%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java index c003989b3414..343855b6d83b 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.Category; @@ -43,7 +42,7 @@ Pet.JSON_PROPERTY_TAGS, Pet.JSON_PROPERTY_STATUS }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -112,7 +111,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,7 +136,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -162,7 +161,7 @@ public Pet name(String name) { * Get name * @return name **/ - @jakarta.annotation.Nonnull + @.annotation.Nonnull @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -192,7 +191,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @jakarta.annotation.Nonnull + @.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -225,7 +224,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -252,7 +251,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -317,79 +316,5 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `category` to the URL query string - if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `photoUrls` to the URL query string - if (getPhotoUrls() != null) { - for (int i = 0; i < getPhotoUrls().size(); i++) { - joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - } - - // add `tags` to the URL query string - if (getTags() != null) { - for (int i = 0; i < getTags().size(); i++) { - if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - // add `status` to the URL query string - if (getStatus() != null) { - joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java index d59987169b90..e4888fa3a4de 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java @@ -13,9 +13,6 @@ package org.openapitools.client.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -25,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -35,7 +34,7 @@ Tag.JSON_PROPERTY_ID, Tag.JSON_PROPERTY_NAME }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -55,7 +54,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +79,7 @@ public Tag name(String name) { * Get name * @return name **/ - @jakarta.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,50 +136,5 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java index 74e474b0e27a..c17f5b7f4c21 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * A category for a pet */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -69,7 +71,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -91,7 +93,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 855c8732c421..b8cdd90b944d 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * Describes the result of uploading an image resource */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) @@ -73,7 +75,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @javax.annotation.Nullable + @.annotation.Nullable public Integer getCode() { return code; @@ -95,7 +97,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getType() { return type; @@ -117,7 +119,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getMessage() { return message; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java index b6069802987b..eb7ac449ae09 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; @@ -47,7 +49,7 @@ /** * An order for a pets from the pet store */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -135,7 +137,7 @@ public Order id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -157,7 +159,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getPetId() { return petId; @@ -179,7 +181,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @javax.annotation.Nullable + @.annotation.Nullable public Integer getQuantity() { return quantity; @@ -201,7 +203,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @javax.annotation.Nullable + @.annotation.Nullable public OffsetDateTime getShipDate() { return shipDate; @@ -223,7 +225,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @javax.annotation.Nullable + @.annotation.Nullable public StatusEnum getStatus() { return status; @@ -245,7 +247,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @javax.annotation.Nullable + @.annotation.Nullable public Boolean getComplete() { return complete; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java index 7c1fae694270..f7d611413e34 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -50,7 +52,7 @@ /** * A pet for sale in the pet store */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -138,7 +140,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -160,7 +162,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable + @.annotation.Nullable public Category getCategory() { return category; @@ -182,7 +184,7 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull + @.annotation.Nonnull public String getName() { return name; @@ -209,7 +211,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull + @.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -239,7 +241,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getTags() { return tags; @@ -263,7 +265,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @javax.annotation.Nullable + @.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java index 312895d569ff..6b939a3e9afd 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * A tag for a pet */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -69,7 +71,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -91,7 +93,7 @@ public Tag name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java index 3078490c3af5..7165ee7e93fa 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * A User who is purchasing from the pet store */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class User { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -93,7 +95,7 @@ public User id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -115,7 +117,7 @@ public User username(String username) { * Get username * @return username **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getUsername() { return username; @@ -137,7 +139,7 @@ public User firstName(String firstName) { * Get firstName * @return firstName **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getFirstName() { return firstName; @@ -159,7 +161,7 @@ public User lastName(String lastName) { * Get lastName * @return lastName **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getLastName() { return lastName; @@ -181,7 +183,7 @@ public User email(String email) { * Get email * @return email **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getEmail() { return email; @@ -203,7 +205,7 @@ public User password(String password) { * Get password * @return password **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getPassword() { return password; @@ -225,7 +227,7 @@ public User phone(String phone) { * Get phone * @return phone **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getPhone() { return phone; @@ -247,7 +249,7 @@ public User userStatus(Integer userStatus) { * User Status * @return userStatus **/ - @javax.annotation.Nullable + @.annotation.Nullable public Integer getUserStatus() { return userStatus; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java index 74e474b0e27a..c17f5b7f4c21 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * A category for a pet */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -69,7 +71,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -91,7 +93,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 855c8732c421..b8cdd90b944d 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * Describes the result of uploading an image resource */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) @@ -73,7 +75,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @javax.annotation.Nullable + @.annotation.Nullable public Integer getCode() { return code; @@ -95,7 +97,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getType() { return type; @@ -117,7 +119,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getMessage() { return message; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java index b6069802987b..eb7ac449ae09 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; @@ -47,7 +49,7 @@ /** * An order for a pets from the pet store */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -135,7 +137,7 @@ public Order id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -157,7 +159,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getPetId() { return petId; @@ -179,7 +181,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @javax.annotation.Nullable + @.annotation.Nullable public Integer getQuantity() { return quantity; @@ -201,7 +203,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @javax.annotation.Nullable + @.annotation.Nullable public OffsetDateTime getShipDate() { return shipDate; @@ -223,7 +225,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @javax.annotation.Nullable + @.annotation.Nullable public StatusEnum getStatus() { return status; @@ -245,7 +247,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @javax.annotation.Nullable + @.annotation.Nullable public Boolean getComplete() { return complete; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java index 7c1fae694270..f7d611413e34 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -50,7 +52,7 @@ /** * A pet for sale in the pet store */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -138,7 +140,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -160,7 +162,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable + @.annotation.Nullable public Category getCategory() { return category; @@ -182,7 +184,7 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull + @.annotation.Nonnull public String getName() { return name; @@ -209,7 +211,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull + @.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -239,7 +241,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable + @.annotation.Nullable public List getTags() { return tags; @@ -263,7 +265,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @javax.annotation.Nullable + @.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java index 312895d569ff..6b939a3e9afd 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java @@ -20,6 +20,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -46,7 +48,7 @@ /** * A tag for a pet */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -69,7 +71,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable + @.annotation.Nullable public Long getId() { return id; @@ -91,7 +93,7 @@ public Tag name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java index d404c0c07ca6..c17f5b7f4c21 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java @@ -48,8 +48,7 @@ /** * A category for a pet */ -@ApiModel(description = "A category for a pet") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -72,8 +71,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Long getId() { return id; @@ -95,8 +93,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java index db10be182961..b8cdd90b944d 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -48,8 +48,7 @@ /** * Describes the result of uploading an image resource */ -@ApiModel(description = "Describes the result of uploading an image resource") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) @@ -76,8 +75,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Integer getCode() { return code; @@ -99,8 +97,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getType() { return type; @@ -122,8 +119,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getMessage() { return message; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java index 547ed754b820..eb7ac449ae09 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java @@ -49,8 +49,7 @@ /** * An order for a pets from the pet store */ -@ApiModel(description = "An order for a pets from the pet store") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -138,8 +137,7 @@ public Order id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Long getId() { return id; @@ -161,8 +159,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Long getPetId() { return petId; @@ -184,8 +181,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Integer getQuantity() { return quantity; @@ -207,8 +203,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public OffsetDateTime getShipDate() { return shipDate; @@ -230,8 +225,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Order Status") + @.annotation.Nullable public StatusEnum getStatus() { return status; @@ -253,8 +247,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Boolean getComplete() { return complete; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java index 1deb29bce92c..f7d611413e34 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java @@ -52,8 +52,7 @@ /** * A pet for sale in the pet store */ -@ApiModel(description = "A pet for sale in the pet store") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -141,8 +140,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Long getId() { return id; @@ -164,8 +162,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Category getCategory() { return category; @@ -187,8 +184,7 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull - @ApiModelProperty(example = "doggie", required = true, value = "") + @.annotation.Nonnull public String getName() { return name; @@ -215,8 +211,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") + @.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -246,8 +241,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public List getTags() { return tags; @@ -271,8 +265,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @javax.annotation.Nullable - @ApiModelProperty(value = "pet status in the store") + @.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java index d6e095358fa4..6b939a3e9afd 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java @@ -48,8 +48,7 @@ /** * A tag for a pet */ -@ApiModel(description = "A tag for a pet") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -72,8 +71,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Long getId() { return id; @@ -95,8 +93,7 @@ public Tag name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java index 3dc3fc06dfa0..7165ee7e93fa 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java @@ -48,8 +48,7 @@ /** * A User who is purchasing from the pet store */ -@ApiModel(description = "A User who is purchasing from the pet store") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class User { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -96,8 +95,7 @@ public User id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public Long getId() { return id; @@ -119,8 +117,7 @@ public User username(String username) { * Get username * @return username **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getUsername() { return username; @@ -142,8 +139,7 @@ public User firstName(String firstName) { * Get firstName * @return firstName **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getFirstName() { return firstName; @@ -165,8 +161,7 @@ public User lastName(String lastName) { * Get lastName * @return lastName **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getLastName() { return lastName; @@ -188,8 +183,7 @@ public User email(String email) { * Get email * @return email **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getEmail() { return email; @@ -211,8 +205,7 @@ public User password(String password) { * Get password * @return password **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getPassword() { return password; @@ -234,8 +227,7 @@ public User phone(String phone) { * Get phone * @return phone **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable public String getPhone() { return phone; @@ -257,8 +249,7 @@ public User userStatus(Integer userStatus) { * User Status * @return userStatus **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "User Status") + @.annotation.Nullable public Integer getUserStatus() { return userStatus; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java index 561f5e521900..8c64c58dec0d 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java @@ -1,15 +1,15 @@ package org.openapitools.client; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Form; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import .ws.rs.client.Client; +import .ws.rs.client.ClientBuilder; +import .ws.rs.client.Entity; +import .ws.rs.client.Invocation; +import .ws.rs.client.WebTarget; +import .ws.rs.core.Form; +import .ws.rs.core.GenericType; +import .ws.rs.core.MediaType; +import .ws.rs.core.Response; +import .ws.rs.core.Response.Status; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.ClientProperties; @@ -66,7 +66,7 @@ /** *

ApiClient class.

*/ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiClient extends JavaTimeFormatter { protected Map defaultHeaderMap = new HashMap(); protected Map defaultCookieMap = new HashMap(); @@ -199,7 +199,7 @@ public JSON getJSON() { /** *

Getter for the field httpClient.

* - * @return a {@link javax.ws.rs.client.Client} object. + * @return a {@link .ws.rs.client.Client} object. */ public Client getHttpClient() { return httpClient; @@ -208,7 +208,7 @@ public Client getHttpClient() { /** *

Setter for the field httpClient.

* - * @param httpClient a {@link javax.ws.rs.client.Client} object. + * @param httpClient a {@link .ws.rs.client.Client} object. * @return a {@link org.openapitools.client.ApiClient} object. */ public ApiClient setHttpClient(Client httpClient) { @@ -929,7 +929,7 @@ public File downloadFileFromResponse(Response response) throws ApiException { /** *

Prepare the file for download from the response.

* - * @param response a {@link javax.ws.rs.core.Response} object. + * @param response a {@link .ws.rs.core.Response} object. * @return a {@link java.io.File} object. * @throws java.io.IOException if any. */ @@ -1193,7 +1193,7 @@ public ClientConfig getDefaultClientConfig() { * To completely disable certificate validation (at your own risk), you can * override this method and invoke disableCertificateValidation(clientBuilder). * - * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object. + * @param clientBuilder a {@link .ws.rs.client.ClientBuilder} object. */ protected void customizeClientBuilder(ClientBuilder clientBuilder) { // No-op extension point @@ -1205,7 +1205,7 @@ protected void customizeClientBuilder(ClientBuilder clientBuilder) { * Please note that trusting all certificates is extremely risky. * This may be useful in a development environment with self-signed certificates. * - * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object. + * @param clientBuilder a {@link .ws.rs.client.ClientBuilder} object. * @throws java.security.KeyManagementException if any. * @throws java.security.NoSuchAlgorithmException if any. */ @@ -1232,7 +1232,7 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) { /** *

Build the response headers.

* - * @param response a {@link javax.ws.rs.core.Response} object. + * @param response a {@link .ws.rs.core.Response} object. * @return a {@link java.util.Map} of response headers. */ protected Map> buildResponseHeaders(Response response) { diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java index 0559ac98ab96..aadc1fb91ee9 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java @@ -20,7 +20,7 @@ * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class. * It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}. */ -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class JavaTimeFormatter { private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java index baacf90a2b13..03f3555f2405 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.Iterator; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java index 3b1d2d280f05..f9a1aa01b4be 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java @@ -6,7 +6,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.Pair; -import javax.ws.rs.core.GenericType; +import .ws.rs.core.GenericType; import java.util.ArrayList; @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class UsageApi { private ApiClient apiClient; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java index f7ae20160d33..cff48865c78e 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java index 2bae057b7c42..7c2a64e028b0 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBearerAuth implements Authentication { private final String scheme; private String bearerToken; diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java index 2bbea7b750cf..16286fc92569 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -6,7 +6,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.Pair; -import javax.ws.rs.core.GenericType; +import .ws.rs.core.GenericType; import org.openapitools.client.model.MySchemaNameCharacters; @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultApi { private ApiClient apiClient; diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java index a39f12c00b14..dd755fc7ae28 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java @@ -29,6 +29,9 @@ 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 org.openapitools.client.model.ChildSchemaAllOf; import org.openapitools.client.model.Parent; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -40,7 +43,7 @@ @JsonPropertyOrder({ ChildSchema.JSON_PROPERTY_PROP1 }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @JsonIgnoreProperties( value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization allowSetters = true // allows the objectType to be set during deserialization @@ -63,7 +66,7 @@ public ChildSchema prop1(String prop1) { * Get prop1 * @return prop1 **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP1) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java index d6851fb740b9..f7662204b798 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java @@ -22,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -33,7 +35,7 @@ ChildSchemaAllOf.JSON_PROPERTY_PROP1 }) @JsonTypeName("ChildSchema_allOf") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ChildSchemaAllOf { public static final String JSON_PROPERTY_PROP1 = "prop1"; private String prop1; @@ -50,7 +52,7 @@ public ChildSchemaAllOf prop1(String prop1) { * Get prop1 * @return prop1 **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP1) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java index fd536702c9c1..6f11ccf0bda9 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java @@ -29,6 +29,9 @@ 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 org.openapitools.client.model.MySchemaNameCharactersAllOf; import org.openapitools.client.model.Parent; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -41,7 +44,7 @@ MySchemaNameCharacters.JSON_PROPERTY_PROP2 }) @JsonTypeName("MySchemaName._-Characters") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @JsonIgnoreProperties( value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization allowSetters = true // allows the objectType to be set during deserialization @@ -64,7 +67,7 @@ public MySchemaNameCharacters prop2(String prop2) { * Get prop2 * @return prop2 **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP2) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java index 78aeee21aef7..ab36fc1fb113 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java @@ -22,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -33,7 +35,7 @@ MySchemaNameCharactersAllOf.JSON_PROPERTY_PROP2 }) @JsonTypeName("MySchemaName___Characters_allOf") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class MySchemaNameCharactersAllOf { public static final String JSON_PROPERTY_PROP2 = "prop2"; private String prop2; @@ -50,7 +52,7 @@ public MySchemaNameCharactersAllOf prop2(String prop2) { * Get prop2 * @return prop2 **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP2) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java index ebef79d5e941..1f7316701db3 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java @@ -25,6 +25,8 @@ 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 org.openapitools.client.model.ChildSchema; import org.openapitools.client.model.MySchemaNameCharacters; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -37,7 +39,7 @@ @JsonPropertyOrder({ Parent.JSON_PROPERTY_OBJECT_TYPE }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @JsonIgnoreProperties( value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization allowSetters = true // allows the objectType to be set during deserialization @@ -64,7 +66,7 @@ public Parent objectType(String objectType) { * Get objectType * @return objectType **/ - @javax.annotation.Nullable + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_OBJECT_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java index 308f13bc2634..3bec69c1a0de 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java @@ -31,12 +31,11 @@ /** * A category for a pet */ -@ApiModel(description = "A category for a pet") @JsonPropertyOrder({ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -56,8 +55,7 @@ public Category id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -82,8 +80,7 @@ public Category name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 656070057d26..a1821dbb385c 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -31,14 +31,13 @@ /** * Describes the result of uploading an image resource */ -@ApiModel(description = "Describes the result of uploading an image resource") @JsonPropertyOrder({ ModelApiResponse.JSON_PROPERTY_CODE, ModelApiResponse.JSON_PROPERTY_TYPE, ModelApiResponse.JSON_PROPERTY_MESSAGE }) @JsonTypeName("ApiResponse") -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String JSON_PROPERTY_CODE = "code"; private Integer code; @@ -61,8 +60,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -87,8 +85,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -113,8 +110,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java index 89791081a096..43f544ac26fc 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java @@ -32,7 +32,6 @@ /** * An order for a pets from the pet store */ -@ApiModel(description = "An order for a pets from the pet store") @JsonPropertyOrder({ Order.JSON_PROPERTY_ID, Order.JSON_PROPERTY_PET_ID, @@ -41,7 +40,7 @@ Order.JSON_PROPERTY_STATUS, Order.JSON_PROPERTY_COMPLETE }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -110,8 +109,7 @@ public Order id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,8 +134,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -162,8 +159,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -188,8 +184,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -214,8 +209,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Order Status") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -240,8 +234,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java index 866bfced4c7d..bed39bc9648c 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java @@ -35,7 +35,6 @@ /** * A pet for sale in the pet store */ -@ApiModel(description = "A pet for sale in the pet store") @JsonPropertyOrder({ Pet.JSON_PROPERTY_ID, Pet.JSON_PROPERTY_CATEGORY, @@ -44,7 +43,7 @@ Pet.JSON_PROPERTY_TAGS, Pet.JSON_PROPERTY_STATUS }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -113,8 +112,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -139,8 +137,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -165,8 +162,7 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull - @ApiModelProperty(example = "doggie", required = true, value = "") + @.annotation.Nonnull @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -196,8 +192,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = "") + @.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -230,8 +225,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -258,8 +252,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @javax.annotation.Nullable - @ApiModelProperty(value = "pet status in the store") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java index 3852416d80b4..7da7da3fd40e 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java @@ -31,12 +31,11 @@ /** * A tag for a pet */ -@ApiModel(description = "A tag for a pet") @JsonPropertyOrder({ Tag.JSON_PROPERTY_ID, Tag.JSON_PROPERTY_NAME }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -56,8 +55,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -82,8 +80,7 @@ public Tag name(String name) { * Get name * @return name **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java index e354d4dbda6a..98d8a5272d1a 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java @@ -31,7 +31,6 @@ /** * A User who is purchasing from the pet store */ -@ApiModel(description = "A User who is purchasing from the pet store") @JsonPropertyOrder({ User.JSON_PROPERTY_ID, User.JSON_PROPERTY_USERNAME, @@ -42,7 +41,7 @@ User.JSON_PROPERTY_PHONE, User.JSON_PROPERTY_USER_STATUS }) -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class User { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -80,8 +79,7 @@ public User id(Long id) { * Get id * @return id **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -106,8 +104,7 @@ public User username(String username) { * Get username * @return username **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -132,8 +129,7 @@ public User firstName(String firstName) { * Get firstName * @return firstName **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -158,8 +154,7 @@ public User lastName(String lastName) { * Get lastName * @return lastName **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -184,8 +179,7 @@ public User email(String email) { * Get email * @return email **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -210,8 +204,7 @@ public User password(String password) { * Get password * @return password **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -236,8 +229,7 @@ public User phone(String phone) { * Get phone * @return phone **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -262,8 +254,7 @@ public User userStatus(Integer userStatus) { * User Status * @return userStatus **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "User Status") + @.annotation.Nullable @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..9bf61a0df0f9 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("ByRefOrValue") + .description("This tests for a oneOf interface representation ") + .license("") + .licenseUrl("http://unlicense.org") + .termsOfServiceUrl("") + .version("0.0.1") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.byRefOrValue.base-path:}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..1fc96305a3e7 --- /dev/null +++ b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..1fc96305a3e7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..1ebe51cb901d --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,17 @@ +package org.openapitools; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java new file mode 100644 index 000000000000..8f936b311447 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java @@ -0,0 +1,232 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; +import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; +import com.fasterxml.jackson.datatype.threetenbp.function.Function; +import org.threeten.bp.DateTimeException; +import org.threeten.bp.DateTimeUtils; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZoneId; +import org.threeten.bp.ZonedDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.temporal.Temporal; +import org.threeten.bp.temporal.TemporalAccessor; + +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. + * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. + * + * @author Nick Williams + */ +public class CustomInstantDeserializer + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(this, dtf); + } + + @Override + public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { + //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only + //string values have to be adjusted to the configured TZ. + switch (parser.getCurrentTokenId()) { + case JsonTokenId.ID_NUMBER_FLOAT: { + BigDecimal value = parser.getDecimalValue(); + long seconds = value.longValue(); + int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); + return fromNanoseconds.apply(new FromDecimalArguments( + seconds, nanoseconds, getZone(context))); + } + + case JsonTokenId.ID_NUMBER_INT: { + long timestamp = parser.getLongValue(); + if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + return this.fromNanoseconds.apply(new FromDecimalArguments( + timestamp, 0, this.getZone(context) + )); + } + return this.fromMilliseconds.apply(new FromIntegerArguments( + timestamp, this.getZone(context) + )); + } + + case JsonTokenId.ID_STRING: { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + if (string.endsWith("+0000")) { + string = string.substring(0, string.length() - 5) + "Z"; + } + T value; + try { + TemporalAccessor acc = _formatter.parse(string); + value = parsedToValue.apply(acc); + if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { + return adjust.apply(value, this.getZone(context)); + } + } catch (DateTimeException e) { + throw _peelDTE(e); + } + return value; + } + } + throw context.mappingException("Expected type float, integer, or string."); + } + + private ZoneId getZone(DeserializationContext context) { + // Instants are always in UTC, so don't waste compute cycles + return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); + } + + private static class FromIntegerArguments { + public final long value; + public final ZoneId zoneId; + + private FromIntegerArguments(long value, ZoneId zoneId) { + this.value = value; + this.zoneId = zoneId; + } + } + + private static class FromDecimalArguments { + public final long integer; + public final int fraction; + public final ZoneId zoneId; + + private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { + this.integer = integer; + this.fraction = fraction; + this.zoneId = zoneId; + } + } +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java new file mode 100644 index 000000000000..b481a87518f4 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java @@ -0,0 +1,23 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZonedDateTime; + +@Configuration +public class JacksonConfiguration { + + @Bean + @ConditionalOnMissingBean(ThreeTenModule.class) + ThreeTenModule threeTenModule() { + ThreeTenModule module = new ThreeTenModule(); + module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); + module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); + module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); + return module; + } +} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..1fc96305a3e7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..77674f29d63f --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,73 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.Optional; +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .genericModelSubstitutes(Optional.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..1fc96305a3e7 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java index 72502d0f0e26..d74962ea1914 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java @@ -48,7 +48,7 @@ public Category id(Long id) { * @return id */ - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) public Long getId() { return id; } @@ -67,7 +67,7 @@ public Category name(String name) { * @return name */ @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") - @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "name", required = false) public String getName() { return name; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java index d7fd8f87d926..8a01264cac07 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -54,7 +54,7 @@ public ModelApiResponse code(Integer code) { * @return code */ - @Schema(name = "code", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "code", required = false) public Integer getCode() { return code; } @@ -73,7 +73,7 @@ public ModelApiResponse type(String type) { * @return type */ - @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "type", required = false) public String getType() { return type; } @@ -92,7 +92,7 @@ public ModelApiResponse message(String message) { * @return message */ - @Schema(name = "message", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "message", required = false) public String getMessage() { return message; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java index a2507752ed07..d57417899844 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java @@ -105,7 +105,7 @@ public Order id(Long id) { * @return id */ - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) public Long getId() { return id; } @@ -124,7 +124,7 @@ public Order petId(Long petId) { * @return petId */ - @Schema(name = "petId", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "petId", required = false) public Long getPetId() { return petId; } @@ -143,7 +143,7 @@ public Order quantity(Integer quantity) { * @return quantity */ - @Schema(name = "quantity", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "quantity", required = false) public Integer getQuantity() { return quantity; } @@ -162,7 +162,7 @@ public Order shipDate(Date shipDate) { * @return shipDate */ @Valid - @Schema(name = "shipDate", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "shipDate", required = false) public Date getShipDate() { return shipDate; } @@ -181,7 +181,7 @@ public Order status(StatusEnum status) { * @return status */ - @Schema(name = "status", description = "Order Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "status", description = "Order Status", required = false) public StatusEnum getStatus() { return status; } @@ -200,7 +200,7 @@ public Order complete(Boolean complete) { * @return complete */ - @Schema(name = "complete", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "complete", required = false) public Boolean getComplete() { return complete; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java index 280811e85670..43f830ce2952 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java @@ -108,7 +108,7 @@ public Pet id(Long id) { * @return id */ - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) public Long getId() { return id; } @@ -127,7 +127,7 @@ public Pet category(Category category) { * @return category */ @Valid - @Schema(name = "category", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "category", required = false) public Category getCategory() { return category; } @@ -146,7 +146,7 @@ public Pet name(String name) { * @return name */ @NotNull - @Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(name = "name", example = "doggie", required = true) public String getName() { return name; } @@ -170,7 +170,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * @return photoUrls */ @NotNull - @Schema(name = "photoUrls", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(name = "photoUrls", required = true) public List getPhotoUrls() { return photoUrls; } @@ -197,7 +197,7 @@ public Pet addTagsItem(Tag tagsItem) { * @return tags */ @Valid - @Schema(name = "tags", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "tags", required = false) public List getTags() { return tags; } @@ -216,7 +216,7 @@ public Pet status(StatusEnum status) { * @return status */ - @Schema(name = "status", description = "pet status in the store", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "status", description = "pet status in the store", required = false) public StatusEnum getStatus() { return status; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java index e841695b5e09..84a8c85754e5 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java @@ -48,7 +48,7 @@ public Tag id(Long id) { * @return id */ - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) public Long getId() { return id; } @@ -67,7 +67,7 @@ public Tag name(String name) { * @return name */ - @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "name", required = false) public String getName() { return name; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java index 5a2a1168ea85..b7f1e01576b0 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java @@ -72,7 +72,7 @@ public User id(Long id) { * @return id */ - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) public Long getId() { return id; } @@ -91,7 +91,7 @@ public User username(String username) { * @return username */ - @Schema(name = "username", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "username", required = false) public String getUsername() { return username; } @@ -110,7 +110,7 @@ public User firstName(String firstName) { * @return firstName */ - @Schema(name = "firstName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "firstName", required = false) public String getFirstName() { return firstName; } @@ -129,7 +129,7 @@ public User lastName(String lastName) { * @return lastName */ - @Schema(name = "lastName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "lastName", required = false) public String getLastName() { return lastName; } @@ -148,7 +148,7 @@ public User email(String email) { * @return email */ - @Schema(name = "email", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "email", required = false) public String getEmail() { return email; } @@ -167,7 +167,7 @@ public User password(String password) { * @return password */ - @Schema(name = "password", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "password", required = false) public String getPassword() { return password; } @@ -186,7 +186,7 @@ public User phone(String phone) { * @return phone */ - @Schema(name = "phone", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "phone", required = false) public String getPhone() { return phone; } @@ -205,7 +205,7 @@ public User userStatus(Integer userStatus) { * @return userStatus */ - @Schema(name = "userStatus", description = "User Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "userStatus", description = "User Status", required = false) public Integer getUserStatus() { return userStatus; } diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java index 1de389611a7e..9bfa4b7c9b4e 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java @@ -53,7 +53,7 @@ public Category id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -77,7 +77,7 @@ public Category name(String name) { **/ @Nullable @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") - @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "name", required = false) @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java index 91ecfafb30ee..fe1b67499eb1 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -58,7 +58,7 @@ public ModelApiResponse code(Integer code) { * @return code **/ @Nullable - @Schema(name = "code", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "code", required = false) @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getCode() { @@ -81,7 +81,7 @@ public ModelApiResponse type(String type) { * @return type **/ @Nullable - @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "type", required = false) @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getType() { @@ -104,7 +104,7 @@ public ModelApiResponse message(String message) { * @return message **/ @Nullable - @Schema(name = "message", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "message", required = false) @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getMessage() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java index f759446ae7c4..7594d35deeaa 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java @@ -104,7 +104,7 @@ public Order id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -127,7 +127,7 @@ public Order petId(Long petId) { * @return petId **/ @Nullable - @Schema(name = "petId", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "petId", required = false) @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getPetId() { @@ -150,7 +150,7 @@ public Order quantity(Integer quantity) { * @return quantity **/ @Nullable - @Schema(name = "quantity", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "quantity", required = false) @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getQuantity() { @@ -173,7 +173,7 @@ public Order shipDate(OffsetDateTime shipDate) { * @return shipDate **/ @Nullable - @Schema(name = "shipDate", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "shipDate", required = false) @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXX") @@ -198,7 +198,7 @@ public Order status(StatusEnum status) { * @return status **/ @Nullable - @Schema(name = "status", description = "Order Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "status", description = "Order Status", required = false) @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { @@ -221,7 +221,7 @@ public Order complete(Boolean complete) { * @return complete **/ @Nullable - @Schema(name = "complete", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "complete", required = false) @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Boolean getComplete() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java index 1ce739e5bec2..1a4b66d3350d 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java @@ -109,7 +109,7 @@ public Pet id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -133,7 +133,7 @@ public Pet category(Category category) { **/ @Valid @Nullable - @Schema(name = "category", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "category", required = false) @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Category getCategory() { @@ -156,7 +156,7 @@ public Pet name(String name) { * @return name **/ @NotNull - @Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(name = "name", example = "doggie", required = true) @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getName() { @@ -184,7 +184,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * @return photoUrls **/ @NotNull - @Schema(name = "photoUrls", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(name = "photoUrls", required = true) @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public List getPhotoUrls() { @@ -215,7 +215,7 @@ public Pet addTagsItem(Tag tagsItem) { * @return tags **/ @Nullable - @Schema(name = "tags", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "tags", required = false) @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getTags() { @@ -238,7 +238,7 @@ public Pet status(StatusEnum status) { * @return status **/ @Nullable - @Schema(name = "status", description = "pet status in the store", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "status", description = "pet status in the store", required = false) @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java index fe4dd0f4676a..b94c645596ec 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java @@ -53,7 +53,7 @@ public Tag id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -76,7 +76,7 @@ public Tag name(String name) { * @return name **/ @Nullable - @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "name", required = false) @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java index e1e76dd010fa..17cf05d120b7 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java @@ -77,7 +77,7 @@ public User id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "id", required = false) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -100,7 +100,7 @@ public User username(String username) { * @return username **/ @Nullable - @Schema(name = "username", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "username", required = false) @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getUsername() { @@ -123,7 +123,7 @@ public User firstName(String firstName) { * @return firstName **/ @Nullable - @Schema(name = "firstName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "firstName", required = false) @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getFirstName() { @@ -146,7 +146,7 @@ public User lastName(String lastName) { * @return lastName **/ @Nullable - @Schema(name = "lastName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "lastName", required = false) @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getLastName() { @@ -169,7 +169,7 @@ public User email(String email) { * @return email **/ @Nullable - @Schema(name = "email", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "email", required = false) @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getEmail() { @@ -192,7 +192,7 @@ public User password(String password) { * @return password **/ @Nullable - @Schema(name = "password", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "password", required = false) @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPassword() { @@ -215,7 +215,7 @@ public User phone(String phone) { * @return phone **/ @Nullable - @Schema(name = "phone", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "phone", required = false) @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPhone() { @@ -238,7 +238,7 @@ public User userStatus(Integer userStatus) { * @return userStatus **/ @Nullable - @Schema(name = "userStatus", description = "User Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "userStatus", description = "User Status", required = false) @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getUserStatus() { diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..1ebe51cb901d --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,17 @@ +package org.openapitools; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java new file mode 100644 index 000000000000..8f936b311447 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java @@ -0,0 +1,232 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; +import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; +import com.fasterxml.jackson.datatype.threetenbp.function.Function; +import org.threeten.bp.DateTimeException; +import org.threeten.bp.DateTimeUtils; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZoneId; +import org.threeten.bp.ZonedDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.temporal.Temporal; +import org.threeten.bp.temporal.TemporalAccessor; + +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. + * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. + * + * @author Nick Williams + */ +public class CustomInstantDeserializer + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(this, dtf); + } + + @Override + public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { + //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only + //string values have to be adjusted to the configured TZ. + switch (parser.getCurrentTokenId()) { + case JsonTokenId.ID_NUMBER_FLOAT: { + BigDecimal value = parser.getDecimalValue(); + long seconds = value.longValue(); + int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); + return fromNanoseconds.apply(new FromDecimalArguments( + seconds, nanoseconds, getZone(context))); + } + + case JsonTokenId.ID_NUMBER_INT: { + long timestamp = parser.getLongValue(); + if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + return this.fromNanoseconds.apply(new FromDecimalArguments( + timestamp, 0, this.getZone(context) + )); + } + return this.fromMilliseconds.apply(new FromIntegerArguments( + timestamp, this.getZone(context) + )); + } + + case JsonTokenId.ID_STRING: { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + if (string.endsWith("+0000")) { + string = string.substring(0, string.length() - 5) + "Z"; + } + T value; + try { + TemporalAccessor acc = _formatter.parse(string); + value = parsedToValue.apply(acc); + if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { + return adjust.apply(value, this.getZone(context)); + } + } catch (DateTimeException e) { + throw _peelDTE(e); + } + return value; + } + } + throw context.mappingException("Expected type float, integer, or string."); + } + + private ZoneId getZone(DeserializationContext context) { + // Instants are always in UTC, so don't waste compute cycles + return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); + } + + private static class FromIntegerArguments { + public final long value; + public final ZoneId zoneId; + + private FromIntegerArguments(long value, ZoneId zoneId) { + this.value = value; + this.zoneId = zoneId; + } + } + + private static class FromDecimalArguments { + public final long integer; + public final int fraction; + public final ZoneId zoneId; + + private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { + this.integer = integer; + this.fraction = fraction; + this.zoneId = zoneId; + } + } +} diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java new file mode 100644 index 000000000000..b481a87518f4 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java @@ -0,0 +1,23 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZonedDateTime; + +@Configuration +public class JacksonConfiguration { + + @Bean + @ConditionalOnMissingBean(ThreeTenModule.class) + ThreeTenModule threeTenModule() { + ThreeTenModule module = new ThreeTenModule(); + module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); + module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); + module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); + return module; + } +} diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java new file mode 100644 index 000000000000..8f936b311447 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java @@ -0,0 +1,232 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; +import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; +import com.fasterxml.jackson.datatype.threetenbp.function.Function; +import org.threeten.bp.DateTimeException; +import org.threeten.bp.DateTimeUtils; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZoneId; +import org.threeten.bp.ZonedDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.temporal.Temporal; +import org.threeten.bp.temporal.TemporalAccessor; + +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. + * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. + * + * @author Nick Williams + */ +public class CustomInstantDeserializer + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(this, dtf); + } + + @Override + public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { + //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only + //string values have to be adjusted to the configured TZ. + switch (parser.getCurrentTokenId()) { + case JsonTokenId.ID_NUMBER_FLOAT: { + BigDecimal value = parser.getDecimalValue(); + long seconds = value.longValue(); + int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); + return fromNanoseconds.apply(new FromDecimalArguments( + seconds, nanoseconds, getZone(context))); + } + + case JsonTokenId.ID_NUMBER_INT: { + long timestamp = parser.getLongValue(); + if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + return this.fromNanoseconds.apply(new FromDecimalArguments( + timestamp, 0, this.getZone(context) + )); + } + return this.fromMilliseconds.apply(new FromIntegerArguments( + timestamp, this.getZone(context) + )); + } + + case JsonTokenId.ID_STRING: { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + if (string.endsWith("+0000")) { + string = string.substring(0, string.length() - 5) + "Z"; + } + T value; + try { + TemporalAccessor acc = _formatter.parse(string); + value = parsedToValue.apply(acc); + if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { + return adjust.apply(value, this.getZone(context)); + } + } catch (DateTimeException e) { + throw _peelDTE(e); + } + return value; + } + } + throw context.mappingException("Expected type float, integer, or string."); + } + + private ZoneId getZone(DeserializationContext context) { + // Instants are always in UTC, so don't waste compute cycles + return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); + } + + private static class FromIntegerArguments { + public final long value; + public final ZoneId zoneId; + + private FromIntegerArguments(long value, ZoneId zoneId) { + this.value = value; + this.zoneId = zoneId; + } + } + + private static class FromDecimalArguments { + public final long integer; + public final int fraction; + public final ZoneId zoneId; + + private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { + this.integer = integer; + this.fraction = fraction; + this.zoneId = zoneId; + } + } +} diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java new file mode 100644 index 000000000000..b481a87518f4 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java @@ -0,0 +1,23 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZonedDateTime; + +@Configuration +public class JacksonConfiguration { + + @Bean + @ConditionalOnMissingBean(ThreeTenModule.class) + ThreeTenModule threeTenModule() { + ThreeTenModule module = new ThreeTenModule(); + module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); + module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); + module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); + return module; + } +} diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..ae31b200b2d6 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..ae31b200b2d6 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java new file mode 100644 index 000000000000..8f936b311447 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java @@ -0,0 +1,232 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; +import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; +import com.fasterxml.jackson.datatype.threetenbp.function.Function; +import org.threeten.bp.DateTimeException; +import org.threeten.bp.DateTimeUtils; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZoneId; +import org.threeten.bp.ZonedDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.temporal.Temporal; +import org.threeten.bp.temporal.TemporalAccessor; + +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. + * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. + * + * @author Nick Williams + */ +public class CustomInstantDeserializer + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(this, dtf); + } + + @Override + public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { + //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only + //string values have to be adjusted to the configured TZ. + switch (parser.getCurrentTokenId()) { + case JsonTokenId.ID_NUMBER_FLOAT: { + BigDecimal value = parser.getDecimalValue(); + long seconds = value.longValue(); + int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); + return fromNanoseconds.apply(new FromDecimalArguments( + seconds, nanoseconds, getZone(context))); + } + + case JsonTokenId.ID_NUMBER_INT: { + long timestamp = parser.getLongValue(); + if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + return this.fromNanoseconds.apply(new FromDecimalArguments( + timestamp, 0, this.getZone(context) + )); + } + return this.fromMilliseconds.apply(new FromIntegerArguments( + timestamp, this.getZone(context) + )); + } + + case JsonTokenId.ID_STRING: { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + if (string.endsWith("+0000")) { + string = string.substring(0, string.length() - 5) + "Z"; + } + T value; + try { + TemporalAccessor acc = _formatter.parse(string); + value = parsedToValue.apply(acc); + if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { + return adjust.apply(value, this.getZone(context)); + } + } catch (DateTimeException e) { + throw _peelDTE(e); + } + return value; + } + } + throw context.mappingException("Expected type float, integer, or string."); + } + + private ZoneId getZone(DeserializationContext context) { + // Instants are always in UTC, so don't waste compute cycles + return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); + } + + private static class FromIntegerArguments { + public final long value; + public final ZoneId zoneId; + + private FromIntegerArguments(long value, ZoneId zoneId) { + this.value = value; + this.zoneId = zoneId; + } + } + + private static class FromDecimalArguments { + public final long integer; + public final int fraction; + public final ZoneId zoneId; + + private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { + this.integer = integer; + this.fraction = fraction; + this.zoneId = zoneId; + } + } +} diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java new file mode 100644 index 000000000000..b481a87518f4 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java @@ -0,0 +1,23 @@ +package org.openapitools.configuration; + +import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZonedDateTime; + +@Configuration +public class JacksonConfiguration { + + @Bean + @ConditionalOnMissingBean(ThreeTenModule.class) + ThreeTenModule threeTenModule() { + ThreeTenModule module = new ThreeTenModule(); + module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); + module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); + module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); + return module; + } +} diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..ae31b200b2d6 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..ae31b200b2d6 --- /dev/null +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..77674f29d63f --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,73 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.Optional; +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .genericModelSubstitutes(Optional.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..2610b90e6393 --- /dev/null +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.virtualan.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..7fd7bc22fdaa --- /dev/null +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.virtualan.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java new file mode 100644 index 000000000000..f62fd6d91797 --- /dev/null +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java @@ -0,0 +1,23 @@ +package org.openapitools; + +import com.fasterxml.jackson.databind.Module; +import org.openapitools.jackson.nullable.JsonNullableModule; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) +public class OpenApiGeneratorApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiGeneratorApplication.class, args); + } + + @Bean + public Module jsonNullableModule() { + return new JsonNullableModule(); + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java new file mode 100644 index 000000000000..e05217a98f21 --- /dev/null +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java @@ -0,0 +1,71 @@ +package org.openapitools.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.web.util.UriComponentsBuilder; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.Paths; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.annotation.Generated; +import javax.servlet.ServletContext; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +@Configuration +@EnableSwagger2 +public class SpringFoxConfiguration { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OpenAPI Petstore") + .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") + .license("Apache-2.0") + .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") + .termsOfServiceUrl("") + .version("1.0.0") + .contact(new Contact("","", "")) + .build(); + } + + @Bean + public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) + .build() + .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + + class BasePathAwareRelativePathProvider extends RelativePathProvider { + private String basePath; + + public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { + super(servletContext); + this.basePath = basePath; + } + + @Override + protected String applicationPath() { + return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); + } + + @Override + public String getOperationPath(String operationPath) { + UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); + return Paths.removeAdjacentForwardSlashes( + uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); + } + } + +} From 6b22e31b61f3b2a13e4d2144e8ce34b366cfa313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Rodr=C3=ADguez=20Mart=C3=ADn?= Date: Fri, 17 Feb 2023 14:55:34 +0100 Subject: [PATCH 3/5] Update samples --- .../java/apache-httpclient/docs/DataQuery.md | 12 - .../org/openapitools/client/model/Bird.java | 66 +++++- .../openapitools/client/model/Category.java | 66 +++++- .../openapitools/client/model/DataQuery.java | 221 ++++++++---------- .../client/model/DataQueryAllOf.java | 78 ++++++- .../client/model/DefaultValue.java | 168 +++++++++++-- .../org/openapitools/client/model/Pet.java | 113 ++++++++- .../org/openapitools/client/model/Bird.java | 39 ++-- .../openapitools/client/model/Category.java | 39 ++-- .../openapitools/client/model/DataQuery.java | 166 ++----------- .../client/model/DataQueryAllOf.java | 50 ++-- .../client/model/DefaultValue.java | 171 +++++--------- .../org/openapitools/client/model/Pet.java | 95 ++++---- .../echo_api/java/native/docs/DataQuery.md | 12 - .../org/openapitools/client/model/Bird.java | 56 ++++- .../openapitools/client/model/Category.java | 56 ++++- .../openapitools/client/model/DataQuery.java | 193 ++++++--------- .../client/model/DataQueryAllOf.java | 63 ++++- .../client/model/DefaultValue.java | 125 ++++++++-- .../java/okhttp-gson/docs/DataQuery.md | 12 - .../org/openapitools/client/model/Bird.java | 8 +- .../openapitools/client/model/Category.java | 8 +- .../openapitools/client/model/DataQuery.java | 134 +---------- .../client/model/DataQueryAllOf.java | 10 +- .../client/model/DefaultValue.java | 39 ++-- .../org/openapitools/client/model/Pet.java | 16 +- .../org/openapitools/client/StringUtil.java | 2 +- .../org/openapitools/client/api/PingApi.java | 2 +- .../openapitools/client/auth/ApiKeyAuth.java | 2 +- .../client/auth/HttpBearerAuth.java | 2 +- .../openapitools/client/model/SomeObj.java | 14 +- .../org/openapitools/client/model/Order.java | 20 ++ .../org/openapitools/client/model/Pet.java | 20 ++ .../org/openapitools/client/model/Order.java | 20 ++ .../org/openapitools/client/model/Pet.java | 20 ++ .../openapitools/client/model/Category.java | 56 ++++- .../client/model/ModelApiResponse.java | 63 ++++- .../org/openapitools/client/model/Order.java | 84 ++++++- .../org/openapitools/client/model/Pet.java | 93 +++++++- .../org/openapitools/client/model/Tag.java | 56 ++++- .../openapitools/client/model/Category.java | 8 +- .../client/model/ModelApiResponse.java | 10 +- .../org/openapitools/client/model/Order.java | 16 +- .../org/openapitools/client/model/Pet.java | 16 +- .../org/openapitools/client/model/Tag.java | 8 +- .../org/openapitools/client/model/User.java | 20 +- .../openapitools/client/model/Category.java | 8 +- .../client/model/ModelApiResponse.java | 10 +- .../org/openapitools/client/model/Order.java | 16 +- .../org/openapitools/client/model/Pet.java | 16 +- .../org/openapitools/client/model/Tag.java | 8 +- .../openapitools/client/model/Category.java | 9 +- .../client/model/ModelApiResponse.java | 12 +- .../org/openapitools/client/model/Order.java | 21 +- .../org/openapitools/client/model/Pet.java | 21 +- .../org/openapitools/client/model/Tag.java | 9 +- .../org/openapitools/client/model/User.java | 27 ++- .../org/openapitools/client/ApiClient.java | 34 +-- .../client/JavaTimeFormatter.java | 2 +- .../org/openapitools/client/StringUtil.java | 2 +- .../org/openapitools/client/api/UsageApi.java | 4 +- .../client/auth/HttpBasicAuth.java | 2 +- .../client/auth/HttpBearerAuth.java | 2 +- .../openapitools/client/api/DefaultApi.java | 4 +- .../client/model/ChildSchema.java | 7 +- .../client/model/ChildSchemaAllOf.java | 6 +- .../client/model/MySchemaNameCharacters.java | 7 +- .../model/MySchemaNameCharactersAllOf.java | 6 +- .../org/openapitools/client/model/Parent.java | 6 +- .../openapitools/client/model/Category.java | 9 +- .../client/model/ModelApiResponse.java | 12 +- .../org/openapitools/client/model/Order.java | 21 +- .../org/openapitools/client/model/Pet.java | 21 +- .../org/openapitools/client/model/Tag.java | 9 +- .../org/openapitools/client/model/User.java | 27 ++- .../java/org/openapitools/model/Category.java | 4 +- .../openapitools/model/ModelApiResponse.java | 6 +- .../java/org/openapitools/model/Order.java | 12 +- .../main/java/org/openapitools/model/Pet.java | 12 +- .../main/java/org/openapitools/model/Tag.java | 4 +- .../java/org/openapitools/model/User.java | 16 +- .../java/org/openapitools/model/Category.java | 4 +- .../openapitools/model/ModelApiResponse.java | 6 +- .../java/org/openapitools/model/Order.java | 12 +- .../main/java/org/openapitools/model/Pet.java | 12 +- .../main/java/org/openapitools/model/Tag.java | 4 +- .../java/org/openapitools/model/User.java | 16 +- 87 files changed, 1788 insertions(+), 1206 deletions(-) diff --git a/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md b/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md index 5beb983af973..338c467b2d56 100644 --- a/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md +++ b/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md @@ -10,18 +10,6 @@ |**suffix** | **String** | test suffix | [optional] | |**text** | **String** | Some text containing white spaces | [optional] | |**date** | **OffsetDateTime** | A date | [optional] | -|**id** | **Long** | Query | [optional] | -|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | - - - -## Enum: List<OutcomesEnum> - -| Name | Value | -|---- | -----| -| SUCCESS | "SUCCESS" | -| FAILURE | "FAILURE" | -| SKIPPED | "SKIPPED" | diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java index c04e23293647..a42433b9d5cd 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java @@ -20,10 +20,11 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; /** * Bird @@ -32,7 +33,7 @@ Bird.JSON_PROPERTY_SIZE, Bird.JSON_PROPERTY_COLOR }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { public static final String JSON_PROPERTY_SIZE = "size"; private String size; @@ -53,7 +54,7 @@ public Bird size(String size) { * Get size * @return size **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_SIZE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -79,7 +80,7 @@ public Bird color(String color) { * Get color * @return color **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_COLOR) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -134,5 +135,60 @@ private String toIndentedString(Object o) { 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 `size` to the URL query string + if (getSize() != null) { + try { + joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `color` to the URL query string + if (getColor() != null) { + try { + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java index e278b76dfad6..9d205aa629e4 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java @@ -20,10 +20,11 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; /** * Category @@ -32,7 +33,7 @@ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -53,7 +54,7 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -79,7 +80,7 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -134,5 +135,60 @@ private String toIndentedString(Object o) { 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 `id` to the URL query string + if (getId() != null) { + try { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `name` to the URL query string + if (getName() != null) { + try { + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java index c8eedf63c08c..482cc9c32464 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java @@ -20,15 +20,15 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; -import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; /** * DataQuery @@ -36,12 +36,10 @@ @JsonPropertyOrder({ DataQuery.JSON_PROPERTY_SUFFIX, DataQuery.JSON_PROPERTY_TEXT, - DataQuery.JSON_PROPERTY_DATE, - DataQuery.JSON_PROPERTY_ID, - DataQuery.JSON_PROPERTY_OUTCOMES + DataQuery.JSON_PROPERTY_DATE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -51,50 +49,8 @@ public class DataQuery { public static final String JSON_PROPERTY_DATE = "date"; private OffsetDateTime date; - public static final String JSON_PROPERTY_ID = "id"; - private Long id; - - /** - * Gets or Sets outcomes - */ - public enum OutcomesEnum { - SUCCESS("SUCCESS"), - - FAILURE("FAILURE"), - - SKIPPED("SKIPPED"); - - private String value; - - OutcomesEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static OutcomesEnum fromValue(String value) { - for (OutcomesEnum b : OutcomesEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - } - - public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; - private List outcomes = new ArrayList<>(); - public DataQuery() { + } public DataQuery suffix(String suffix) { @@ -107,7 +63,7 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -133,7 +89,7 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -159,7 +115,7 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -175,66 +131,6 @@ public void setDate(OffsetDateTime date) { } - public DataQuery id(Long id) { - - this.id = id; - return this; - } - - /** - * Query - * @return id - **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public Long getId() { - return id; - } - - - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setId(Long id) { - this.id = id; - } - - - public DataQuery outcomes(List outcomes) { - - this.outcomes = outcomes; - return this; - } - - public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { - if (this.outcomes == null) { - this.outcomes = new ArrayList<>(); - } - this.outcomes.add(outcomesItem); - return this; - } - - /** - * Get outcomes - * @return outcomes - **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_OUTCOMES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public List getOutcomes() { - return outcomes; - } - - - @JsonProperty(JSON_PROPERTY_OUTCOMES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setOutcomes(List outcomes) { - this.outcomes = outcomes; - } - - @Override public boolean equals(Object o) { if (this == o) { @@ -247,24 +143,22 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - Objects.equals(this.id, dataQuery.id) && - Objects.equals(this.outcomes, dataQuery.outcomes); + super.equals(o); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, id, outcomes); + return Objects.hash(suffix, text, date, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } @@ -280,5 +174,94 @@ private String toIndentedString(Object o) { 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 `suffix` to the URL query string + if (getSuffix() != null) { + try { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `text` to the URL query string + if (getText() != null) { + try { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `date` to the URL query string + if (getDate() != null) { + try { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `id` to the URL query string + if (getId() != null) { + try { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `outcomes` to the URL query string + if (getOutcomes() != null) { + for (int i = 0; i < getOutcomes().size(); i++) { + try { + joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getOutcomes().get(i)), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 15d00cff792a..971198bc3559 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -20,11 +20,12 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; /** * DataQueryAllOf @@ -35,7 +36,7 @@ DataQueryAllOf.JSON_PROPERTY_DATE }) @JsonTypeName("DataQuery_allOf") -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -59,7 +60,7 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -85,7 +86,7 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -111,7 +112,7 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -168,5 +169,70 @@ private String toIndentedString(Object o) { 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 `suffix` to the URL query string + if (getSuffix() != null) { + try { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `text` to the URL query string + if (getText() != null) { + try { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `date` to the URL query string + if (getDate() != null) { + try { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "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/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java index 9d7f2fe5617d..859afd7a9816 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -20,8 +20,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.StringEnumRef; @@ -31,6 +29,9 @@ import java.util.NoSuchElementException; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; /** * to test the default value of properties @@ -44,10 +45,10 @@ DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE, DefaultValue.JSON_PROPERTY_STRING_NULLABLE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; - private List arrayStringEnumRefDefault = new ArrayList<>(); + private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); /** * Gets or Sets arrayStringEnumDefault @@ -87,13 +88,13 @@ public static ArrayStringEnumDefaultEnum fromValue(String value) { } public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; - private List arrayStringEnumDefault = new ArrayList<>(); + private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default"; - private List arrayStringDefault = new ArrayList<>(); + private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default"; - private List arrayIntegerDefault = new ArrayList<>(); + private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); public static final String JSON_PROPERTY_ARRAY_STRING = "array_string"; private List arrayString = new ArrayList<>(); @@ -115,7 +116,7 @@ public DefaultValue arrayStringEnumRefDefault(List arrayStringEnu public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) { if (this.arrayStringEnumRefDefault == null) { - this.arrayStringEnumRefDefault = new ArrayList<>(); + this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); } this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem); return this; @@ -125,7 +126,7 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -149,7 +150,7 @@ public DefaultValue arrayStringEnumDefault(List arra public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) { if (this.arrayStringEnumDefault == null) { - this.arrayStringEnumDefault = new ArrayList<>(); + this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); } this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem); return this; @@ -159,7 +160,7 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -183,7 +184,7 @@ public DefaultValue arrayStringDefault(List arrayStringDefault) { public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { if (this.arrayStringDefault == null) { - this.arrayStringDefault = new ArrayList<>(); + this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); } this.arrayStringDefault.add(arrayStringDefaultItem); return this; @@ -193,7 +194,7 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -217,7 +218,7 @@ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) { public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) { if (this.arrayIntegerDefault == null) { - this.arrayIntegerDefault = new ArrayList<>(); + this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); } this.arrayIntegerDefault.add(arrayIntegerDefaultItem); return this; @@ -227,7 +228,7 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -261,7 +262,7 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -299,7 +300,7 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonIgnore public List getArrayStringNullable() { @@ -333,7 +334,7 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonIgnore public String getStringNullable() { @@ -417,5 +418,136 @@ private String toIndentedString(Object o) { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `array_string_enum_ref_default` to the URL query string + if (getArrayStringEnumRefDefault() != null) { + for (int i = 0; i < getArrayStringEnumRefDefault().size(); i++) { + if (getArrayStringEnumRefDefault().get(i) != null) { + try { + joiner.add(String.format("%sarray_string_enum_ref_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringEnumRefDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + } + + // add `array_string_enum_default` to the URL query string + if (getArrayStringEnumDefault() != null) { + for (int i = 0; i < getArrayStringEnumDefault().size(); i++) { + try { + joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `array_string_default` to the URL query string + if (getArrayStringDefault() != null) { + for (int i = 0; i < getArrayStringDefault().size(); i++) { + try { + joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `array_integer_default` to the URL query string + if (getArrayIntegerDefault() != null) { + for (int i = 0; i < getArrayIntegerDefault().size(); i++) { + try { + joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `array_string` to the URL query string + if (getArrayString() != null) { + for (int i = 0; i < getArrayString().size(); i++) { + try { + joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayString().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `array_string_nullable` to the URL query string + if (getArrayStringNullable() != null) { + for (int i = 0; i < getArrayStringNullable().size(); i++) { + try { + joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `string_nullable` to the URL query string + if (getStringNullable() != null) { + try { + joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } + } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java index dab63f7571e7..ffb0408d05b2 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java @@ -20,14 +20,15 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.Category; import org.openapitools.client.model.Tag; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; /** * Pet @@ -40,7 +41,7 @@ Pet.JSON_PROPERTY_TAGS, Pet.JSON_PROPERTY_STATUS }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -110,7 +111,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,7 +137,7 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @javax.annotation.Nonnull @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -162,7 +163,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -193,7 +194,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @javax.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -227,7 +228,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -253,7 +254,7 @@ public Pet status(StatusEnum status) { * pet status in the store * @return status **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -316,5 +317,99 @@ private String toIndentedString(Object o) { 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 `id` to the URL query string + if (getId() != null) { + try { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `name` to the URL query string + if (getName() != null) { + try { + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `category` to the URL query string + if (getCategory() != null) { + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); + } + + // add `photoUrls` to the URL query string + if (getPhotoUrls() != null) { + for (int i = 0; i < getPhotoUrls().size(); i++) { + try { + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `tags` to the URL query string + if (getTags() != null) { + for (int i = 0; i < getTags().size(); i++) { + if (getTags().get(i) != null) { + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `status` to the URL query string + if (getStatus() != null) { + try { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), "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/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java index c04e23293647..39ed6122578f 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Bird.java @@ -15,29 +15,24 @@ import java.util.Objects; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; /** * Bird */ -@JsonPropertyOrder({ - Bird.JSON_PROPERTY_SIZE, - Bird.JSON_PROPERTY_COLOR -}) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { - public static final String JSON_PROPERTY_SIZE = "size"; + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) private String size; - public static final String JSON_PROPERTY_COLOR = "color"; + public static final String SERIALIZED_NAME_COLOR = "color"; + @SerializedName(SERIALIZED_NAME_COLOR) private String color; public Bird() { @@ -53,17 +48,13 @@ public Bird size(String size) { * Get size * @return size **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_SIZE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getSize() { return size; } - @JsonProperty(JSON_PROPERTY_SIZE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSize(String size) { this.size = size; } @@ -79,17 +70,13 @@ public Bird color(String color) { * Get color * @return color **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_COLOR) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getColor() { return color; } - @JsonProperty(JSON_PROPERTY_COLOR) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setColor(String color) { this.color = color; } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java index e278b76dfad6..236c8190bb81 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Category.java @@ -15,29 +15,24 @@ import java.util.Objects; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; /** * Category */ -@JsonPropertyOrder({ - Category.JSON_PROPERTY_ID, - Category.JSON_PROPERTY_NAME -}) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { - public static final String JSON_PROPERTY_ID = "id"; + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) private Long id; - public static final String JSON_PROPERTY_NAME = "name"; + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) private String name; public Category() { @@ -53,17 +48,13 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public Long getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(Long id) { this.id = id; } @@ -79,17 +70,13 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_NAME) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getName() { return name; } - @JsonProperty(JSON_PROPERTY_NAME) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java index c8eedf63c08c..1e0355bab78f 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java @@ -15,86 +15,36 @@ import java.util.Objects; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; -import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; /** * DataQuery */ -@JsonPropertyOrder({ - DataQuery.JSON_PROPERTY_SUFFIX, - DataQuery.JSON_PROPERTY_TEXT, - DataQuery.JSON_PROPERTY_DATE, - DataQuery.JSON_PROPERTY_ID, - DataQuery.JSON_PROPERTY_OUTCOMES -}) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery { - public static final String JSON_PROPERTY_SUFFIX = "suffix"; +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { + public static final String SERIALIZED_NAME_SUFFIX = "suffix"; + @SerializedName(SERIALIZED_NAME_SUFFIX) private String suffix; - public static final String JSON_PROPERTY_TEXT = "text"; + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) private String text; - public static final String JSON_PROPERTY_DATE = "date"; + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) private OffsetDateTime date; - public static final String JSON_PROPERTY_ID = "id"; - private Long id; - - /** - * Gets or Sets outcomes - */ - public enum OutcomesEnum { - SUCCESS("SUCCESS"), - - FAILURE("FAILURE"), - - SKIPPED("SKIPPED"); - - private String value; - - OutcomesEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static OutcomesEnum fromValue(String value) { - for (OutcomesEnum b : OutcomesEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - } - - public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; - private List outcomes = new ArrayList<>(); - public DataQuery() { + } public DataQuery suffix(String suffix) { @@ -107,17 +57,13 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_SUFFIX) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getSuffix() { return suffix; } - @JsonProperty(JSON_PROPERTY_SUFFIX) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSuffix(String suffix) { this.suffix = suffix; } @@ -133,17 +79,13 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_TEXT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getText() { return text; } - @JsonProperty(JSON_PROPERTY_TEXT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setText(String text) { this.text = text; } @@ -159,82 +101,18 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_DATE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public OffsetDateTime getDate() { return date; } - @JsonProperty(JSON_PROPERTY_DATE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDate(OffsetDateTime date) { this.date = date; } - public DataQuery id(Long id) { - - this.id = id; - return this; - } - - /** - * Query - * @return id - **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public Long getId() { - return id; - } - - - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setId(Long id) { - this.id = id; - } - - - public DataQuery outcomes(List outcomes) { - - this.outcomes = outcomes; - return this; - } - - public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { - if (this.outcomes == null) { - this.outcomes = new ArrayList<>(); - } - this.outcomes.add(outcomesItem); - return this; - } - - /** - * Get outcomes - * @return outcomes - **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_OUTCOMES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public List getOutcomes() { - return outcomes; - } - - - @JsonProperty(JSON_PROPERTY_OUTCOMES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setOutcomes(List outcomes) { - this.outcomes = outcomes; - } - - @Override public boolean equals(Object o) { if (this == o) { @@ -247,24 +125,22 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - Objects.equals(this.id, dataQuery.id) && - Objects.equals(this.outcomes, dataQuery.outcomes); + super.equals(o); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, id, outcomes); + return Objects.hash(suffix, text, date, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 15d00cff792a..08b9865487cc 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -15,35 +15,29 @@ import java.util.Objects; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import java.time.OffsetDateTime; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; /** * DataQueryAllOf */ -@JsonPropertyOrder({ - DataQueryAllOf.JSON_PROPERTY_SUFFIX, - DataQueryAllOf.JSON_PROPERTY_TEXT, - DataQueryAllOf.JSON_PROPERTY_DATE -}) -@JsonTypeName("DataQuery_allOf") -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { - public static final String JSON_PROPERTY_SUFFIX = "suffix"; + public static final String SERIALIZED_NAME_SUFFIX = "suffix"; + @SerializedName(SERIALIZED_NAME_SUFFIX) private String suffix; - public static final String JSON_PROPERTY_TEXT = "text"; + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) private String text; - public static final String JSON_PROPERTY_DATE = "date"; + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) private OffsetDateTime date; public DataQueryAllOf() { @@ -59,17 +53,13 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_SUFFIX) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getSuffix() { return suffix; } - @JsonProperty(JSON_PROPERTY_SUFFIX) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setSuffix(String suffix) { this.suffix = suffix; } @@ -85,17 +75,13 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_TEXT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public String getText() { return text; } - @JsonProperty(JSON_PROPERTY_TEXT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setText(String text) { this.text = text; } @@ -111,17 +97,13 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_DATE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public OffsetDateTime getDate() { return date; } - @JsonProperty(JSON_PROPERTY_DATE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setDate(OffsetDateTime date) { this.date = date; } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java index 9d7f2fe5617d..84ac9669049f 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -15,43 +15,30 @@ import java.util.Objects; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.openapitools.client.model.StringEnumRef; 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; /** * to test the default value of properties */ -@JsonPropertyOrder({ - DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT, - DefaultValue.JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT, - DefaultValue.JSON_PROPERTY_ARRAY_STRING_DEFAULT, - DefaultValue.JSON_PROPERTY_ARRAY_INTEGER_DEFAULT, - DefaultValue.JSON_PROPERTY_ARRAY_STRING, - DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE, - DefaultValue.JSON_PROPERTY_STRING_NULLABLE -}) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { - public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; - private List arrayStringEnumRefDefault = new ArrayList<>(); + public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; + @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT) + private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); /** * Gets or Sets arrayStringEnumDefault */ + @JsonAdapter(ArrayStringEnumDefaultEnum.Adapter.class) public enum ArrayStringEnumDefaultEnum { SUCCESS("success"), @@ -65,7 +52,6 @@ public enum ArrayStringEnumDefaultEnum { this.value = value; } - @JsonValue public String getValue() { return value; } @@ -75,7 +61,6 @@ public String toString() { return String.valueOf(value); } - @JsonCreator public static ArrayStringEnumDefaultEnum fromValue(String value) { for (ArrayStringEnumDefaultEnum b : ArrayStringEnumDefaultEnum.values()) { if (b.value.equals(value)) { @@ -84,25 +69,44 @@ public static ArrayStringEnumDefaultEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ArrayStringEnumDefaultEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ArrayStringEnumDefaultEnum.fromValue(value); + } + } } - public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; - private List arrayStringEnumDefault = new ArrayList<>(); + public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; + @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT) + private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); - public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default"; - private List arrayStringDefault = new ArrayList<>(); + public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default"; + @SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT) + private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); - public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default"; - private List arrayIntegerDefault = new ArrayList<>(); + public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default"; + @SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT) + private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); - public static final String JSON_PROPERTY_ARRAY_STRING = "array_string"; + public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string"; + @SerializedName(SERIALIZED_NAME_ARRAY_STRING) private List arrayString = new ArrayList<>(); - public static final String JSON_PROPERTY_ARRAY_STRING_NULLABLE = "array_string_nullable"; - private JsonNullable> arrayStringNullable = JsonNullable.>undefined(); + public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable"; + @SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE) + private List arrayStringNullable; - public static final String JSON_PROPERTY_STRING_NULLABLE = "string_nullable"; - private JsonNullable stringNullable = JsonNullable.undefined(); + public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable"; + @SerializedName(SERIALIZED_NAME_STRING_NULLABLE) + private String stringNullable; public DefaultValue() { } @@ -115,7 +119,7 @@ public DefaultValue arrayStringEnumRefDefault(List arrayStringEnu public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) { if (this.arrayStringEnumRefDefault == null) { - this.arrayStringEnumRefDefault = new ArrayList<>(); + this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); } this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem); return this; @@ -125,17 +129,13 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public List getArrayStringEnumRefDefault() { return arrayStringEnumRefDefault; } - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayStringEnumRefDefault(List arrayStringEnumRefDefault) { this.arrayStringEnumRefDefault = arrayStringEnumRefDefault; } @@ -149,7 +149,7 @@ public DefaultValue arrayStringEnumDefault(List arra public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) { if (this.arrayStringEnumDefault == null) { - this.arrayStringEnumDefault = new ArrayList<>(); + this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); } this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem); return this; @@ -159,17 +159,13 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public List getArrayStringEnumDefault() { return arrayStringEnumDefault; } - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayStringEnumDefault(List arrayStringEnumDefault) { this.arrayStringEnumDefault = arrayStringEnumDefault; } @@ -183,7 +179,7 @@ public DefaultValue arrayStringDefault(List arrayStringDefault) { public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { if (this.arrayStringDefault == null) { - this.arrayStringDefault = new ArrayList<>(); + this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); } this.arrayStringDefault.add(arrayStringDefaultItem); return this; @@ -193,17 +189,13 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public List getArrayStringDefault() { return arrayStringDefault; } - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayStringDefault(List arrayStringDefault) { this.arrayStringDefault = arrayStringDefault; } @@ -217,7 +209,7 @@ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) { public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) { if (this.arrayIntegerDefault == null) { - this.arrayIntegerDefault = new ArrayList<>(); + this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); } this.arrayIntegerDefault.add(arrayIntegerDefaultItem); return this; @@ -227,17 +219,13 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public List getArrayIntegerDefault() { return arrayIntegerDefault; } - @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayIntegerDefault(List arrayIntegerDefault) { this.arrayIntegerDefault = arrayIntegerDefault; } @@ -261,37 +249,26 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ARRAY_STRING) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public List getArrayString() { return arrayString; } - @JsonProperty(JSON_PROPERTY_ARRAY_STRING) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setArrayString(List arrayString) { this.arrayString = arrayString; } public DefaultValue arrayStringNullable(List arrayStringNullable) { - this.arrayStringNullable = JsonNullable.>of(arrayStringNullable); + this.arrayStringNullable = arrayStringNullable; return this; } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - if (this.arrayStringNullable == null || !this.arrayStringNullable.isPresent()) { - this.arrayStringNullable = JsonNullable.>of(new ArrayList<>()); - } - try { - this.arrayStringNullable.get().add(arrayStringNullableItem); - } catch (java.util.NoSuchElementException e) { - // this can never happen, as we make sure above that the value is present - } + this.arrayStringNullable.add(arrayStringNullableItem); return this; } @@ -299,33 +276,21 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @.annotation.Nullable - @JsonIgnore + @javax.annotation.Nullable public List getArrayStringNullable() { - return arrayStringNullable.orElse(null); - } - - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public JsonNullable> getArrayStringNullable_JsonNullable() { return arrayStringNullable; } - - @JsonProperty(JSON_PROPERTY_ARRAY_STRING_NULLABLE) - public void setArrayStringNullable_JsonNullable(JsonNullable> arrayStringNullable) { - this.arrayStringNullable = arrayStringNullable; - } + public void setArrayStringNullable(List arrayStringNullable) { - this.arrayStringNullable = JsonNullable.>of(arrayStringNullable); + this.arrayStringNullable = arrayStringNullable; } public DefaultValue stringNullable(String stringNullable) { - this.stringNullable = JsonNullable.of(stringNullable); + this.stringNullable = stringNullable; return this; } @@ -333,27 +298,15 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @.annotation.Nullable - @JsonIgnore + @javax.annotation.Nullable public String getStringNullable() { - return stringNullable.orElse(null); - } - - @JsonProperty(JSON_PROPERTY_STRING_NULLABLE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public JsonNullable getStringNullable_JsonNullable() { return stringNullable; } - - @JsonProperty(JSON_PROPERTY_STRING_NULLABLE) - public void setStringNullable_JsonNullable(JsonNullable stringNullable) { - this.stringNullable = stringNullable; - } + public void setStringNullable(String stringNullable) { - this.stringNullable = JsonNullable.of(stringNullable); + this.stringNullable = stringNullable; } @@ -371,8 +324,8 @@ public boolean equals(Object o) { Objects.equals(this.arrayStringDefault, defaultValue.arrayStringDefault) && Objects.equals(this.arrayIntegerDefault, defaultValue.arrayIntegerDefault) && Objects.equals(this.arrayString, defaultValue.arrayString) && - equalsNullable(this.arrayStringNullable, defaultValue.arrayStringNullable) && - equalsNullable(this.stringNullable, defaultValue.stringNullable); + Objects.equals(this.arrayStringNullable, defaultValue.arrayStringNullable) && + Objects.equals(this.stringNullable, defaultValue.stringNullable); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -381,7 +334,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, hashCodeNullable(arrayStringNullable), hashCodeNullable(stringNullable)); + return Objects.hash(arrayStringEnumRefDefault, arrayStringEnumDefault, arrayStringDefault, arrayIntegerDefault, arrayString, arrayStringNullable, stringNullable); } private static int hashCodeNullable(JsonNullable a) { diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java index dab63f7571e7..23b255c290d0 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Pet.java @@ -15,51 +15,46 @@ import java.util.Objects; import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.openapitools.client.model.Category; import org.openapitools.client.model.Tag; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; /** * Pet */ -@JsonPropertyOrder({ - Pet.JSON_PROPERTY_ID, - Pet.JSON_PROPERTY_NAME, - Pet.JSON_PROPERTY_CATEGORY, - Pet.JSON_PROPERTY_PHOTO_URLS, - Pet.JSON_PROPERTY_TAGS, - Pet.JSON_PROPERTY_STATUS -}) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { - public static final String JSON_PROPERTY_ID = "id"; + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) private Long id; - public static final String JSON_PROPERTY_NAME = "name"; + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) private String name; - public static final String JSON_PROPERTY_CATEGORY = "category"; + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) private Category category; - public static final String JSON_PROPERTY_PHOTO_URLS = "photoUrls"; + public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls"; + @SerializedName(SERIALIZED_NAME_PHOTO_URLS) private List photoUrls = new ArrayList<>(); - public static final String JSON_PROPERTY_TAGS = "tags"; + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) private List tags = new ArrayList<>(); /** * pet status in the store */ + @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { AVAILABLE("available"), @@ -73,7 +68,6 @@ public enum StatusEnum { this.value = value; } - @JsonValue public String getValue() { return value; } @@ -83,7 +77,6 @@ public String toString() { return String.valueOf(value); } - @JsonCreator public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { @@ -92,9 +85,23 @@ public static StatusEnum fromValue(String value) { } throw new IllegalArgumentException("Unexpected value '" + value + "'"); } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } } - public static final String JSON_PROPERTY_STATUS = "status"; + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) private StatusEnum status; public Pet() { @@ -110,17 +117,13 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public Long getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(Long id) { this.id = id; } @@ -136,17 +139,13 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull - @JsonProperty(JSON_PROPERTY_NAME) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @javax.annotation.Nonnull public String getName() { return name; } - @JsonProperty(JSON_PROPERTY_NAME) - @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setName(String name) { this.name = name; } @@ -162,17 +161,13 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_CATEGORY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public Category getCategory() { return category; } - @JsonProperty(JSON_PROPERTY_CATEGORY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCategory(Category category) { this.category = category; } @@ -193,17 +188,13 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull - @JsonProperty(JSON_PROPERTY_PHOTO_URLS) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @javax.annotation.Nonnull public List getPhotoUrls() { return photoUrls; } - @JsonProperty(JSON_PROPERTY_PHOTO_URLS) - @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } @@ -227,17 +218,13 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_TAGS) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public List getTags() { return tags; } - @JsonProperty(JSON_PROPERTY_TAGS) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTags(List tags) { this.tags = tags; } @@ -253,17 +240,13 @@ public Pet status(StatusEnum status) { * pet status in the store * @return status **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_STATUS) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @javax.annotation.Nullable public StatusEnum getStatus() { return status; } - @JsonProperty(JSON_PROPERTY_STATUS) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setStatus(StatusEnum status) { this.status = status; } diff --git a/samples/client/echo_api/java/native/docs/DataQuery.md b/samples/client/echo_api/java/native/docs/DataQuery.md index 5beb983af973..338c467b2d56 100644 --- a/samples/client/echo_api/java/native/docs/DataQuery.md +++ b/samples/client/echo_api/java/native/docs/DataQuery.md @@ -10,18 +10,6 @@ |**suffix** | **String** | test suffix | [optional] | |**text** | **String** | Some text containing white spaces | [optional] | |**date** | **OffsetDateTime** | A date | [optional] | -|**id** | **Long** | Query | [optional] | -|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | - - - -## Enum: List<OutcomesEnum> - -| Name | Value | -|---- | -----| -| SUCCESS | "SUCCESS" | -| FAILURE | "FAILURE" | -| SKIPPED | "SKIPPED" | diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java index e4161a695bb6..7bc3649a8631 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -34,7 +35,7 @@ Bird.JSON_PROPERTY_SIZE, Bird.JSON_PROPERTY_COLOR }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { public static final String JSON_PROPERTY_SIZE = "size"; private String size; @@ -54,7 +55,7 @@ public Bird size(String size) { * Get size * @return size **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_SIZE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -79,7 +80,7 @@ public Bird color(String color) { * Get color * @return color **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_COLOR) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,5 +137,50 @@ private String toIndentedString(Object o) { } 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 `size` to the URL query string + if (getSize() != null) { + joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `color` to the URL query string + if (getColor() != null) { + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java index 0aaed79d4809..d647aea29bf4 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -34,7 +35,7 @@ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -54,7 +55,7 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -79,7 +80,7 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,5 +137,50 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java index e9f24440745c..23fd24cf1790 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,12 +25,9 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; -import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -38,12 +38,10 @@ @JsonPropertyOrder({ DataQuery.JSON_PROPERTY_SUFFIX, DataQuery.JSON_PROPERTY_TEXT, - DataQuery.JSON_PROPERTY_DATE, - DataQuery.JSON_PROPERTY_ID, - DataQuery.JSON_PROPERTY_OUTCOMES + DataQuery.JSON_PROPERTY_DATE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -53,49 +51,6 @@ public class DataQuery { public static final String JSON_PROPERTY_DATE = "date"; private OffsetDateTime date; - public static final String JSON_PROPERTY_ID = "id"; - private Long id; - - /** - * Gets or Sets outcomes - */ - public enum OutcomesEnum { - SUCCESS("SUCCESS"), - - FAILURE("FAILURE"), - - SKIPPED("SKIPPED"); - - private String value; - - OutcomesEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static OutcomesEnum fromValue(String value) { - for (OutcomesEnum b : OutcomesEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - } - - public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; - private List outcomes = new ArrayList<>(); - public DataQuery() { } @@ -108,7 +63,7 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -133,7 +88,7 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -158,7 +113,7 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -174,64 +129,6 @@ public void setDate(OffsetDateTime date) { } - public DataQuery id(Long id) { - this.id = id; - return this; - } - - /** - * Query - * @return id - **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public Long getId() { - return id; - } - - - @JsonProperty(JSON_PROPERTY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setId(Long id) { - this.id = id; - } - - - public DataQuery outcomes(List outcomes) { - this.outcomes = outcomes; - return this; - } - - public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { - if (this.outcomes == null) { - this.outcomes = new ArrayList<>(); - } - this.outcomes.add(outcomesItem); - return this; - } - - /** - * Get outcomes - * @return outcomes - **/ - @.annotation.Nullable - @JsonProperty(JSON_PROPERTY_OUTCOMES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - - public List getOutcomes() { - return outcomes; - } - - - @JsonProperty(JSON_PROPERTY_OUTCOMES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setOutcomes(List outcomes) { - this.outcomes = outcomes; - } - - /** * Return true if this DataQuery object is equal to o. */ @@ -247,24 +144,22 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - Objects.equals(this.id, dataQuery.id) && - Objects.equals(this.outcomes, dataQuery.outcomes); + super.equals(o); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, id, outcomes); + return Objects.hash(suffix, text, date, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } @@ -279,5 +174,69 @@ private String toIndentedString(Object o) { } 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 `suffix` to the URL query string + if (getSuffix() != null) { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `text` to the URL query string + if (getText() != null) { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `date` to the URL query string + if (getDate() != null) { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `outcomes` to the URL query string + if (getOutcomes() != null) { + for (int i = 0; i < getOutcomes().size(); i++) { + joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getOutcomes().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + return joiner.toString(); + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 08ae093dbee6..16f726a615b7 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -36,7 +37,7 @@ DataQueryAllOf.JSON_PROPERTY_TEXT, DataQueryAllOf.JSON_PROPERTY_DATE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { public static final String JSON_PROPERTY_SUFFIX = "suffix"; private String suffix; @@ -59,7 +60,7 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUFFIX) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -84,7 +85,7 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -109,7 +110,7 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -168,5 +169,55 @@ private String toIndentedString(Object o) { } 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 `suffix` to the URL query string + if (getSuffix() != null) { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `text` to the URL query string + if (getText() != null) { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `date` to the URL query string + if (getDate() != null) { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java index 08a062454228..28f3c70e6346 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.StringEnumRef; @@ -46,10 +47,10 @@ DefaultValue.JSON_PROPERTY_ARRAY_STRING_NULLABLE, DefaultValue.JSON_PROPERTY_STRING_NULLABLE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; - private List arrayStringEnumRefDefault = new ArrayList<>(); + private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); /** * Gets or Sets arrayStringEnumDefault @@ -89,13 +90,13 @@ public static ArrayStringEnumDefaultEnum fromValue(String value) { } public static final String JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; - private List arrayStringEnumDefault = new ArrayList<>(); + private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); public static final String JSON_PROPERTY_ARRAY_STRING_DEFAULT = "array_string_default"; - private List arrayStringDefault = new ArrayList<>(); + private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); public static final String JSON_PROPERTY_ARRAY_INTEGER_DEFAULT = "array_integer_default"; - private List arrayIntegerDefault = new ArrayList<>(); + private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); public static final String JSON_PROPERTY_ARRAY_STRING = "array_string"; private List arrayString = new ArrayList<>(); @@ -126,7 +127,7 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_REF_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -159,7 +160,7 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_ENUM_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -192,7 +193,7 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -225,7 +226,7 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_INTEGER_DEFAULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -258,7 +259,7 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_ARRAY_STRING) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -295,7 +296,7 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonIgnore public List getArrayStringNullable() { @@ -328,7 +329,7 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonIgnore public String getStringNullable() { @@ -414,5 +415,101 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `array_string_enum_ref_default` to the URL query string + if (getArrayStringEnumRefDefault() != null) { + for (int i = 0; i < getArrayStringEnumRefDefault().size(); i++) { + if (getArrayStringEnumRefDefault().get(i) != null) { + joiner.add(String.format("%sarray_string_enum_ref_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringEnumRefDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + } + + // add `array_string_enum_default` to the URL query string + if (getArrayStringEnumDefault() != null) { + for (int i = 0; i < getArrayStringEnumDefault().size(); i++) { + joiner.add(String.format("%sarray_string_enum_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringEnumDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + // add `array_string_default` to the URL query string + if (getArrayStringDefault() != null) { + for (int i = 0; i < getArrayStringDefault().size(); i++) { + joiner.add(String.format("%sarray_string_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + // add `array_integer_default` to the URL query string + if (getArrayIntegerDefault() != null) { + for (int i = 0; i < getArrayIntegerDefault().size(); i++) { + joiner.add(String.format("%sarray_integer_default%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayIntegerDefault().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + // add `array_string` to the URL query string + if (getArrayString() != null) { + for (int i = 0; i < getArrayString().size(); i++) { + joiner.add(String.format("%sarray_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + // add `array_string_nullable` to the URL query string + if (getArrayStringNullable() != null) { + for (int i = 0; i < getArrayStringNullable().size(); i++) { + joiner.add(String.format("%sarray_string_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayStringNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + // add `string_nullable` to the URL query string + if (getStringNullable() != null) { + joiner.add(String.format("%sstring_nullable%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringNullable()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md b/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md index 5beb983af973..338c467b2d56 100644 --- a/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md +++ b/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md @@ -10,18 +10,6 @@ |**suffix** | **String** | test suffix | [optional] | |**text** | **String** | Some text containing white spaces | [optional] | |**date** | **OffsetDateTime** | A date | [optional] | -|**id** | **Long** | Query | [optional] | -|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | - - - -## Enum: List<OutcomesEnum> - -| Name | Value | -|---- | -----| -| SUCCESS | "SUCCESS" | -| FAILURE | "FAILURE" | -| SKIPPED | "SKIPPED" | diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java index b56b91c263c5..0e54b8e21a8c 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * Bird */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Bird { public static final String SERIALIZED_NAME_SIZE = "size"; @SerializedName(SERIALIZED_NAME_SIZE) @@ -71,7 +69,7 @@ public Bird size(String size) { * Get size * @return size **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getSize() { return size; @@ -93,7 +91,7 @@ public Bird color(String color) { * Get color * @return color **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getColor() { return color; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java index 5ae560afa09f..9b9f3df7d1f1 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * Category */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +69,7 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -93,7 +91,7 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getName() { return name; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java index 93b1cbe7903a..52c90035ee57 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java @@ -20,13 +20,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; -import org.openapitools.client.model.DataQueryAllOf; import org.openapitools.client.model.Query; import com.google.gson.Gson; @@ -53,8 +50,8 @@ /** * DataQuery */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class DataQuery { +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { public static final String SERIALIZED_NAME_SUFFIX = "suffix"; @SerializedName(SERIALIZED_NAME_SUFFIX) private String suffix; @@ -67,63 +64,6 @@ public class DataQuery { @SerializedName(SERIALIZED_NAME_DATE) private OffsetDateTime date; - public static final String SERIALIZED_NAME_ID = "id"; - @SerializedName(SERIALIZED_NAME_ID) - private Long id; - - /** - * Gets or Sets outcomes - */ - @JsonAdapter(OutcomesEnum.Adapter.class) - public enum OutcomesEnum { - SUCCESS("SUCCESS"), - - FAILURE("FAILURE"), - - SKIPPED("SKIPPED"); - - private String value; - - OutcomesEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static OutcomesEnum fromValue(String value) { - for (OutcomesEnum b : OutcomesEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final OutcomesEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public OutcomesEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return OutcomesEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_OUTCOMES = "outcomes"; - @SerializedName(SERIALIZED_NAME_OUTCOMES) - private List outcomes = new ArrayList<>(); - public DataQuery() { } @@ -137,7 +77,7 @@ public DataQuery suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getSuffix() { return suffix; @@ -159,7 +99,7 @@ public DataQuery text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getText() { return text; @@ -181,7 +121,7 @@ public DataQuery date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable + @javax.annotation.Nullable public OffsetDateTime getDate() { return date; @@ -193,58 +133,6 @@ public void setDate(OffsetDateTime date) { } - public DataQuery id(Long id) { - - this.id = id; - return this; - } - - /** - * Query - * @return id - **/ - @.annotation.Nullable - - public Long getId() { - return id; - } - - - public void setId(Long id) { - this.id = id; - } - - - public DataQuery outcomes(List outcomes) { - - this.outcomes = outcomes; - return this; - } - - public DataQuery addOutcomesItem(OutcomesEnum outcomesItem) { - if (this.outcomes == null) { - this.outcomes = new ArrayList<>(); - } - this.outcomes.add(outcomesItem); - return this; - } - - /** - * Get outcomes - * @return outcomes - **/ - @.annotation.Nullable - - public List getOutcomes() { - return outcomes; - } - - - public void setOutcomes(List outcomes) { - this.outcomes = outcomes; - } - - @Override public boolean equals(Object o) { @@ -258,24 +146,22 @@ public boolean equals(Object o) { return Objects.equals(this.suffix, dataQuery.suffix) && Objects.equals(this.text, dataQuery.text) && Objects.equals(this.date, dataQuery.date) && - Objects.equals(this.id, dataQuery.id) && - Objects.equals(this.outcomes, dataQuery.outcomes); + super.equals(o); } @Override public int hashCode() { - return Objects.hash(suffix, text, date, id, outcomes); + return Objects.hash(suffix, text, date, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); sb.append(" text: ").append(toIndentedString(text)).append("\n"); sb.append(" date: ").append(toIndentedString(date)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); sb.append("}"); return sb.toString(); } @@ -334,10 +220,6 @@ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); } - // ensure the optional json data is an array if present - if (jsonObj.get("outcomes") != null && !jsonObj.get("outcomes").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `outcomes` to be an array in the JSON string but got `%s`", jsonObj.get("outcomes").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java index 9d7b2600a144..950251095b3e 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; @@ -49,7 +47,7 @@ /** * DataQueryAllOf */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DataQueryAllOf { public static final String SERIALIZED_NAME_SUFFIX = "suffix"; @SerializedName(SERIALIZED_NAME_SUFFIX) @@ -76,7 +74,7 @@ public DataQueryAllOf suffix(String suffix) { * test suffix * @return suffix **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getSuffix() { return suffix; @@ -98,7 +96,7 @@ public DataQueryAllOf text(String text) { * Some text containing white spaces * @return text **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getText() { return text; @@ -120,7 +118,7 @@ public DataQueryAllOf date(OffsetDateTime date) { * A date * @return date **/ - @.annotation.Nullable + @javax.annotation.Nullable public OffsetDateTime getDate() { return date; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java index 7d64b77146af..420af1f7ff6c 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -52,11 +50,11 @@ /** * to test the default value of properties */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultValue { public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT = "array_string_enum_ref_default"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_REF_DEFAULT) - private List arrayStringEnumRefDefault = new ArrayList<>(); + private List arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); /** * Gets or Sets arrayStringEnumDefault @@ -109,15 +107,15 @@ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOExc public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT) - private List arrayStringEnumDefault = new ArrayList<>(); + private List arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); public static final String SERIALIZED_NAME_ARRAY_STRING_DEFAULT = "array_string_default"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_DEFAULT) - private List arrayStringDefault = new ArrayList<>(); + private List arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); public static final String SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT = "array_integer_default"; @SerializedName(SERIALIZED_NAME_ARRAY_INTEGER_DEFAULT) - private List arrayIntegerDefault = new ArrayList<>(); + private List arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); public static final String SERIALIZED_NAME_ARRAY_STRING = "array_string"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING) @@ -125,7 +123,7 @@ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOExc public static final String SERIALIZED_NAME_ARRAY_STRING_NULLABLE = "array_string_nullable"; @SerializedName(SERIALIZED_NAME_ARRAY_STRING_NULLABLE) - private List arrayStringNullable = new ArrayList<>(); + private List arrayStringNullable; public static final String SERIALIZED_NAME_STRING_NULLABLE = "string_nullable"; @SerializedName(SERIALIZED_NAME_STRING_NULLABLE) @@ -142,7 +140,7 @@ public DefaultValue arrayStringEnumRefDefault(List arrayStringEnu public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEnumRefDefaultItem) { if (this.arrayStringEnumRefDefault == null) { - this.arrayStringEnumRefDefault = new ArrayList<>(); + this.arrayStringEnumRefDefault = new ArrayList<>(Arrays.asList(StringEnumRef.SUCCESS, StringEnumRef.FAILURE)); } this.arrayStringEnumRefDefault.add(arrayStringEnumRefDefaultItem); return this; @@ -152,7 +150,7 @@ public DefaultValue addArrayStringEnumRefDefaultItem(StringEnumRef arrayStringEn * Get arrayStringEnumRefDefault * @return arrayStringEnumRefDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getArrayStringEnumRefDefault() { return arrayStringEnumRefDefault; @@ -172,7 +170,7 @@ public DefaultValue arrayStringEnumDefault(List arra public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arrayStringEnumDefaultItem) { if (this.arrayStringEnumDefault == null) { - this.arrayStringEnumDefault = new ArrayList<>(); + this.arrayStringEnumDefault = new ArrayList<>(Arrays.asList(ArrayStringEnumDefaultEnum.SUCCESS, ArrayStringEnumDefaultEnum.FAILURE)); } this.arrayStringEnumDefault.add(arrayStringEnumDefaultItem); return this; @@ -182,7 +180,7 @@ public DefaultValue addArrayStringEnumDefaultItem(ArrayStringEnumDefaultEnum arr * Get arrayStringEnumDefault * @return arrayStringEnumDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getArrayStringEnumDefault() { return arrayStringEnumDefault; @@ -202,7 +200,7 @@ public DefaultValue arrayStringDefault(List arrayStringDefault) { public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { if (this.arrayStringDefault == null) { - this.arrayStringDefault = new ArrayList<>(); + this.arrayStringDefault = new ArrayList<>(Arrays.asList("failure", "skipped")); } this.arrayStringDefault.add(arrayStringDefaultItem); return this; @@ -212,7 +210,7 @@ public DefaultValue addArrayStringDefaultItem(String arrayStringDefaultItem) { * Get arrayStringDefault * @return arrayStringDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getArrayStringDefault() { return arrayStringDefault; @@ -232,7 +230,7 @@ public DefaultValue arrayIntegerDefault(List arrayIntegerDefault) { public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) { if (this.arrayIntegerDefault == null) { - this.arrayIntegerDefault = new ArrayList<>(); + this.arrayIntegerDefault = new ArrayList<>(Arrays.asList(1, 3)); } this.arrayIntegerDefault.add(arrayIntegerDefaultItem); return this; @@ -242,7 +240,7 @@ public DefaultValue addArrayIntegerDefaultItem(Integer arrayIntegerDefaultItem) * Get arrayIntegerDefault * @return arrayIntegerDefault **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getArrayIntegerDefault() { return arrayIntegerDefault; @@ -272,7 +270,7 @@ public DefaultValue addArrayStringItem(String arrayStringItem) { * Get arrayString * @return arrayString **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getArrayString() { return arrayString; @@ -291,9 +289,6 @@ public DefaultValue arrayStringNullable(List arrayStringNullable) { } public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { - if (this.arrayStringNullable == null) { - this.arrayStringNullable = new ArrayList<>(); - } this.arrayStringNullable.add(arrayStringNullableItem); return this; } @@ -302,7 +297,7 @@ public DefaultValue addArrayStringNullableItem(String arrayStringNullableItem) { * Get arrayStringNullable * @return arrayStringNullable **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getArrayStringNullable() { return arrayStringNullable; @@ -324,7 +319,7 @@ public DefaultValue stringNullable(String stringNullable) { * Get stringNullable * @return stringNullable **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getStringNullable() { return stringNullable; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java index abf95ac4da6d..c3aa75d476bf 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -52,7 +50,7 @@ /** * Pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -140,7 +138,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -162,7 +160,7 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @javax.annotation.Nonnull public String getName() { return name; @@ -184,7 +182,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @javax.annotation.Nullable public Category getCategory() { return category; @@ -211,7 +209,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @javax.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -241,7 +239,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getTags() { return tags; @@ -263,7 +261,7 @@ public Pet status(StatusEnum status) { * pet status in the store * @return status **/ - @.annotation.Nullable + @javax.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java index 122b562fff7f..275a49dcf429 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/StringUtil.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.Iterator; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java index 3d0a2b1f6d79..72a4e7910c96 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java @@ -35,7 +35,7 @@ import java.util.List; import java.util.Map; import java.io.InputStream; -import .ws.rs.core.GenericType; +import javax.ws.rs.core.GenericType; public class PingApi { private ApiClient localVarApiClient; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java index a060052c9771..d41b8a58391c 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java index aa9ee01f9136..96f57427e9fd 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBearerAuth implements Authentication { private final String scheme; private String bearerToken; diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java index f71b3d6745d8..dde198e60683 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * SomeObj */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class SomeObj { /** * Gets or Sets $type @@ -128,7 +126,7 @@ public SomeObj() { * Get $type * @return $type **/ - @.annotation.Nullable + @javax.annotation.Nullable public TypeEnum get$Type() { return $type; @@ -150,7 +148,7 @@ public SomeObj id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -172,7 +170,7 @@ public SomeObj name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getName() { return name; @@ -194,7 +192,7 @@ public SomeObj active(Boolean active) { * Get active * @return active **/ - @.annotation.Nullable + @javax.annotation.Nullable public Boolean getActive() { return active; @@ -216,7 +214,7 @@ public SomeObj type(String type) { * Get type * @return type **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getType() { return type; diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java index b93958095133..7d5241198622 100644 --- a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Order.java @@ -43,6 +43,8 @@ public class Order { @JsonbProperty("shipDate") private Date shipDate; + @JsonbTypeSerializer(StatusEnum.Serializer.class) + @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); @@ -63,6 +65,24 @@ public String toString() { return String.valueOf(value); } + public static final class Deserializer implements JsonbDeserializer { + @Override + public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); + } + } + + public static final class Serializer implements JsonbSerializer { + @Override + public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } } /** diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java index 895e50c3025b..d39f45d721e0 100644 --- a/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/model/Pet.java @@ -49,6 +49,8 @@ public class Pet { @JsonbProperty("tags") private List tags = null; + @JsonbTypeSerializer(StatusEnum.Serializer.class) + @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); @@ -69,6 +71,24 @@ public String toString() { return String.valueOf(value); } + public static final class Deserializer implements JsonbDeserializer { + @Override + public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); + } + } + + public static final class Serializer implements JsonbSerializer { + @Override + public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } } /** diff --git a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java index e245de60ca08..b775633f6ce7 100644 --- a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Order.java @@ -43,6 +43,8 @@ public class Order { @JsonbProperty("shipDate") private Date shipDate; + @JsonbTypeSerializer(StatusEnum.Serializer.class) + @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); @@ -63,6 +65,24 @@ public String toString() { return String.valueOf(value); } + public static final class Deserializer implements JsonbDeserializer { + @Override + public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); + } + } + + public static final class Serializer implements JsonbSerializer { + @Override + public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } } /** diff --git a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java index 7c6a4fbfd3fd..9b415336ac06 100644 --- a/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/model/Pet.java @@ -49,6 +49,8 @@ public class Pet { @JsonbProperty("tags") private List tags = null; + @JsonbTypeSerializer(StatusEnum.Serializer.class) + @JsonbTypeDeserializer(StatusEnum.Deserializer.class) public enum StatusEnum { AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); @@ -69,6 +71,24 @@ public String toString() { return String.valueOf(value); } + public static final class Deserializer implements JsonbDeserializer { + @Override + public StatusEnum deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'"); + } + } + + public static final class Serializer implements JsonbSerializer { + @Override + public void serialize(StatusEnum obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } } /** diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java index 9d044c36ff23..098d777d9942 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -34,7 +35,7 @@ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -54,7 +55,7 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -79,7 +80,7 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,5 +137,50 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 3d19ee41161e..1ac8d3f977e7 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -35,7 +36,7 @@ ModelApiResponse.JSON_PROPERTY_TYPE, ModelApiResponse.JSON_PROPERTY_MESSAGE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String JSON_PROPERTY_CODE = "code"; private Integer code; @@ -58,7 +59,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -83,7 +84,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -108,7 +109,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -167,5 +168,55 @@ private String toIndentedString(Object o) { } 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 `code` to the URL query string + if (getCode() != null) { + joiner.add(String.format("%scode%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `message` to the URL query string + if (getMessage() != null) { + joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java index 902d45a51602..c64c67c42aba 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -39,7 +40,7 @@ Order.JSON_PROPERTY_STATUS, Order.JSON_PROPERTY_COMPLETE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -108,7 +109,7 @@ public Order id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -133,7 +134,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -158,7 +159,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -183,7 +184,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -208,7 +209,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -233,7 +234,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -298,5 +299,70 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `petId` to the URL query string + if (getPetId() != null) { + joiner.add(String.format("%spetId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `quantity` to the URL query string + if (getQuantity() != null) { + joiner.add(String.format("%squantity%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `shipDate` to the URL query string + if (getShipDate() != null) { + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `complete` to the URL query string + if (getComplete() != null) { + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java index 343855b6d83b..c003989b3414 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; 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.ArrayList; import java.util.List; import org.openapitools.client.model.Category; @@ -42,7 +43,7 @@ Pet.JSON_PROPERTY_TAGS, Pet.JSON_PROPERTY_STATUS }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -111,7 +112,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,7 +137,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -161,7 +162,7 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -191,7 +192,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -224,7 +225,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -251,7 +252,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -316,5 +317,79 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `category` to the URL query string + if (getCategory() != null) { + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `photoUrls` to the URL query string + if (getPhotoUrls() != null) { + for (int i = 0; i < getPhotoUrls().size(); i++) { + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + // add `tags` to the URL query string + if (getTags() != null) { + for (int i = 0; i < getTags().size(); i++) { + if (getTags().get(i) != null) { + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java index e4888fa3a4de..d59987169b90 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java @@ -13,6 +13,9 @@ package org.openapitools.client.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; import java.util.Objects; import java.util.Arrays; import java.util.Map; @@ -22,8 +25,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -34,7 +35,7 @@ Tag.JSON_PROPERTY_ID, Tag.JSON_PROPERTY_NAME }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -54,7 +55,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -79,7 +80,7 @@ public Tag name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -136,5 +137,50 @@ private String toIndentedString(Object o) { } 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 `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } } diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java index c17f5b7f4c21..74e474b0e27a 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * A category for a pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +69,7 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -93,7 +91,7 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java index b8cdd90b944d..855c8732c421 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * Describes the result of uploading an image resource */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) @@ -75,7 +73,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @.annotation.Nullable + @javax.annotation.Nullable public Integer getCode() { return code; @@ -97,7 +95,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getType() { return type; @@ -119,7 +117,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getMessage() { return message; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java index eb7ac449ae09..b6069802987b 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; @@ -49,7 +47,7 @@ /** * An order for a pets from the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -137,7 +135,7 @@ public Order id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -159,7 +157,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getPetId() { return petId; @@ -181,7 +179,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @.annotation.Nullable + @javax.annotation.Nullable public Integer getQuantity() { return quantity; @@ -203,7 +201,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @.annotation.Nullable + @javax.annotation.Nullable public OffsetDateTime getShipDate() { return shipDate; @@ -225,7 +223,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @.annotation.Nullable + @javax.annotation.Nullable public StatusEnum getStatus() { return status; @@ -247,7 +245,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @.annotation.Nullable + @javax.annotation.Nullable public Boolean getComplete() { return complete; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java index f7d611413e34..7c1fae694270 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -52,7 +50,7 @@ /** * A pet for sale in the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -140,7 +138,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -162,7 +160,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @javax.annotation.Nullable public Category getCategory() { return category; @@ -184,7 +182,7 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @javax.annotation.Nonnull public String getName() { return name; @@ -211,7 +209,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @javax.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -241,7 +239,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getTags() { return tags; @@ -265,7 +263,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @.annotation.Nullable + @javax.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java index 6b939a3e9afd..312895d569ff 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * A tag for a pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +69,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -93,7 +91,7 @@ public Tag name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java index 7165ee7e93fa..3078490c3af5 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * A User who is purchasing from the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class User { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -95,7 +93,7 @@ public User id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -117,7 +115,7 @@ public User username(String username) { * Get username * @return username **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getUsername() { return username; @@ -139,7 +137,7 @@ public User firstName(String firstName) { * Get firstName * @return firstName **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getFirstName() { return firstName; @@ -161,7 +159,7 @@ public User lastName(String lastName) { * Get lastName * @return lastName **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getLastName() { return lastName; @@ -183,7 +181,7 @@ public User email(String email) { * Get email * @return email **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getEmail() { return email; @@ -205,7 +203,7 @@ public User password(String password) { * Get password * @return password **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getPassword() { return password; @@ -227,7 +225,7 @@ public User phone(String phone) { * Get phone * @return phone **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getPhone() { return phone; @@ -249,7 +247,7 @@ public User userStatus(Integer userStatus) { * User Status * @return userStatus **/ - @.annotation.Nullable + @javax.annotation.Nullable public Integer getUserStatus() { return userStatus; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java index c17f5b7f4c21..74e474b0e27a 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * A category for a pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +69,7 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -93,7 +91,7 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java index b8cdd90b944d..855c8732c421 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * Describes the result of uploading an image resource */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) @@ -75,7 +73,7 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @.annotation.Nullable + @javax.annotation.Nullable public Integer getCode() { return code; @@ -97,7 +95,7 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getType() { return type; @@ -119,7 +117,7 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getMessage() { return message; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java index eb7ac449ae09..b6069802987b 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.time.OffsetDateTime; @@ -49,7 +47,7 @@ /** * An order for a pets from the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -137,7 +135,7 @@ public Order id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -159,7 +157,7 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getPetId() { return petId; @@ -181,7 +179,7 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @.annotation.Nullable + @javax.annotation.Nullable public Integer getQuantity() { return quantity; @@ -203,7 +201,7 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @.annotation.Nullable + @javax.annotation.Nullable public OffsetDateTime getShipDate() { return shipDate; @@ -225,7 +223,7 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @.annotation.Nullable + @javax.annotation.Nullable public StatusEnum getStatus() { return status; @@ -247,7 +245,7 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @.annotation.Nullable + @javax.annotation.Nullable public Boolean getComplete() { return complete; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java index f7d611413e34..7c1fae694270 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -52,7 +50,7 @@ /** * A pet for sale in the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -140,7 +138,7 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -162,7 +160,7 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @javax.annotation.Nullable public Category getCategory() { return category; @@ -184,7 +182,7 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @javax.annotation.Nonnull public String getName() { return name; @@ -211,7 +209,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @javax.annotation.Nonnull public List getPhotoUrls() { return photoUrls; @@ -241,7 +239,7 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @javax.annotation.Nullable public List getTags() { return tags; @@ -265,7 +263,7 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @.annotation.Nullable + @javax.annotation.Nullable public StatusEnum getStatus() { return status; diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java index 6b939a3e9afd..312895d569ff 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java @@ -20,8 +20,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -48,7 +46,7 @@ /** * A tag for a pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +69,7 @@ public Tag id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable public Long getId() { return id; @@ -93,7 +91,7 @@ public Tag name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java index c17f5b7f4c21..d404c0c07ca6 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Category.java @@ -48,7 +48,8 @@ /** * A category for a pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@ApiModel(description = "A category for a pet") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +72,8 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Long getId() { return id; @@ -93,7 +95,8 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java index b8cdd90b944d..db10be182961 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -48,7 +48,8 @@ /** * Describes the result of uploading an image resource */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@ApiModel(description = "Describes the result of uploading an image resource") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) @@ -75,7 +76,8 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Integer getCode() { return code; @@ -97,7 +99,8 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getType() { return type; @@ -119,7 +122,8 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getMessage() { return message; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java index eb7ac449ae09..547ed754b820 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java @@ -49,7 +49,8 @@ /** * An order for a pets from the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@ApiModel(description = "An order for a pets from the pet store") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -137,7 +138,8 @@ public Order id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Long getId() { return id; @@ -159,7 +161,8 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Long getPetId() { return petId; @@ -181,7 +184,8 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Integer getQuantity() { return quantity; @@ -203,7 +207,8 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public OffsetDateTime getShipDate() { return shipDate; @@ -225,7 +230,8 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "Order Status") public StatusEnum getStatus() { return status; @@ -247,7 +253,8 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Boolean getComplete() { return complete; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java index f7d611413e34..1deb29bce92c 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java @@ -52,7 +52,8 @@ /** * A pet for sale in the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@ApiModel(description = "A pet for sale in the pet store") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -140,7 +141,8 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Long getId() { return id; @@ -162,7 +164,8 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Category getCategory() { return category; @@ -184,7 +187,8 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @javax.annotation.Nonnull + @ApiModelProperty(example = "doggie", required = true, value = "") public String getName() { return name; @@ -211,7 +215,8 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") public List getPhotoUrls() { return photoUrls; @@ -241,7 +246,8 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public List getTags() { return tags; @@ -265,7 +271,8 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "pet status in the store") public StatusEnum getStatus() { return status; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java index 6b939a3e9afd..d6e095358fa4 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Tag.java @@ -48,7 +48,8 @@ /** * A tag for a pet */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@ApiModel(description = "A tag for a pet") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -71,7 +72,8 @@ public Tag id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Long getId() { return id; @@ -93,7 +95,8 @@ public Tag name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getName() { return name; diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java index 7165ee7e93fa..3dc3fc06dfa0 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/User.java @@ -48,7 +48,8 @@ /** * A User who is purchasing from the pet store */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@ApiModel(description = "A User who is purchasing from the pet store") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class User { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @@ -95,7 +96,8 @@ public User id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public Long getId() { return id; @@ -117,7 +119,8 @@ public User username(String username) { * Get username * @return username **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getUsername() { return username; @@ -139,7 +142,8 @@ public User firstName(String firstName) { * Get firstName * @return firstName **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getFirstName() { return firstName; @@ -161,7 +165,8 @@ public User lastName(String lastName) { * Get lastName * @return lastName **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getLastName() { return lastName; @@ -183,7 +188,8 @@ public User email(String email) { * Get email * @return email **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getEmail() { return email; @@ -205,7 +211,8 @@ public User password(String password) { * Get password * @return password **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getPassword() { return password; @@ -227,7 +234,8 @@ public User phone(String phone) { * Get phone * @return phone **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") public String getPhone() { return phone; @@ -249,7 +257,8 @@ public User userStatus(Integer userStatus) { * User Status * @return userStatus **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "User Status") public Integer getUserStatus() { return userStatus; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java index 8c64c58dec0d..561f5e521900 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java @@ -1,15 +1,15 @@ package org.openapitools.client; -import .ws.rs.client.Client; -import .ws.rs.client.ClientBuilder; -import .ws.rs.client.Entity; -import .ws.rs.client.Invocation; -import .ws.rs.client.WebTarget; -import .ws.rs.core.Form; -import .ws.rs.core.GenericType; -import .ws.rs.core.MediaType; -import .ws.rs.core.Response; -import .ws.rs.core.Response.Status; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Form; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.ClientProperties; @@ -66,7 +66,7 @@ /** *

ApiClient class.

*/ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiClient extends JavaTimeFormatter { protected Map defaultHeaderMap = new HashMap(); protected Map defaultCookieMap = new HashMap(); @@ -199,7 +199,7 @@ public JSON getJSON() { /** *

Getter for the field httpClient.

* - * @return a {@link .ws.rs.client.Client} object. + * @return a {@link javax.ws.rs.client.Client} object. */ public Client getHttpClient() { return httpClient; @@ -208,7 +208,7 @@ public Client getHttpClient() { /** *

Setter for the field httpClient.

* - * @param httpClient a {@link .ws.rs.client.Client} object. + * @param httpClient a {@link javax.ws.rs.client.Client} object. * @return a {@link org.openapitools.client.ApiClient} object. */ public ApiClient setHttpClient(Client httpClient) { @@ -929,7 +929,7 @@ public File downloadFileFromResponse(Response response) throws ApiException { /** *

Prepare the file for download from the response.

* - * @param response a {@link .ws.rs.core.Response} object. + * @param response a {@link javax.ws.rs.core.Response} object. * @return a {@link java.io.File} object. * @throws java.io.IOException if any. */ @@ -1193,7 +1193,7 @@ public ClientConfig getDefaultClientConfig() { * To completely disable certificate validation (at your own risk), you can * override this method and invoke disableCertificateValidation(clientBuilder). * - * @param clientBuilder a {@link .ws.rs.client.ClientBuilder} object. + * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object. */ protected void customizeClientBuilder(ClientBuilder clientBuilder) { // No-op extension point @@ -1205,7 +1205,7 @@ protected void customizeClientBuilder(ClientBuilder clientBuilder) { * Please note that trusting all certificates is extremely risky. * This may be useful in a development environment with self-signed certificates. * - * @param clientBuilder a {@link .ws.rs.client.ClientBuilder} object. + * @param clientBuilder a {@link javax.ws.rs.client.ClientBuilder} object. * @throws java.security.KeyManagementException if any. * @throws java.security.NoSuchAlgorithmException if any. */ @@ -1232,7 +1232,7 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) { /** *

Build the response headers.

* - * @param response a {@link .ws.rs.core.Response} object. + * @param response a {@link javax.ws.rs.core.Response} object. * @return a {@link java.util.Map} of response headers. */ protected Map> buildResponseHeaders(Response response) { diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java index aadc1fb91ee9..0559ac98ab96 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JavaTimeFormatter.java @@ -20,7 +20,7 @@ * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class. * It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}. */ -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class JavaTimeFormatter { private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java index 03f3555f2405..baacf90a2b13 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/StringUtil.java @@ -16,7 +16,7 @@ import java.util.Collection; import java.util.Iterator; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java index f9a1aa01b4be..3b1d2d280f05 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/api/UsageApi.java @@ -6,7 +6,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.Pair; -import .ws.rs.core.GenericType; +import javax.ws.rs.core.GenericType; import java.util.ArrayList; @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class UsageApi { private ApiClient apiClient; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java index cff48865c78e..f7ae20160d33 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.List; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java index 7c2a64e028b0..2bae057b7c42 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.List; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBearerAuth implements Authentication { private final String scheme; private String bearerToken; diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java index 16286fc92569..2bbea7b750cf 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -6,7 +6,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.Pair; -import .ws.rs.core.GenericType; +import javax.ws.rs.core.GenericType; import org.openapitools.client.model.MySchemaNameCharacters; @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map; -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class DefaultApi { private ApiClient apiClient; diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java index dd755fc7ae28..a39f12c00b14 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchema.java @@ -29,9 +29,6 @@ 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 org.openapitools.client.model.ChildSchemaAllOf; import org.openapitools.client.model.Parent; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -43,7 +40,7 @@ @JsonPropertyOrder({ ChildSchema.JSON_PROPERTY_PROP1 }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @JsonIgnoreProperties( value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization allowSetters = true // allows the objectType to be set during deserialization @@ -66,7 +63,7 @@ public ChildSchema prop1(String prop1) { * Get prop1 * @return prop1 **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP1) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java index f7662204b798..d6851fb740b9 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/ChildSchemaAllOf.java @@ -22,8 +22,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -35,7 +33,7 @@ ChildSchemaAllOf.JSON_PROPERTY_PROP1 }) @JsonTypeName("ChildSchema_allOf") -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ChildSchemaAllOf { public static final String JSON_PROPERTY_PROP1 = "prop1"; private String prop1; @@ -52,7 +50,7 @@ public ChildSchemaAllOf prop1(String prop1) { * Get prop1 * @return prop1 **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP1) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java index 6f11ccf0bda9..fd536702c9c1 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharacters.java @@ -29,9 +29,6 @@ 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 org.openapitools.client.model.MySchemaNameCharactersAllOf; import org.openapitools.client.model.Parent; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -44,7 +41,7 @@ MySchemaNameCharacters.JSON_PROPERTY_PROP2 }) @JsonTypeName("MySchemaName._-Characters") -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @JsonIgnoreProperties( value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization allowSetters = true // allows the objectType to be set during deserialization @@ -67,7 +64,7 @@ public MySchemaNameCharacters prop2(String prop2) { * Get prop2 * @return prop2 **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP2) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java index ab36fc1fb113..78aeee21aef7 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/MySchemaNameCharactersAllOf.java @@ -22,8 +22,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.openapitools.client.JSON; @@ -35,7 +33,7 @@ MySchemaNameCharactersAllOf.JSON_PROPERTY_PROP2 }) @JsonTypeName("MySchemaName___Characters_allOf") -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class MySchemaNameCharactersAllOf { public static final String JSON_PROPERTY_PROP2 = "prop2"; private String prop2; @@ -52,7 +50,7 @@ public MySchemaNameCharactersAllOf prop2(String prop2) { * Get prop2 * @return prop2 **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_PROP2) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java index 1f7316701db3..ebef79d5e941 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/model/Parent.java @@ -25,8 +25,6 @@ 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 org.openapitools.client.model.ChildSchema; import org.openapitools.client.model.MySchemaNameCharacters; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -39,7 +37,7 @@ @JsonPropertyOrder({ Parent.JSON_PROPERTY_OBJECT_TYPE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") @JsonIgnoreProperties( value = "objectType", // ignore manually set objectType, it will be automatically generated by Jackson during serialization allowSetters = true // allows the objectType to be set during deserialization @@ -66,7 +64,7 @@ public Parent objectType(String objectType) { * Get objectType * @return objectType **/ - @.annotation.Nullable + @javax.annotation.Nullable @JsonProperty(JSON_PROPERTY_OBJECT_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java index 3bec69c1a0de..308f13bc2634 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Category.java @@ -31,11 +31,12 @@ /** * A category for a pet */ +@ApiModel(description = "A category for a pet") @JsonPropertyOrder({ Category.JSON_PROPERTY_ID, Category.JSON_PROPERTY_NAME }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Category { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -55,7 +56,8 @@ public Category id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +82,8 @@ public Category name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java index a1821dbb385c..656070057d26 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -31,13 +31,14 @@ /** * Describes the result of uploading an image resource */ +@ApiModel(description = "Describes the result of uploading an image resource") @JsonPropertyOrder({ ModelApiResponse.JSON_PROPERTY_CODE, ModelApiResponse.JSON_PROPERTY_TYPE, ModelApiResponse.JSON_PROPERTY_MESSAGE }) @JsonTypeName("ApiResponse") -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ModelApiResponse { public static final String JSON_PROPERTY_CODE = "code"; private Integer code; @@ -60,7 +61,8 @@ public ModelApiResponse code(Integer code) { * Get code * @return code **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -85,7 +87,8 @@ public ModelApiResponse type(String type) { * Get type * @return type **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -110,7 +113,8 @@ public ModelApiResponse message(String message) { * Get message * @return message **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java index 43f544ac26fc..89791081a096 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Order.java @@ -32,6 +32,7 @@ /** * An order for a pets from the pet store */ +@ApiModel(description = "An order for a pets from the pet store") @JsonPropertyOrder({ Order.JSON_PROPERTY_ID, Order.JSON_PROPERTY_PET_ID, @@ -40,7 +41,7 @@ Order.JSON_PROPERTY_STATUS, Order.JSON_PROPERTY_COMPLETE }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Order { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -109,7 +110,8 @@ public Order id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -134,7 +136,8 @@ public Order petId(Long petId) { * Get petId * @return petId **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -159,7 +162,8 @@ public Order quantity(Integer quantity) { * Get quantity * @return quantity **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -184,7 +188,8 @@ public Order shipDate(OffsetDateTime shipDate) { * Get shipDate * @return shipDate **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -209,7 +214,8 @@ public Order status(StatusEnum status) { * Order Status * @return status **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -234,7 +240,8 @@ public Order complete(Boolean complete) { * Get complete * @return complete **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java index bed39bc9648c..866bfced4c7d 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Pet.java @@ -35,6 +35,7 @@ /** * A pet for sale in the pet store */ +@ApiModel(description = "A pet for sale in the pet store") @JsonPropertyOrder({ Pet.JSON_PROPERTY_ID, Pet.JSON_PROPERTY_CATEGORY, @@ -43,7 +44,7 @@ Pet.JSON_PROPERTY_TAGS, Pet.JSON_PROPERTY_STATUS }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pet { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -112,7 +113,8 @@ public Pet id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -137,7 +139,8 @@ public Pet category(Category category) { * Get category * @return category **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -162,7 +165,8 @@ public Pet name(String name) { * Get name * @return name **/ - @.annotation.Nonnull + @javax.annotation.Nonnull + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -192,7 +196,8 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * Get photoUrls * @return photoUrls **/ - @.annotation.Nonnull + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -225,7 +230,8 @@ public Pet addTagsItem(Tag tagsItem) { * Get tags * @return tags **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -252,7 +258,8 @@ public Pet status(StatusEnum status) { * @deprecated **/ @Deprecated - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java index 7da7da3fd40e..3852416d80b4 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/Tag.java @@ -31,11 +31,12 @@ /** * A tag for a pet */ +@ApiModel(description = "A tag for a pet") @JsonPropertyOrder({ Tag.JSON_PROPERTY_ID, Tag.JSON_PROPERTY_NAME }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Tag { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -55,7 +56,8 @@ public Tag id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -80,7 +82,8 @@ public Tag name(String name) { * Get name * @return name **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java index 98d8a5272d1a..e354d4dbda6a 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/model/User.java @@ -31,6 +31,7 @@ /** * A User who is purchasing from the pet store */ +@ApiModel(description = "A User who is purchasing from the pet store") @JsonPropertyOrder({ User.JSON_PROPERTY_ID, User.JSON_PROPERTY_USERNAME, @@ -41,7 +42,7 @@ User.JSON_PROPERTY_PHONE, User.JSON_PROPERTY_USER_STATUS }) -@.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class User { public static final String JSON_PROPERTY_ID = "id"; private Long id; @@ -79,7 +80,8 @@ public User id(Long id) { * Get id * @return id **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -104,7 +106,8 @@ public User username(String username) { * Get username * @return username **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -129,7 +132,8 @@ public User firstName(String firstName) { * Get firstName * @return firstName **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -154,7 +158,8 @@ public User lastName(String lastName) { * Get lastName * @return lastName **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -179,7 +184,8 @@ public User email(String email) { * Get email * @return email **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -204,7 +210,8 @@ public User password(String password) { * Get password * @return password **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -229,7 +236,8 @@ public User phone(String phone) { * Get phone * @return phone **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -254,7 +262,8 @@ public User userStatus(Integer userStatus) { * User Status * @return userStatus **/ - @.annotation.Nullable + @javax.annotation.Nullable + @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java index d74962ea1914..72502d0f0e26 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Category.java @@ -48,7 +48,7 @@ public Category id(Long id) { * @return id */ - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Long getId() { return id; } @@ -67,7 +67,7 @@ public Category name(String name) { * @return name */ @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") - @Schema(name = "name", required = false) + @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getName() { return name; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java index 8a01264cac07..d7fd8f87d926 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -54,7 +54,7 @@ public ModelApiResponse code(Integer code) { * @return code */ - @Schema(name = "code", required = false) + @Schema(name = "code", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getCode() { return code; } @@ -73,7 +73,7 @@ public ModelApiResponse type(String type) { * @return type */ - @Schema(name = "type", required = false) + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getType() { return type; } @@ -92,7 +92,7 @@ public ModelApiResponse message(String message) { * @return message */ - @Schema(name = "message", required = false) + @Schema(name = "message", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getMessage() { return message; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java index d57417899844..a2507752ed07 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Order.java @@ -105,7 +105,7 @@ public Order id(Long id) { * @return id */ - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Long getId() { return id; } @@ -124,7 +124,7 @@ public Order petId(Long petId) { * @return petId */ - @Schema(name = "petId", required = false) + @Schema(name = "petId", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Long getPetId() { return petId; } @@ -143,7 +143,7 @@ public Order quantity(Integer quantity) { * @return quantity */ - @Schema(name = "quantity", required = false) + @Schema(name = "quantity", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getQuantity() { return quantity; } @@ -162,7 +162,7 @@ public Order shipDate(Date shipDate) { * @return shipDate */ @Valid - @Schema(name = "shipDate", required = false) + @Schema(name = "shipDate", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Date getShipDate() { return shipDate; } @@ -181,7 +181,7 @@ public Order status(StatusEnum status) { * @return status */ - @Schema(name = "status", description = "Order Status", required = false) + @Schema(name = "status", description = "Order Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public StatusEnum getStatus() { return status; } @@ -200,7 +200,7 @@ public Order complete(Boolean complete) { * @return complete */ - @Schema(name = "complete", required = false) + @Schema(name = "complete", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Boolean getComplete() { return complete; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java index 43f830ce2952..280811e85670 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java @@ -108,7 +108,7 @@ public Pet id(Long id) { * @return id */ - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Long getId() { return id; } @@ -127,7 +127,7 @@ public Pet category(Category category) { * @return category */ @Valid - @Schema(name = "category", required = false) + @Schema(name = "category", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Category getCategory() { return category; } @@ -146,7 +146,7 @@ public Pet name(String name) { * @return name */ @NotNull - @Schema(name = "name", example = "doggie", required = true) + @Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED) public String getName() { return name; } @@ -170,7 +170,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * @return photoUrls */ @NotNull - @Schema(name = "photoUrls", required = true) + @Schema(name = "photoUrls", requiredMode = Schema.RequiredMode.REQUIRED) public List getPhotoUrls() { return photoUrls; } @@ -197,7 +197,7 @@ public Pet addTagsItem(Tag tagsItem) { * @return tags */ @Valid - @Schema(name = "tags", required = false) + @Schema(name = "tags", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public List getTags() { return tags; } @@ -216,7 +216,7 @@ public Pet status(StatusEnum status) { * @return status */ - @Schema(name = "status", description = "pet status in the store", required = false) + @Schema(name = "status", description = "pet status in the store", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public StatusEnum getStatus() { return status; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java index 84a8c85754e5..e841695b5e09 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Tag.java @@ -48,7 +48,7 @@ public Tag id(Long id) { * @return id */ - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Long getId() { return id; } @@ -67,7 +67,7 @@ public Tag name(String name) { * @return name */ - @Schema(name = "name", required = false) + @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getName() { return name; } diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java index b7f1e01576b0..5a2a1168ea85 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/User.java @@ -72,7 +72,7 @@ public User id(Long id) { * @return id */ - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Long getId() { return id; } @@ -91,7 +91,7 @@ public User username(String username) { * @return username */ - @Schema(name = "username", required = false) + @Schema(name = "username", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getUsername() { return username; } @@ -110,7 +110,7 @@ public User firstName(String firstName) { * @return firstName */ - @Schema(name = "firstName", required = false) + @Schema(name = "firstName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getFirstName() { return firstName; } @@ -129,7 +129,7 @@ public User lastName(String lastName) { * @return lastName */ - @Schema(name = "lastName", required = false) + @Schema(name = "lastName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getLastName() { return lastName; } @@ -148,7 +148,7 @@ public User email(String email) { * @return email */ - @Schema(name = "email", required = false) + @Schema(name = "email", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getEmail() { return email; } @@ -167,7 +167,7 @@ public User password(String password) { * @return password */ - @Schema(name = "password", required = false) + @Schema(name = "password", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getPassword() { return password; } @@ -186,7 +186,7 @@ public User phone(String phone) { * @return phone */ - @Schema(name = "phone", required = false) + @Schema(name = "phone", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getPhone() { return phone; } @@ -205,7 +205,7 @@ public User userStatus(Integer userStatus) { * @return userStatus */ - @Schema(name = "userStatus", description = "User Status", required = false) + @Schema(name = "userStatus", description = "User Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getUserStatus() { return userStatus; } diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java index 9bfa4b7c9b4e..1de389611a7e 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Category.java @@ -53,7 +53,7 @@ public Category id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -77,7 +77,7 @@ public Category name(String name) { **/ @Nullable @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") - @Schema(name = "name", required = false) + @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java index fe1b67499eb1..91ecfafb30ee 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/ModelApiResponse.java @@ -58,7 +58,7 @@ public ModelApiResponse code(Integer code) { * @return code **/ @Nullable - @Schema(name = "code", required = false) + @Schema(name = "code", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getCode() { @@ -81,7 +81,7 @@ public ModelApiResponse type(String type) { * @return type **/ @Nullable - @Schema(name = "type", required = false) + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getType() { @@ -104,7 +104,7 @@ public ModelApiResponse message(String message) { * @return message **/ @Nullable - @Schema(name = "message", required = false) + @Schema(name = "message", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getMessage() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java index 7594d35deeaa..f759446ae7c4 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Order.java @@ -104,7 +104,7 @@ public Order id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -127,7 +127,7 @@ public Order petId(Long petId) { * @return petId **/ @Nullable - @Schema(name = "petId", required = false) + @Schema(name = "petId", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getPetId() { @@ -150,7 +150,7 @@ public Order quantity(Integer quantity) { * @return quantity **/ @Nullable - @Schema(name = "quantity", required = false) + @Schema(name = "quantity", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getQuantity() { @@ -173,7 +173,7 @@ public Order shipDate(OffsetDateTime shipDate) { * @return shipDate **/ @Nullable - @Schema(name = "shipDate", required = false) + @Schema(name = "shipDate", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXX") @@ -198,7 +198,7 @@ public Order status(StatusEnum status) { * @return status **/ @Nullable - @Schema(name = "status", description = "Order Status", required = false) + @Schema(name = "status", description = "Order Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { @@ -221,7 +221,7 @@ public Order complete(Boolean complete) { * @return complete **/ @Nullable - @Schema(name = "complete", required = false) + @Schema(name = "complete", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Boolean getComplete() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java index 1a4b66d3350d..1ce739e5bec2 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Pet.java @@ -109,7 +109,7 @@ public Pet id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -133,7 +133,7 @@ public Pet category(Category category) { **/ @Valid @Nullable - @Schema(name = "category", required = false) + @Schema(name = "category", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Category getCategory() { @@ -156,7 +156,7 @@ public Pet name(String name) { * @return name **/ @NotNull - @Schema(name = "name", example = "doggie", required = true) + @Schema(name = "name", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED) @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getName() { @@ -184,7 +184,7 @@ public Pet addPhotoUrlsItem(String photoUrlsItem) { * @return photoUrls **/ @NotNull - @Schema(name = "photoUrls", required = true) + @Schema(name = "photoUrls", requiredMode = Schema.RequiredMode.REQUIRED) @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public List getPhotoUrls() { @@ -215,7 +215,7 @@ public Pet addTagsItem(Tag tagsItem) { * @return tags **/ @Nullable - @Schema(name = "tags", required = false) + @Schema(name = "tags", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public List getTags() { @@ -238,7 +238,7 @@ public Pet status(StatusEnum status) { * @return status **/ @Nullable - @Schema(name = "status", description = "pet status in the store", required = false) + @Schema(name = "status", description = "pet status in the store", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public StatusEnum getStatus() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java index b94c645596ec..fe4dd0f4676a 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/Tag.java @@ -53,7 +53,7 @@ public Tag id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -76,7 +76,7 @@ public Tag name(String name) { * @return name **/ @Nullable - @Schema(name = "name", required = false) + @Schema(name = "name", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getName() { diff --git a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java index 17cf05d120b7..e1e76dd010fa 100644 --- a/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java +++ b/samples/server/petstore/java-micronaut-server/src/main/java/org/openapitools/model/User.java @@ -77,7 +77,7 @@ public User id(Long id) { * @return id **/ @Nullable - @Schema(name = "id", required = false) + @Schema(name = "id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Long getId() { @@ -100,7 +100,7 @@ public User username(String username) { * @return username **/ @Nullable - @Schema(name = "username", required = false) + @Schema(name = "username", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getUsername() { @@ -123,7 +123,7 @@ public User firstName(String firstName) { * @return firstName **/ @Nullable - @Schema(name = "firstName", required = false) + @Schema(name = "firstName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getFirstName() { @@ -146,7 +146,7 @@ public User lastName(String lastName) { * @return lastName **/ @Nullable - @Schema(name = "lastName", required = false) + @Schema(name = "lastName", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getLastName() { @@ -169,7 +169,7 @@ public User email(String email) { * @return email **/ @Nullable - @Schema(name = "email", required = false) + @Schema(name = "email", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getEmail() { @@ -192,7 +192,7 @@ public User password(String password) { * @return password **/ @Nullable - @Schema(name = "password", required = false) + @Schema(name = "password", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPassword() { @@ -215,7 +215,7 @@ public User phone(String phone) { * @return phone **/ @Nullable - @Schema(name = "phone", required = false) + @Schema(name = "phone", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public String getPhone() { @@ -238,7 +238,7 @@ public User userStatus(Integer userStatus) { * @return userStatus **/ @Nullable - @Schema(name = "userStatus", description = "User Status", required = false) + @Schema(name = "userStatus", description = "User Status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Integer getUserStatus() { From 0dbc5391512382fbf3548125abf332c5bb9caf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Rodr=C3=ADguez=20Mart=C3=ADn?= Date: Fri, 17 Feb 2023 15:03:32 +0100 Subject: [PATCH 4/5] upgrade samples --- .../src/main/java/org/openapitools/model/AnimalDto.java | 1 - .../src/main/java/org/openapitools/model/CatDto.java | 1 - .../src/main/java/org/openapitools/model/AnimalDto.java | 1 - .../springboot/src/main/java/org/openapitools/model/CatDto.java | 1 - 4 files changed, 4 deletions(-) diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/AnimalDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/AnimalDto.java index 87b60c3cdb2a..c17b0385407e 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/AnimalDto.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/AnimalDto.java @@ -34,7 +34,6 @@ @JsonSubTypes.Type(value = DogDto.class, name = "Dog") }) -@JsonTypeName("Animal") @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AnimalDto { diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/CatDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/CatDto.java index 99cf34ad2325..61f8bc958e63 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/CatDto.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/CatDto.java @@ -31,7 +31,6 @@ @JsonSubTypes.Type(value = BigCatDto.class, name = "BigCat") }) -@JsonTypeName("Cat") @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class CatDto extends AnimalDto { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AnimalDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AnimalDto.java index aba7e9e70f51..3d6817c8f8ce 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AnimalDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/AnimalDto.java @@ -37,7 +37,6 @@ @JsonSubTypes.Type(value = DogDto.class, name = "Dog") }) -@JsonTypeName("Animal") @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class AnimalDto { diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/CatDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/CatDto.java index ffbd4428513b..3d11bd7ba3aa 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/CatDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/CatDto.java @@ -34,7 +34,6 @@ @JsonSubTypes.Type(value = BigCatDto.class, name = "BigCat") }) -@JsonTypeName("Cat") @Generated(value = "org.openapitools.codegen.languages.SpringCodegen") public class CatDto extends AnimalDto { From d5ccaf46ab543cf95fae865d565356381649fd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Rodr=C3=ADguez=20Mart=C3=ADn?= Date: Fri, 17 Feb 2023 21:16:08 +0100 Subject: [PATCH 5/5] Revert "Update samples" This reverts commit d6affde263d6c539e32a7f38dc984cf5948ab322. --- .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 17 -- .../CustomInstantDeserializer.java | 232 ------------------ .../configuration/JacksonConfiguration.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 73 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 17 -- .../CustomInstantDeserializer.java | 232 ------------------ .../configuration/JacksonConfiguration.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../CustomInstantDeserializer.java | 232 ------------------ .../configuration/JacksonConfiguration.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../CustomInstantDeserializer.java | 232 ------------------ .../configuration/JacksonConfiguration.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 73 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ .../org/openapitools/OpenAPI2SpringBoot.java | 23 -- .../OpenAPIDocumentationConfig.java | 71 ------ 52 files changed, 3032 deletions(-) delete mode 100644 samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java delete mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java delete mode 100644 samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java delete mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java delete mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java delete mode 100644 samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java delete mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java diff --git a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 9bf61a0df0f9..000000000000 --- a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("ByRefOrValue") - .description("This tests for a oneOf interface representation ") - .license("") - .licenseUrl("http://unlicense.org") - .termsOfServiceUrl("") - .version("0.0.1") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.byRefOrValue.base-path:}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 1fc96305a3e7..000000000000 --- a/samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 1fc96305a3e7..000000000000 --- a/samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index 1ebe51cb901d..000000000000 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.openapitools; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java deleted file mode 100644 index 8f936b311447..000000000000 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java deleted file mode 100644 index b481a87518f4..000000000000 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; - -@Configuration -public class JacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(ThreeTenModule.class) - ThreeTenModule threeTenModule() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - return module; - } -} diff --git a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 1fc96305a3e7..000000000000 --- a/samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 77674f29d63f..000000000000 --- a/samples/openapi3/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.Optional; -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .genericModelSubstitutes(Optional.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 1fc96305a3e7..000000000000 --- a/samples/openapi3/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index 1ebe51cb901d..000000000000 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.openapitools; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java deleted file mode 100644 index 8f936b311447..000000000000 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java deleted file mode 100644 index b481a87518f4..000000000000 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/JacksonConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; - -@Configuration -public class JacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(ThreeTenModule.class) - ThreeTenModule threeTenModule() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - return module; - } -} diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java deleted file mode 100644 index 8f936b311447..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java deleted file mode 100644 index b481a87518f4..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; - -@Configuration -public class JacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(ThreeTenModule.class) - ThreeTenModule threeTenModule() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - return module; - } -} diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index ae31b200b2d6..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index ae31b200b2d6..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java deleted file mode 100644 index 8f936b311447..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java deleted file mode 100644 index b481a87518f4..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/JacksonConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools.configuration; - -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; - -@Configuration -public class JacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(ThreeTenModule.class) - ThreeTenModule threeTenModule() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - return module; - } -} diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index ae31b200b2d6..000000000000 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index ae31b200b2d6..000000000000 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 77674f29d63f..000000000000 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.Optional; -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .genericModelSubstitutes(Optional.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index 2610b90e6393..000000000000 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.virtualan.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index 7fd7bc22fdaa..000000000000 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.virtualan.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java deleted file mode 100644 index f62fd6d91797..000000000000 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/OpenAPI2SpringBoot.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.openapitools; - -import com.fasterxml.jackson.databind.Module; -import org.openapitools.jackson.nullable.JsonNullableModule; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}) -public class OpenApiGeneratorApplication { - - public static void main(String[] args) { - SpringApplication.run(OpenApiGeneratorApplication.class, args); - } - - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java deleted file mode 100644 index e05217a98f21..000000000000 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openapitools.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import javax.annotation.Generated; -import javax.servlet.ServletContext; - -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") -@Configuration -@EnableSwagger2 -public class SpringFoxConfiguration { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("OpenAPI Petstore") - .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") - .license("Apache-2.0") - .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") - .termsOfServiceUrl("") - .version("1.0.0") - .contact(new Contact("","", "")) - .build(); - } - - @Bean - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.openapitools.api")) - .build() - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -}