From 58d4187054cc9e5f967f2b5153d2a89f5d81c8cd Mon Sep 17 00:00:00 2001 From: David Guthrie Date: Thu, 23 Mar 2017 11:24:53 -0400 Subject: [PATCH 01/31] Added a new additional option that allows one to replace the the 'file' generated class with org.springframework.core.io.Resource, which will allow returing file data from Urls or anything that can be converted to a stream. --- .../codegen/languages/SpringCodegen.java | 34 +++++++++++++++++++ .../options/SpringOptionsProvider.java | 2 ++ 2 files changed, 36 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index 9616f4f11ad..0f4867507ba 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java @@ -5,6 +5,7 @@ import io.swagger.codegen.languages.features.BeanValidationFeatures; import io.swagger.models.Operation; import io.swagger.models.Path; import io.swagger.models.Swagger; +import io.swagger.models.properties.Property; import java.io.File; import java.util.*; @@ -24,6 +25,7 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation public static final String SPRING_MVC_LIBRARY = "spring-mvc"; public static final String SPRING_CLOUD_LIBRARY = "spring-cloud"; public static final String IMPLICIT_HEADERS = "implicitHeaders"; + public static final String RESOURCE_FILE_STREAMS = "resourceStreams"; protected String title = "swagger-petstore"; protected String configPackage = "io.swagger.configuration"; @@ -66,6 +68,7 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames")); cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.")); + cliOptions.add(CliOption.newBoolean(RESOURCE_FILE_STREAMS, "When \"file\" is specified as a type, generate the type as org.springframework.core.io.Resource, and FileSystemResource for example values.")); supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration."); supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration."); @@ -148,6 +151,11 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); } + if (additionalProperties.containsKey(RESOURCE_FILE_STREAMS)) { + typeMapping.put("file", "Resource"); + importMapping.put("Resource", "org.springframework.core.io.Resource"); + } + if (useBeanValidation) { writePropertyBack(USE_BEANVALIDATION, useBeanValidation); } @@ -448,6 +456,32 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation return camelize(name) + "Api"; } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("File".equals(type)) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + if (example == null) { + example = "/path/to/file"; + } + example = "new org.springframework.core.io.FileSystemResource(new java.io.File(\"" + escapeText(example) + "\"))"; + p.example = example; + } else { + super.setParameterExampleValue(p); + } + } + public void setTitle(String title) { this.title = title; } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java index 6387d49f144..d3cc27dc723 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java @@ -20,6 +20,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider { public static final String USE_TAGS = "useTags"; public static final String USE_BEANVALIDATION = "false"; public static final String IMPLICIT_HEADERS = "false"; + public static final String RESOURCE_FILE_STREAMS = "false"; @Override public String getLanguage() { @@ -42,6 +43,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider { options.put(SpringCodegen.USE_TAGS, USE_TAGS); options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION); options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS); + options.put(SpringCodegen.RESOURCE_FILE_STREAMS, RESOURCE_FILE_STREAMS); return options; } From aa773dc7fda3c330b04c1ef8ff7e0c10920f6152 Mon Sep 17 00:00:00 2001 From: David Guthrie Date: Thu, 30 Mar 2017 12:34:22 -0400 Subject: [PATCH 02/31] Resource stream for file is no longer an option, it's the default for Spring --- .../io/swagger/codegen/languages/SpringCodegen.java | 11 +++-------- .../codegen/options/SpringOptionsProvider.java | 2 -- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index 0f4867507ba..89fc3f4653a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java @@ -5,7 +5,6 @@ import io.swagger.codegen.languages.features.BeanValidationFeatures; import io.swagger.models.Operation; import io.swagger.models.Path; import io.swagger.models.Swagger; -import io.swagger.models.properties.Property; import java.io.File; import java.util.*; @@ -25,7 +24,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation public static final String SPRING_MVC_LIBRARY = "spring-mvc"; public static final String SPRING_CLOUD_LIBRARY = "spring-cloud"; public static final String IMPLICIT_HEADERS = "implicitHeaders"; - public static final String RESOURCE_FILE_STREAMS = "resourceStreams"; protected String title = "swagger-petstore"; protected String configPackage = "io.swagger.configuration"; @@ -68,7 +66,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames")); cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.")); - cliOptions.add(CliOption.newBoolean(RESOURCE_FILE_STREAMS, "When \"file\" is specified as a type, generate the type as org.springframework.core.io.Resource, and FileSystemResource for example values.")); supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration."); supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration."); @@ -151,11 +148,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); } - if (additionalProperties.containsKey(RESOURCE_FILE_STREAMS)) { - typeMapping.put("file", "Resource"); - importMapping.put("Resource", "org.springframework.core.io.Resource"); - } - if (useBeanValidation) { writePropertyBack(USE_BEANVALIDATION, useBeanValidation); } @@ -165,6 +157,9 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString())); } + typeMapping.put("file", "Resource"); + importMapping.put("Resource", "org.springframework.core.io.Resource"); + supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java index d3cc27dc723..6387d49f144 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringOptionsProvider.java @@ -20,7 +20,6 @@ public class SpringOptionsProvider extends JavaOptionsProvider { public static final String USE_TAGS = "useTags"; public static final String USE_BEANVALIDATION = "false"; public static final String IMPLICIT_HEADERS = "false"; - public static final String RESOURCE_FILE_STREAMS = "false"; @Override public String getLanguage() { @@ -43,7 +42,6 @@ public class SpringOptionsProvider extends JavaOptionsProvider { options.put(SpringCodegen.USE_TAGS, USE_TAGS); options.put(SpringCodegen.USE_BEANVALIDATION, USE_BEANVALIDATION); options.put(SpringCodegen.IMPLICIT_HEADERS, IMPLICIT_HEADERS); - options.put(SpringCodegen.RESOURCE_FILE_STREAMS, RESOURCE_FILE_STREAMS); return options; } From 02bcad36fd67b16ad8690cc2a381ac39882fa9fe Mon Sep 17 00:00:00 2001 From: "Thomas, Elizabeth-CW" Date: Thu, 13 Apr 2017 09:31:07 -0500 Subject: [PATCH 03/31] Elizabeth/Joy - adding example support if specified in the swagger spec --- .../src/main/resources/JavaSpring/api.mustache | 3 ++- .../main/resources/JavaSpring/apiController.mustache | 12 ++++++++++-- .../resources/JavaSpring/exampleReturnTypes.mustache | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/JavaSpring/exampleReturnTypes.mustache diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index 327e5c03f78..b8f91005288 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; {{#async}} @@ -48,7 +49,7 @@ public interface {{classname}} { produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { + {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{#examples}}throws IOException{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} { // do some magic! return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; }{{/jdk8}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache index 608c22d212a..12c5a0f0416 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache @@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; {{#async}} @@ -39,9 +41,15 @@ public class {{classname}}Controller implements {{classname}} { {{^jdk8-no-delegate}}{{#operation}} public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, - {{/hasMore}}{{/allParams}}) { + {{/hasMore}}{{/allParams}}) {{#examples}}throws IOException{{/examples}} { // do some magic!{{^isDelegate}}{{^async}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/async}}{{#async}} + + {{#examples}} + ObjectMapper objectMapper = new ObjectMapper(); + return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue({{{example}}},{{>exampleReturnTypes}}.class), HttpStatus.OK); + {{/examples}} + {{^examples}} + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/examples}}{{/async}}{{#async}} return new CallablereturnTypes}}>>() { @Override public ResponseEntity<{{>returnTypes}}> call() throws Exception { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/exampleReturnTypes.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/exampleReturnTypes.mustache new file mode 100644 index 00000000000..395e3889c20 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/exampleReturnTypes.mustache @@ -0,0 +1 @@ +{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file From a32774c541128499c2fed12deca5cf9228550454 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 17 Apr 2017 23:25:27 +0800 Subject: [PATCH 04/31] update spring boot bean validation script --- bin/springboot-petstore-server-beanvalidation.json | 1 + samples/server/petstore/springboot-beanvalidation/pom.xml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/springboot-petstore-server-beanvalidation.json b/bin/springboot-petstore-server-beanvalidation.json index ac9d7cf599b..21db69b6d8d 100644 --- a/bin/springboot-petstore-server-beanvalidation.json +++ b/bin/springboot-petstore-server-beanvalidation.json @@ -1,4 +1,5 @@ { + "artifactId": "spring-boot-beanvalidation", "library": "spring-boot", "useBeanValidation": true } diff --git a/samples/server/petstore/springboot-beanvalidation/pom.xml b/samples/server/petstore/springboot-beanvalidation/pom.xml index 2541ef0f478..5af442938b5 100644 --- a/samples/server/petstore/springboot-beanvalidation/pom.xml +++ b/samples/server/petstore/springboot-beanvalidation/pom.xml @@ -1,9 +1,9 @@ 4.0.0 io.swagger - swagger-spring-beanvalidation + spring-boot-beanvalidation jar - swagger-spring + spring-boot-beanvalidation 1.0.0 1.7 @@ -70,4 +70,4 @@ provided - + \ No newline at end of file From 34a99d6dba031e7ca213fba837e0ecd7afd08b49 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 17 Apr 2017 23:32:03 +0800 Subject: [PATCH 05/31] update spring petstore samples --- .../spring-cloud/src/main/java/io/swagger/api/PetApi.java | 2 +- .../spring-stubs/src/main/java/io/swagger/api/PetApi.java | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 2 +- .../spring-mvc/src/main/java/io/swagger/api/PetApi.java | 2 +- .../src/main/java/io/swagger/api/PetApiController.java | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 2 +- .../src/main/java/io/swagger/api/PetApiController.java | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 2 +- .../src/main/java/io/swagger/api/PetApiController.java | 2 +- .../src/main/java/io/swagger/api/PetApiDelegate.java | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 2 +- .../src/main/java/io/swagger/api/PetApiController.java | 2 +- .../src/main/java/io/swagger/api/PetApiDelegate.java | 2 +- .../springboot/src/main/java/io/swagger/api/PetApi.java | 2 +- .../src/main/java/io/swagger/api/PetApiController.java | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java index ff145451fe9..4d3e2792ebb 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java index 6a733290a0b..617ad50e019 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java index 481c651fda1..4ee9bae9961 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.HttpStatus; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 911092d3307..3cf98279345 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java index 80a62f62c29..973055a2f11 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java index 911092d3307..3cf98279345 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java index 80a62f62c29..973055a2f11 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java index c924d5539d8..f310e2cdc0d 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.HttpStatus; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java index c498459bfb0..3c23ed5674a 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java index 7f89dfdabb4..265e7046956 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiDelegate.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.HttpStatus; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java index 911092d3307..3cf98279345 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java index c498459bfb0..3c23ed5674a 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java index f028b3c2e77..fef5d600cc4 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiDelegate.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java index 911092d3307..3cf98279345 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; import org.springframework.http.ResponseEntity; diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java index 80a62f62c29..973055a2f11 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java @@ -1,8 +1,8 @@ package io.swagger.api; -import java.io.File; import io.swagger.model.ModelApiResponse; import io.swagger.model.Pet; +import org.springframework.core.io.Resource; import io.swagger.annotations.*; From b1a39ac820fa1e3920b1ff826797f6fd354921fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fouilh=C3=A9?= Date: Mon, 17 Apr 2017 18:03:52 +0200 Subject: [PATCH 06/31] fix(swift3): decoders call parents decoders too (#5369) --- .../swift3/AlamofireImplementations.mustache | 2 +- .../src/main/resources/swift3/Models.mustache | 48 +- .../Classes/Swaggers/APIs/FakeAPI.swift | 4 +- .../Classes/Swaggers/APIs/PetAPI.swift | 152 +++--- .../Classes/Swaggers/APIs/StoreAPI.swift | 60 +-- .../Classes/Swaggers/APIs/UserAPI.swift | 40 +- .../Swaggers/AlamofireImplementations.swift | 2 +- .../Classes/Swaggers/Models.swift | 471 ++++++++++-------- .../Classes/Swaggers/APIs/FakeAPI.swift | 4 +- .../Classes/Swaggers/APIs/PetAPI.swift | 152 +++--- .../Classes/Swaggers/APIs/StoreAPI.swift | 60 +-- .../Classes/Swaggers/APIs/UserAPI.swift | 40 +- .../Swaggers/AlamofireImplementations.swift | 2 +- .../Classes/Swaggers/Models.swift | 471 ++++++++++-------- .../Classes/Swaggers/APIs/FakeAPI.swift | 4 +- .../Classes/Swaggers/APIs/PetAPI.swift | 152 +++--- .../Classes/Swaggers/APIs/StoreAPI.swift | 60 +-- .../Classes/Swaggers/APIs/UserAPI.swift | 40 +- .../Swaggers/AlamofireImplementations.swift | 2 +- .../Classes/Swaggers/Models.swift | 471 ++++++++++-------- 20 files changed, 1167 insertions(+), 1070 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift3/AlamofireImplementations.mustache b/modules/swagger-codegen/src/main/resources/swift3/AlamofireImplementations.mustache index 27b86f4fb82..31dc40e1b29 100644 --- a/modules/swagger-codegen/src/main/resources/swift3/AlamofireImplementations.mustache +++ b/modules/swagger-codegen/src/main/resources/swift3/AlamofireImplementations.mustache @@ -197,7 +197,7 @@ open class AlamofireRequestBuilder: RequestBuilder { return } if let json: Any = response.result.value { - let body = Decoders.decode(clazz: T.self, source: json as AnyObject) + let body = Decoders.decode(clazz: T.self, source: json as AnyObject, instance: nil) completion(Response(response: response.response!, body: body), nil) return } else if "" is T { diff --git a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache index 19edf4da786..087559d1e6f 100644 --- a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache @@ -37,17 +37,17 @@ open class Response { private var once = Int() class Decoders { - static fileprivate var decoders = Dictionary AnyObject)>() + static fileprivate var decoders = Dictionary AnyObject)>() - static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject) -> T)) { + static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> T)) { let key = "\(T.self)" - decoders[key] = { decoder($0) as AnyObject } + decoders[key] = { decoder($0, $1) as AnyObject } } static func decode(clazz: T.Type, discriminator: String, source: AnyObject) -> T { let key = discriminator; if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, nil) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -55,19 +55,19 @@ class Decoders { static func decode(clazz: [T].Type, source: AnyObject) -> [T] { let array = source as! [AnyObject] - return array.map { Decoders.decode(clazz: T.self, source: $0) } + return array.map { Decoders.decode(clazz: T.self, source: $0, instance: nil) } } static func decode(clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { let sourceDictionary = source as! [Key: AnyObject] var dictionary = [Key:T]() for (key, value) in sourceDictionary { - dictionary[key] = Decoders.decode(clazz: T.self, source: value) + dictionary[key] = Decoders.decode(clazz: T.self, source: value, instance: nil) } return dictionary } - static func decode(clazz: T.Type, source: AnyObject) -> T { + static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T { initialize() if T.self is Int32.Type && source is NSNumber { return source.int32Value as! T; @@ -87,7 +87,7 @@ class Decoders { let key = "\(T.self)" if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, instance) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -98,7 +98,7 @@ class Decoders { return nil } return source.map { (source: AnyObject) -> T in - Decoders.decode(clazz: clazz, source: source) + Decoders.decode(clazz: clazz, source: source, instance: nil) } } @@ -134,7 +134,7 @@ class Decoders { return formatter } // Decoder for Date - Decoders.addDecoder(clazz: Date.self) { (source: AnyObject) -> Date in + Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Date in if let sourceString = source as? String { for formatter in formatters { if let date = formatter.date(from: sourceString) { @@ -150,14 +150,14 @@ class Decoders { } {{#models}}{{#model}} // Decoder for [{{{classname}}}] - Decoders.addDecoder(clazz: [{{{classname}}}].self) { (source: AnyObject) -> [{{{classname}}}] in + Decoders.addDecoder(clazz: [{{{classname}}}].self) { (source: AnyObject, instance: AnyObject?) -> [{{{classname}}}] in return Decoders.decode(clazz: [{{{classname}}}].self, source: source) } // Decoder for {{{classname}}} - Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in + Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject, instance: AnyObject?) -> {{{classname}}} in {{#isArrayModel}} let sourceArray = source as! [AnyObject] - return sourceArray.map({ Decoders.decode(clazz: {{{arrayModelType}}}.self, source: $0) }) + return sourceArray.map({ Decoders.decode(clazz: {{{arrayModelType}}}.self, source: $0, instance: nil) }) {{/isArrayModel}} {{^isArrayModel}} {{#isEnum}} @@ -185,24 +185,28 @@ class Decoders { {{/discriminator}} {{#unwrapRequired}} - let instance = {{classname}}({{#requiredVars}}{{^-first}}, {{/-first}}{{#isEnum}}{{name}}: {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as! {{datatype}}))! {{/isEnum}}{{^isEnum}}{{name}}: Decoders.decode(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]! as AnyObject){{/isEnum}}{{/requiredVars}}) + let result = {{classname}}({{#requiredVars}}{{^-first}}, {{/-first}}{{#isEnum}}{{name}}: {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as! {{datatype}}))! {{/isEnum}}{{^isEnum}}{{name}}: Decoders.decode(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]! as AnyObject, instance: nil){{/isEnum}}{{/requiredVars}}) {{#optionalVars}}{{#isEnum}} if let {{name}} = sourceDictionary["{{baseName}}"] as? {{datatype}} { {{^isContainer}} - instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: ({{name}})){{/isContainer}}{{#isListContainer}} - instance.{{name}} = {{name}}.map ({ {{classname}}.{{enumName}}(rawValue: $0)! }){{/isListContainer}} + result.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: ({{name}})){{/isContainer}}{{#isListContainer}} + result.{{name}} = {{name}}.map ({ {{classname}}.{{enumName}}(rawValue: $0)! }){{/isListContainer}} }{{/isEnum}}{{^isEnum}} - instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"] as AnyObject?){{/isEnum}} + result.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"] as AnyObject?){{/isEnum}} {{/optionalVars}} {{/unwrapRequired}} {{^unwrapRequired}} - let instance = {{classname}}(){{#allVars}}{{#isEnum}} + let result = instance == nil ? {{classname}}() : instance as! {{classname}} + {{#parent}} + _ = Decoders.decode(clazz: {{parent}}.self, source: source, instance: result) + {{/parent}} + {{#allVars}}{{#isEnum}} if let {{name}} = sourceDictionary["{{baseName}}"] as? {{datatype}} { {{^isContainer}} - instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: ({{name}})){{/isContainer}}{{#isListContainer}} - instance.{{name}} = {{name}}.map ({ {{classname}}.{{enumName}}(rawValue: $0)! }){{/isListContainer}}{{#isMapContainer}}//TODO: handle enum map scenario{{/isMapContainer}} + result.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: ({{name}})){{/isContainer}}{{#isListContainer}} + result.{{name}} = {{name}}.map ({ {{classname}}.{{enumName}}(rawValue: $0)! }){{/isListContainer}}{{#isMapContainer}}//TODO: handle enum map scenario{{/isMapContainer}} }{{/isEnum}} - {{^isEnum}}instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"] as AnyObject?){{/isEnum}}{{/allVars}} + {{^isEnum}}result.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"] as AnyObject?){{/isEnum}}{{/allVars}} {{/unwrapRequired}} - return instance + return result {{/allVars.isEmpty}} {{/isEnum}} {{/isArrayModel}} diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift index 51e54c5af34..e92730c051c 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift @@ -27,9 +27,9 @@ open class FakeAPI: APIBase { To test \"client\" model - PATCH /fake - To test \"client\" model - - examples: [{contentType=application/json, example={ + - examples: [{example={ "client" : "aeiou" -}}] +}, contentType=application/json}] - parameter body: (body) client model diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index 7378416c9c4..0ca1fa3bd7b 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -122,7 +122,7 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -131,21 +131,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -154,20 +154,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] - parameter status: (query) Status values that need to be considered for filter @@ -209,7 +209,7 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -218,21 +218,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -241,20 +241,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] - parameter tags: (query) Tags to filter by @@ -296,7 +296,7 @@ open class PetAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -305,21 +305,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example={ + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -328,20 +328,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example={ + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}] - parameter petId: (path) ID of pet to return @@ -470,11 +470,11 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example={ + - examples: [{example={ + "message" : "aeiou", "code" : 0, - "type" : "aeiou", - "message" : "aeiou" -}}] + "type" : "aeiou" +}, contentType=application/json}] - parameter petId: (path) ID of pet to update - parameter additionalMetadata: (form) Additional data to pass to server (optional) diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index f6b937da861..b57280c316f 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -65,9 +65,9 @@ open class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ + - examples: [{example={ "key" : 0 -}}] +}, contentType=application/json}] - returns: RequestBuilder<[String:Int32]> */ @@ -101,36 +101,36 @@ open class StoreAPI: APIBase { Find purchase order by ID - GET /store/order/{order_id} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] - - examples: [{contentType=application/xml, example= + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] - parameter orderId: (path) ID of pet that needs to be fetched @@ -167,36 +167,36 @@ open class StoreAPI: APIBase { Place an order for a pet - POST /store/order - - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] - - examples: [{contentType=application/xml, example= + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] - parameter body: (body) order placed for purchasing the pet diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index b07b5c89faf..65504e68683 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -168,7 +168,7 @@ open class UserAPI: APIBase { Get user by user name - GET /user/{username} - - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 aeiou aeiou @@ -177,17 +177,17 @@ open class UserAPI: APIBase { aeiou aeiou 123 -}, {contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", +, contentType=application/xml}, {example={ "id" : 0, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}] - - examples: [{contentType=application/xml, example= + "userStatus" : 6, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}] + - examples: [{example= 123456789 aeiou aeiou @@ -196,16 +196,16 @@ open class UserAPI: APIBase { aeiou aeiou 123 -}, {contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", +, contentType=application/xml}, {example={ "id" : 0, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}] + "userStatus" : 6, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -245,8 +245,8 @@ open class UserAPI: APIBase { - - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] - - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] - - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] + - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] - parameter username: (query) The user name for login - parameter password: (query) The password for login in clear text diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift index 27b86f4fb82..31dc40e1b29 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift @@ -197,7 +197,7 @@ open class AlamofireRequestBuilder: RequestBuilder { return } if let json: Any = response.result.value { - let body = Decoders.decode(clazz: T.self, source: json as AnyObject) + let body = Decoders.decode(clazz: T.self, source: json as AnyObject, instance: nil) completion(Response(response: response.response!, body: body), nil) return } else if "" is T { diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift index 68190ca646c..d2d50717ba6 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift @@ -37,17 +37,17 @@ open class Response { private var once = Int() class Decoders { - static fileprivate var decoders = Dictionary AnyObject)>() + static fileprivate var decoders = Dictionary AnyObject)>() - static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject) -> T)) { + static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> T)) { let key = "\(T.self)" - decoders[key] = { decoder($0) as AnyObject } + decoders[key] = { decoder($0, $1) as AnyObject } } static func decode(clazz: T.Type, discriminator: String, source: AnyObject) -> T { let key = discriminator; if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, nil) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -55,19 +55,19 @@ class Decoders { static func decode(clazz: [T].Type, source: AnyObject) -> [T] { let array = source as! [AnyObject] - return array.map { Decoders.decode(clazz: T.self, source: $0) } + return array.map { Decoders.decode(clazz: T.self, source: $0, instance: nil) } } static func decode(clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { let sourceDictionary = source as! [Key: AnyObject] var dictionary = [Key:T]() for (key, value) in sourceDictionary { - dictionary[key] = Decoders.decode(clazz: T.self, source: value) + dictionary[key] = Decoders.decode(clazz: T.self, source: value, instance: nil) } return dictionary } - static func decode(clazz: T.Type, source: AnyObject) -> T { + static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T { initialize() if T.self is Int32.Type && source is NSNumber { return source.int32Value as! T; @@ -87,7 +87,7 @@ class Decoders { let key = "\(T.self)" if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, instance) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -98,7 +98,7 @@ class Decoders { return nil } return source.map { (source: AnyObject) -> T in - Decoders.decode(clazz: clazz, source: source) + Decoders.decode(clazz: clazz, source: source, instance: nil) } } @@ -134,7 +134,7 @@ class Decoders { return formatter } // Decoder for Date - Decoders.addDecoder(clazz: Date.self) { (source: AnyObject) -> Date in + Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Date in if let sourceString = source as? String { for formatter in formatters { if let date = formatter.date(from: sourceString) { @@ -150,231 +150,246 @@ class Decoders { } // Decoder for [AdditionalPropertiesClass] - Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject) -> [AdditionalPropertiesClass] in + Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> [AdditionalPropertiesClass] in return Decoders.decode(clazz: [AdditionalPropertiesClass].self, source: source) } // Decoder for AdditionalPropertiesClass - Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in + Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> AdditionalPropertiesClass in let sourceDictionary = source as! [AnyHashable: Any] - let instance = AdditionalPropertiesClass() - instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?) - instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?) - return instance + let result = instance == nil ? AdditionalPropertiesClass() : instance as! AdditionalPropertiesClass + + result.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?) + result.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?) + return result } // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject) -> [Animal] in + Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject, instance: AnyObject?) -> [Animal] in return Decoders.decode(clazz: [Animal].self, source: source) } // Decoder for Animal - Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in + Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Animal in let sourceDictionary = source as! [AnyHashable: Any] // Check discriminator to support inheritance if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{ return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) } - let instance = Animal() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - return instance + let result = instance == nil ? Animal() : instance as! Animal + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + return result } // Decoder for [AnimalFarm] - Decoders.addDecoder(clazz: [AnimalFarm].self) { (source: AnyObject) -> [AnimalFarm] in + Decoders.addDecoder(clazz: [AnimalFarm].self) { (source: AnyObject, instance: AnyObject?) -> [AnimalFarm] in return Decoders.decode(clazz: [AnimalFarm].self, source: source) } // Decoder for AnimalFarm - Decoders.addDecoder(clazz: AnimalFarm.self) { (source: AnyObject) -> AnimalFarm in + Decoders.addDecoder(clazz: AnimalFarm.self) { (source: AnyObject, instance: AnyObject?) -> AnimalFarm in let sourceArray = source as! [AnyObject] - return sourceArray.map({ Decoders.decode(clazz: Animal.self, source: $0) }) + return sourceArray.map({ Decoders.decode(clazz: Animal.self, source: $0, instance: nil) }) } // Decoder for [ApiResponse] - Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject) -> [ApiResponse] in + Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject, instance: AnyObject?) -> [ApiResponse] in return Decoders.decode(clazz: [ApiResponse].self, source: source) } // Decoder for ApiResponse - Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in + Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject, instance: AnyObject?) -> ApiResponse in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ApiResponse() - instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) - instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) - instance.message = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) - return instance + let result = instance == nil ? ApiResponse() : instance as! ApiResponse + + result.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) + result.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) + result.message = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) + return result } // Decoder for [ArrayOfArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject) -> [ArrayOfArrayOfNumberOnly] in + Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayOfArrayOfNumberOnly] in return Decoders.decode(clazz: [ArrayOfArrayOfNumberOnly].self, source: source) } // Decoder for ArrayOfArrayOfNumberOnly - Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in + Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> ArrayOfArrayOfNumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayOfArrayOfNumberOnly() - instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) - return instance + let result = instance == nil ? ArrayOfArrayOfNumberOnly() : instance as! ArrayOfArrayOfNumberOnly + + result.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) + return result } // Decoder for [ArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject) -> [ArrayOfNumberOnly] in + Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayOfNumberOnly] in return Decoders.decode(clazz: [ArrayOfNumberOnly].self, source: source) } // Decoder for ArrayOfNumberOnly - Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in + Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> ArrayOfNumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayOfNumberOnly() - instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?) - return instance + let result = instance == nil ? ArrayOfNumberOnly() : instance as! ArrayOfNumberOnly + + result.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?) + return result } // Decoder for [ArrayTest] - Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject) -> [ArrayTest] in + Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayTest] in return Decoders.decode(clazz: [ArrayTest].self, source: source) } // Decoder for ArrayTest - Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in + Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject, instance: AnyObject?) -> ArrayTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayTest() - instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?) - instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) - instance.arrayArrayOfModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_model"] as AnyObject?) - return instance + let result = instance == nil ? ArrayTest() : instance as! ArrayTest + + result.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?) + result.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) + result.arrayArrayOfModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_model"] as AnyObject?) + return result } // Decoder for [Capitalization] - Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject) -> [Capitalization] in + Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject, instance: AnyObject?) -> [Capitalization] in return Decoders.decode(clazz: [Capitalization].self, source: source) } // Decoder for Capitalization - Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject) -> Capitalization in + Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject, instance: AnyObject?) -> Capitalization in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Capitalization() - instance.smallCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) - instance.capitalCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) - instance.smallSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) - instance.capitalSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) - instance.sCAETHFlowPoints = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) - instance.ATT_NAME = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) - return instance + let result = instance == nil ? Capitalization() : instance as! Capitalization + + result.smallCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) + result.capitalCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) + result.smallSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) + result.capitalSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) + result.sCAETHFlowPoints = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) + result.ATT_NAME = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) + return result } // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject) -> [Cat] in + Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject, instance: AnyObject?) -> [Cat] in return Decoders.decode(clazz: [Cat].self, source: source) } // Decoder for Cat - Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in + Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject, instance: AnyObject?) -> Cat in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Cat() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - instance.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) - return instance + let result = instance == nil ? Cat() : instance as! Cat + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + result.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) + return result } // Decoder for [Category] - Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject) -> [Category] in + Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject, instance: AnyObject?) -> [Category] in return Decoders.decode(clazz: [Category].self, source: source) } // Decoder for Category - Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in + Decoders.addDecoder(clazz: Category.self) { (source: AnyObject, instance: AnyObject?) -> Category in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Category() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - return instance + let result = instance == nil ? Category() : instance as! Category + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + return result } // Decoder for [ClassModel] - Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject) -> [ClassModel] in + Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject, instance: AnyObject?) -> [ClassModel] in return Decoders.decode(clazz: [ClassModel].self, source: source) } // Decoder for ClassModel - Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject) -> ClassModel in + Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject, instance: AnyObject?) -> ClassModel in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ClassModel() - instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) - return instance + let result = instance == nil ? ClassModel() : instance as! ClassModel + + result._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) + return result } // Decoder for [Client] - Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject) -> [Client] in + Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject, instance: AnyObject?) -> [Client] in return Decoders.decode(clazz: [Client].self, source: source) } // Decoder for Client - Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in + Decoders.addDecoder(clazz: Client.self) { (source: AnyObject, instance: AnyObject?) -> Client in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Client() - instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) - return instance + let result = instance == nil ? Client() : instance as! Client + + result.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) + return result } // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject) -> [Dog] in + Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject, instance: AnyObject?) -> [Dog] in return Decoders.decode(clazz: [Dog].self, source: source) } // Decoder for Dog - Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in + Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject, instance: AnyObject?) -> Dog in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Dog() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - instance.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) - return instance + let result = instance == nil ? Dog() : instance as! Dog + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + result.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) + return result } // Decoder for [EnumArrays] - Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject) -> [EnumArrays] in + Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject, instance: AnyObject?) -> [EnumArrays] in return Decoders.decode(clazz: [EnumArrays].self, source: source) } // Decoder for EnumArrays - Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in + Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject, instance: AnyObject?) -> EnumArrays in let sourceDictionary = source as! [AnyHashable: Any] - let instance = EnumArrays() + let result = instance == nil ? EnumArrays() : instance as! EnumArrays + if let justSymbol = sourceDictionary["just_symbol"] as? String { - instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol)) + result.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol)) } if let arrayEnum = sourceDictionary["array_enum"] as? [String] { - instance.arrayEnum = arrayEnum.map ({ EnumArrays.ArrayEnum(rawValue: $0)! }) + result.arrayEnum = arrayEnum.map ({ EnumArrays.ArrayEnum(rawValue: $0)! }) } - return instance + return result } // Decoder for [EnumClass] - Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject) -> [EnumClass] in + Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject, instance: AnyObject?) -> [EnumClass] in return Decoders.decode(clazz: [EnumClass].self, source: source) } // Decoder for EnumClass - Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject) -> EnumClass in + Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject, instance: AnyObject?) -> EnumClass in if let source = source as? String { if let result = EnumClass(rawValue: source) { return result @@ -385,193 +400,203 @@ class Decoders { // Decoder for [EnumTest] - Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject) -> [EnumTest] in + Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject, instance: AnyObject?) -> [EnumTest] in return Decoders.decode(clazz: [EnumTest].self, source: source) } // Decoder for EnumTest - Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in + Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject, instance: AnyObject?) -> EnumTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = EnumTest() + let result = instance == nil ? EnumTest() : instance as! EnumTest + if let enumString = sourceDictionary["enum_string"] as? String { - instance.enumString = EnumTest.EnumString(rawValue: (enumString)) + result.enumString = EnumTest.EnumString(rawValue: (enumString)) } if let enumInteger = sourceDictionary["enum_integer"] as? Int32 { - instance.enumInteger = EnumTest.EnumInteger(rawValue: (enumInteger)) + result.enumInteger = EnumTest.EnumInteger(rawValue: (enumInteger)) } if let enumNumber = sourceDictionary["enum_number"] as? Double { - instance.enumNumber = EnumTest.EnumNumber(rawValue: (enumNumber)) + result.enumNumber = EnumTest.EnumNumber(rawValue: (enumNumber)) } - instance.outerEnum = Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) - return instance + result.outerEnum = Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) + return result } // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject) -> [FormatTest] in + Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject, instance: AnyObject?) -> [FormatTest] in return Decoders.decode(clazz: [FormatTest].self, source: source) } // Decoder for FormatTest - Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in + Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject, instance: AnyObject?) -> FormatTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = FormatTest() - instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) - instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) - instance.int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) - instance.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"] as AnyObject?) - instance.float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) - instance.double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) - instance.string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) - instance.byte = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["byte"] as AnyObject?) - instance.binary = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) - instance.date = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["date"] as AnyObject?) - instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) - instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) - return instance + let result = instance == nil ? FormatTest() : instance as! FormatTest + + result.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) + result.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) + result.int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) + result.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"] as AnyObject?) + result.float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) + result.double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) + result.string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) + result.byte = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["byte"] as AnyObject?) + result.binary = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) + result.date = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["date"] as AnyObject?) + result.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) + result.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) + result.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) + return result } // Decoder for [HasOnlyReadOnly] - Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject) -> [HasOnlyReadOnly] in + Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject, instance: AnyObject?) -> [HasOnlyReadOnly] in return Decoders.decode(clazz: [HasOnlyReadOnly].self, source: source) } // Decoder for HasOnlyReadOnly - Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in + Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject, instance: AnyObject?) -> HasOnlyReadOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = HasOnlyReadOnly() - instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) - instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) - return instance + let result = instance == nil ? HasOnlyReadOnly() : instance as! HasOnlyReadOnly + + result.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) + result.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) + return result } // Decoder for [List] - Decoders.addDecoder(clazz: [List].self) { (source: AnyObject) -> [List] in + Decoders.addDecoder(clazz: [List].self) { (source: AnyObject, instance: AnyObject?) -> [List] in return Decoders.decode(clazz: [List].self, source: source) } // Decoder for List - Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in + Decoders.addDecoder(clazz: List.self) { (source: AnyObject, instance: AnyObject?) -> List in let sourceDictionary = source as! [AnyHashable: Any] - let instance = List() - instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) - return instance + let result = instance == nil ? List() : instance as! List + + result._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) + return result } // Decoder for [MapTest] - Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject) -> [MapTest] in + Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject, instance: AnyObject?) -> [MapTest] in return Decoders.decode(clazz: [MapTest].self, source: source) } // Decoder for MapTest - Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in + Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject, instance: AnyObject?) -> MapTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = MapTest() - instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?) + let result = instance == nil ? MapTest() : instance as! MapTest + + result.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?) if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario } - return instance + return result } // Decoder for [MixedPropertiesAndAdditionalPropertiesClass] - Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject) -> [MixedPropertiesAndAdditionalPropertiesClass] in + Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> [MixedPropertiesAndAdditionalPropertiesClass] in return Decoders.decode(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self, source: source) } // Decoder for MixedPropertiesAndAdditionalPropertiesClass - Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in + Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> MixedPropertiesAndAdditionalPropertiesClass in let sourceDictionary = source as! [AnyHashable: Any] - let instance = MixedPropertiesAndAdditionalPropertiesClass() - instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) - instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) - instance.map = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map"] as AnyObject?) - return instance + let result = instance == nil ? MixedPropertiesAndAdditionalPropertiesClass() : instance as! MixedPropertiesAndAdditionalPropertiesClass + + result.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) + result.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) + result.map = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map"] as AnyObject?) + return result } // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject) -> [Model200Response] in + Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject, instance: AnyObject?) -> [Model200Response] in return Decoders.decode(clazz: [Model200Response].self, source: source) } // Decoder for Model200Response - Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in + Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject, instance: AnyObject?) -> Model200Response in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Model200Response() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) - instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) - return instance + let result = instance == nil ? Model200Response() : instance as! Model200Response + + result.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) + result._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) + return result } // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject) -> [Name] in + Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject, instance: AnyObject?) -> [Name] in return Decoders.decode(clazz: [Name].self, source: source) } // Decoder for Name - Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in + Decoders.addDecoder(clazz: Name.self) { (source: AnyObject, instance: AnyObject?) -> Name in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Name() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) - instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) - instance.property = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) - instance._123Number = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) - return instance + let result = instance == nil ? Name() : instance as! Name + + result.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) + result.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) + result.property = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) + result._123Number = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) + return result } // Decoder for [NumberOnly] - Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject) -> [NumberOnly] in + Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [NumberOnly] in return Decoders.decode(clazz: [NumberOnly].self, source: source) } // Decoder for NumberOnly - Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in + Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> NumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = NumberOnly() - instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) - return instance + let result = instance == nil ? NumberOnly() : instance as! NumberOnly + + result.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) + return result } // Decoder for [Order] - Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in + Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject, instance: AnyObject?) -> [Order] in return Decoders.decode(clazz: [Order].self, source: source) } // Decoder for Order - Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in + Decoders.addDecoder(clazz: Order.self) { (source: AnyObject, instance: AnyObject?) -> Order in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Order() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) - instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) - instance.shipDate = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) + let result = instance == nil ? Order() : instance as! Order + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) + result.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) + result.shipDate = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) if let status = sourceDictionary["status"] as? String { - instance.status = Order.Status(rawValue: (status)) + result.status = Order.Status(rawValue: (status)) } - instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) - return instance + result.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) + return result } // Decoder for [OuterEnum] - Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject) -> [OuterEnum] in + Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject, instance: AnyObject?) -> [OuterEnum] in return Decoders.decode(clazz: [OuterEnum].self, source: source) } // Decoder for OuterEnum - Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject) -> OuterEnum in + Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject, instance: AnyObject?) -> OuterEnum in if let source = source as? String { if let result = OuterEnum(rawValue: source) { return result @@ -582,103 +607,109 @@ class Decoders { // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in + Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject, instance: AnyObject?) -> [Pet] in return Decoders.decode(clazz: [Pet].self, source: source) } // Decoder for Pet - Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in + Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject, instance: AnyObject?) -> Pet in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Pet() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"] as AnyObject?) - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"] as AnyObject?) + let result = instance == nil ? Pet() : instance as! Pet + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + result.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"] as AnyObject?) + result.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"] as AnyObject?) if let status = sourceDictionary["status"] as? String { - instance.status = Pet.Status(rawValue: (status)) + result.status = Pet.Status(rawValue: (status)) } - return instance + return result } // Decoder for [ReadOnlyFirst] - Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject) -> [ReadOnlyFirst] in + Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject, instance: AnyObject?) -> [ReadOnlyFirst] in return Decoders.decode(clazz: [ReadOnlyFirst].self, source: source) } // Decoder for ReadOnlyFirst - Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in + Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject, instance: AnyObject?) -> ReadOnlyFirst in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ReadOnlyFirst() - instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) - instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) - return instance + let result = instance == nil ? ReadOnlyFirst() : instance as! ReadOnlyFirst + + result.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) + result.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) + return result } // Decoder for [Return] - Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject) -> [Return] in + Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject, instance: AnyObject?) -> [Return] in return Decoders.decode(clazz: [Return].self, source: source) } // Decoder for Return - Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in + Decoders.addDecoder(clazz: Return.self) { (source: AnyObject, instance: AnyObject?) -> Return in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Return() - instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) - return instance + let result = instance == nil ? Return() : instance as! Return + + result._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) + return result } // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject) -> [SpecialModelName] in + Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject, instance: AnyObject?) -> [SpecialModelName] in return Decoders.decode(clazz: [SpecialModelName].self, source: source) } // Decoder for SpecialModelName - Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in + Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject, instance: AnyObject?) -> SpecialModelName in let sourceDictionary = source as! [AnyHashable: Any] - let instance = SpecialModelName() - instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) - return instance + let result = instance == nil ? SpecialModelName() : instance as! SpecialModelName + + result.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) + return result } // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in + Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject, instance: AnyObject?) -> [Tag] in return Decoders.decode(clazz: [Tag].self, source: source) } // Decoder for Tag - Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in + Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject, instance: AnyObject?) -> Tag in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Tag() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - return instance + let result = instance == nil ? Tag() : instance as! Tag + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + return result } // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in + Decoders.addDecoder(clazz: [User].self) { (source: AnyObject, instance: AnyObject?) -> [User] in return Decoders.decode(clazz: [User].self, source: source) } // Decoder for User - Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in + Decoders.addDecoder(clazz: User.self) { (source: AnyObject, instance: AnyObject?) -> User in let sourceDictionary = source as! [AnyHashable: Any] - let instance = User() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) - instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) - instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) - instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) - instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) - instance.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) - return instance + let result = instance == nil ? User() : instance as! User + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) + result.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) + result.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) + result.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) + result.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) + result.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) + result.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) + return result } }() diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift index 3847ae1dc6a..13d6c4a48e3 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift @@ -45,9 +45,9 @@ open class FakeAPI: APIBase { To test \"client\" model - PATCH /fake - To test \"client\" model - - examples: [{contentType=application/json, example={ + - examples: [{example={ "client" : "aeiou" -}}] +}, contentType=application/json}] - parameter body: (body) client model diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index c1dbe4ed14a..d819427804e 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -175,7 +175,7 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -184,21 +184,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -207,20 +207,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] - parameter status: (query) Status values that need to be considered for filter @@ -279,7 +279,7 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -288,21 +288,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -311,20 +311,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] - parameter tags: (query) Tags to filter by @@ -383,7 +383,7 @@ open class PetAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -392,21 +392,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example={ + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -415,20 +415,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example={ + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}] - parameter petId: (path) ID of pet to return @@ -612,11 +612,11 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example={ + - examples: [{example={ + "message" : "aeiou", "code" : 0, - "type" : "aeiou", - "message" : "aeiou" -}}] + "type" : "aeiou" +}, contentType=application/json}] - parameter petId: (path) ID of pet to update - parameter additionalMetadata: (form) Additional data to pass to server (optional) diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index 369138f1d01..8ade6fbdbaf 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -99,9 +99,9 @@ open class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ + - examples: [{example={ "key" : 0 -}}] +}, contentType=application/json}] - returns: RequestBuilder<[String:Int32]> */ @@ -152,36 +152,36 @@ open class StoreAPI: APIBase { Find purchase order by ID - GET /store/order/{order_id} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] - - examples: [{contentType=application/xml, example= + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] - parameter orderId: (path) ID of pet that needs to be fetched @@ -235,36 +235,36 @@ open class StoreAPI: APIBase { Place an order for a pet - POST /store/order - - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] - - examples: [{contentType=application/xml, example= + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] - parameter body: (body) order placed for purchasing the pet diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index 9530e6edb81..b033c56824f 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -254,7 +254,7 @@ open class UserAPI: APIBase { Get user by user name - GET /user/{username} - - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 aeiou aeiou @@ -263,17 +263,17 @@ open class UserAPI: APIBase { aeiou aeiou 123 -}, {contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", +, contentType=application/xml}, {example={ "id" : 0, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}] - - examples: [{contentType=application/xml, example= + "userStatus" : 6, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}] + - examples: [{example= 123456789 aeiou aeiou @@ -282,16 +282,16 @@ open class UserAPI: APIBase { aeiou aeiou 123 -}, {contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", +, contentType=application/xml}, {example={ "id" : 0, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}] + "userStatus" : 6, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -349,8 +349,8 @@ open class UserAPI: APIBase { - - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] - - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] - - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] + - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] - parameter username: (query) The user name for login - parameter password: (query) The password for login in clear text diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift index 27b86f4fb82..31dc40e1b29 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift @@ -197,7 +197,7 @@ open class AlamofireRequestBuilder: RequestBuilder { return } if let json: Any = response.result.value { - let body = Decoders.decode(clazz: T.self, source: json as AnyObject) + let body = Decoders.decode(clazz: T.self, source: json as AnyObject, instance: nil) completion(Response(response: response.response!, body: body), nil) return } else if "" is T { diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift index 68190ca646c..d2d50717ba6 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift @@ -37,17 +37,17 @@ open class Response { private var once = Int() class Decoders { - static fileprivate var decoders = Dictionary AnyObject)>() + static fileprivate var decoders = Dictionary AnyObject)>() - static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject) -> T)) { + static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> T)) { let key = "\(T.self)" - decoders[key] = { decoder($0) as AnyObject } + decoders[key] = { decoder($0, $1) as AnyObject } } static func decode(clazz: T.Type, discriminator: String, source: AnyObject) -> T { let key = discriminator; if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, nil) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -55,19 +55,19 @@ class Decoders { static func decode(clazz: [T].Type, source: AnyObject) -> [T] { let array = source as! [AnyObject] - return array.map { Decoders.decode(clazz: T.self, source: $0) } + return array.map { Decoders.decode(clazz: T.self, source: $0, instance: nil) } } static func decode(clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { let sourceDictionary = source as! [Key: AnyObject] var dictionary = [Key:T]() for (key, value) in sourceDictionary { - dictionary[key] = Decoders.decode(clazz: T.self, source: value) + dictionary[key] = Decoders.decode(clazz: T.self, source: value, instance: nil) } return dictionary } - static func decode(clazz: T.Type, source: AnyObject) -> T { + static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T { initialize() if T.self is Int32.Type && source is NSNumber { return source.int32Value as! T; @@ -87,7 +87,7 @@ class Decoders { let key = "\(T.self)" if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, instance) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -98,7 +98,7 @@ class Decoders { return nil } return source.map { (source: AnyObject) -> T in - Decoders.decode(clazz: clazz, source: source) + Decoders.decode(clazz: clazz, source: source, instance: nil) } } @@ -134,7 +134,7 @@ class Decoders { return formatter } // Decoder for Date - Decoders.addDecoder(clazz: Date.self) { (source: AnyObject) -> Date in + Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Date in if let sourceString = source as? String { for formatter in formatters { if let date = formatter.date(from: sourceString) { @@ -150,231 +150,246 @@ class Decoders { } // Decoder for [AdditionalPropertiesClass] - Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject) -> [AdditionalPropertiesClass] in + Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> [AdditionalPropertiesClass] in return Decoders.decode(clazz: [AdditionalPropertiesClass].self, source: source) } // Decoder for AdditionalPropertiesClass - Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in + Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> AdditionalPropertiesClass in let sourceDictionary = source as! [AnyHashable: Any] - let instance = AdditionalPropertiesClass() - instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?) - instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?) - return instance + let result = instance == nil ? AdditionalPropertiesClass() : instance as! AdditionalPropertiesClass + + result.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?) + result.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?) + return result } // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject) -> [Animal] in + Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject, instance: AnyObject?) -> [Animal] in return Decoders.decode(clazz: [Animal].self, source: source) } // Decoder for Animal - Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in + Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Animal in let sourceDictionary = source as! [AnyHashable: Any] // Check discriminator to support inheritance if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{ return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) } - let instance = Animal() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - return instance + let result = instance == nil ? Animal() : instance as! Animal + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + return result } // Decoder for [AnimalFarm] - Decoders.addDecoder(clazz: [AnimalFarm].self) { (source: AnyObject) -> [AnimalFarm] in + Decoders.addDecoder(clazz: [AnimalFarm].self) { (source: AnyObject, instance: AnyObject?) -> [AnimalFarm] in return Decoders.decode(clazz: [AnimalFarm].self, source: source) } // Decoder for AnimalFarm - Decoders.addDecoder(clazz: AnimalFarm.self) { (source: AnyObject) -> AnimalFarm in + Decoders.addDecoder(clazz: AnimalFarm.self) { (source: AnyObject, instance: AnyObject?) -> AnimalFarm in let sourceArray = source as! [AnyObject] - return sourceArray.map({ Decoders.decode(clazz: Animal.self, source: $0) }) + return sourceArray.map({ Decoders.decode(clazz: Animal.self, source: $0, instance: nil) }) } // Decoder for [ApiResponse] - Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject) -> [ApiResponse] in + Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject, instance: AnyObject?) -> [ApiResponse] in return Decoders.decode(clazz: [ApiResponse].self, source: source) } // Decoder for ApiResponse - Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in + Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject, instance: AnyObject?) -> ApiResponse in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ApiResponse() - instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) - instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) - instance.message = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) - return instance + let result = instance == nil ? ApiResponse() : instance as! ApiResponse + + result.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) + result.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) + result.message = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) + return result } // Decoder for [ArrayOfArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject) -> [ArrayOfArrayOfNumberOnly] in + Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayOfArrayOfNumberOnly] in return Decoders.decode(clazz: [ArrayOfArrayOfNumberOnly].self, source: source) } // Decoder for ArrayOfArrayOfNumberOnly - Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in + Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> ArrayOfArrayOfNumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayOfArrayOfNumberOnly() - instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) - return instance + let result = instance == nil ? ArrayOfArrayOfNumberOnly() : instance as! ArrayOfArrayOfNumberOnly + + result.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) + return result } // Decoder for [ArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject) -> [ArrayOfNumberOnly] in + Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayOfNumberOnly] in return Decoders.decode(clazz: [ArrayOfNumberOnly].self, source: source) } // Decoder for ArrayOfNumberOnly - Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in + Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> ArrayOfNumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayOfNumberOnly() - instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?) - return instance + let result = instance == nil ? ArrayOfNumberOnly() : instance as! ArrayOfNumberOnly + + result.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?) + return result } // Decoder for [ArrayTest] - Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject) -> [ArrayTest] in + Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayTest] in return Decoders.decode(clazz: [ArrayTest].self, source: source) } // Decoder for ArrayTest - Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in + Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject, instance: AnyObject?) -> ArrayTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayTest() - instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?) - instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) - instance.arrayArrayOfModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_model"] as AnyObject?) - return instance + let result = instance == nil ? ArrayTest() : instance as! ArrayTest + + result.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?) + result.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) + result.arrayArrayOfModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_model"] as AnyObject?) + return result } // Decoder for [Capitalization] - Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject) -> [Capitalization] in + Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject, instance: AnyObject?) -> [Capitalization] in return Decoders.decode(clazz: [Capitalization].self, source: source) } // Decoder for Capitalization - Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject) -> Capitalization in + Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject, instance: AnyObject?) -> Capitalization in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Capitalization() - instance.smallCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) - instance.capitalCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) - instance.smallSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) - instance.capitalSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) - instance.sCAETHFlowPoints = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) - instance.ATT_NAME = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) - return instance + let result = instance == nil ? Capitalization() : instance as! Capitalization + + result.smallCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) + result.capitalCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) + result.smallSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) + result.capitalSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) + result.sCAETHFlowPoints = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) + result.ATT_NAME = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) + return result } // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject) -> [Cat] in + Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject, instance: AnyObject?) -> [Cat] in return Decoders.decode(clazz: [Cat].self, source: source) } // Decoder for Cat - Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in + Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject, instance: AnyObject?) -> Cat in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Cat() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - instance.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) - return instance + let result = instance == nil ? Cat() : instance as! Cat + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + result.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) + return result } // Decoder for [Category] - Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject) -> [Category] in + Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject, instance: AnyObject?) -> [Category] in return Decoders.decode(clazz: [Category].self, source: source) } // Decoder for Category - Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in + Decoders.addDecoder(clazz: Category.self) { (source: AnyObject, instance: AnyObject?) -> Category in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Category() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - return instance + let result = instance == nil ? Category() : instance as! Category + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + return result } // Decoder for [ClassModel] - Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject) -> [ClassModel] in + Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject, instance: AnyObject?) -> [ClassModel] in return Decoders.decode(clazz: [ClassModel].self, source: source) } // Decoder for ClassModel - Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject) -> ClassModel in + Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject, instance: AnyObject?) -> ClassModel in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ClassModel() - instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) - return instance + let result = instance == nil ? ClassModel() : instance as! ClassModel + + result._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) + return result } // Decoder for [Client] - Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject) -> [Client] in + Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject, instance: AnyObject?) -> [Client] in return Decoders.decode(clazz: [Client].self, source: source) } // Decoder for Client - Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in + Decoders.addDecoder(clazz: Client.self) { (source: AnyObject, instance: AnyObject?) -> Client in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Client() - instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) - return instance + let result = instance == nil ? Client() : instance as! Client + + result.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) + return result } // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject) -> [Dog] in + Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject, instance: AnyObject?) -> [Dog] in return Decoders.decode(clazz: [Dog].self, source: source) } // Decoder for Dog - Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in + Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject, instance: AnyObject?) -> Dog in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Dog() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - instance.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) - return instance + let result = instance == nil ? Dog() : instance as! Dog + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + result.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) + return result } // Decoder for [EnumArrays] - Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject) -> [EnumArrays] in + Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject, instance: AnyObject?) -> [EnumArrays] in return Decoders.decode(clazz: [EnumArrays].self, source: source) } // Decoder for EnumArrays - Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in + Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject, instance: AnyObject?) -> EnumArrays in let sourceDictionary = source as! [AnyHashable: Any] - let instance = EnumArrays() + let result = instance == nil ? EnumArrays() : instance as! EnumArrays + if let justSymbol = sourceDictionary["just_symbol"] as? String { - instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol)) + result.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol)) } if let arrayEnum = sourceDictionary["array_enum"] as? [String] { - instance.arrayEnum = arrayEnum.map ({ EnumArrays.ArrayEnum(rawValue: $0)! }) + result.arrayEnum = arrayEnum.map ({ EnumArrays.ArrayEnum(rawValue: $0)! }) } - return instance + return result } // Decoder for [EnumClass] - Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject) -> [EnumClass] in + Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject, instance: AnyObject?) -> [EnumClass] in return Decoders.decode(clazz: [EnumClass].self, source: source) } // Decoder for EnumClass - Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject) -> EnumClass in + Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject, instance: AnyObject?) -> EnumClass in if let source = source as? String { if let result = EnumClass(rawValue: source) { return result @@ -385,193 +400,203 @@ class Decoders { // Decoder for [EnumTest] - Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject) -> [EnumTest] in + Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject, instance: AnyObject?) -> [EnumTest] in return Decoders.decode(clazz: [EnumTest].self, source: source) } // Decoder for EnumTest - Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in + Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject, instance: AnyObject?) -> EnumTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = EnumTest() + let result = instance == nil ? EnumTest() : instance as! EnumTest + if let enumString = sourceDictionary["enum_string"] as? String { - instance.enumString = EnumTest.EnumString(rawValue: (enumString)) + result.enumString = EnumTest.EnumString(rawValue: (enumString)) } if let enumInteger = sourceDictionary["enum_integer"] as? Int32 { - instance.enumInteger = EnumTest.EnumInteger(rawValue: (enumInteger)) + result.enumInteger = EnumTest.EnumInteger(rawValue: (enumInteger)) } if let enumNumber = sourceDictionary["enum_number"] as? Double { - instance.enumNumber = EnumTest.EnumNumber(rawValue: (enumNumber)) + result.enumNumber = EnumTest.EnumNumber(rawValue: (enumNumber)) } - instance.outerEnum = Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) - return instance + result.outerEnum = Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) + return result } // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject) -> [FormatTest] in + Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject, instance: AnyObject?) -> [FormatTest] in return Decoders.decode(clazz: [FormatTest].self, source: source) } // Decoder for FormatTest - Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in + Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject, instance: AnyObject?) -> FormatTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = FormatTest() - instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) - instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) - instance.int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) - instance.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"] as AnyObject?) - instance.float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) - instance.double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) - instance.string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) - instance.byte = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["byte"] as AnyObject?) - instance.binary = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) - instance.date = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["date"] as AnyObject?) - instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) - instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) - return instance + let result = instance == nil ? FormatTest() : instance as! FormatTest + + result.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) + result.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) + result.int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) + result.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"] as AnyObject?) + result.float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) + result.double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) + result.string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) + result.byte = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["byte"] as AnyObject?) + result.binary = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) + result.date = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["date"] as AnyObject?) + result.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) + result.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) + result.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) + return result } // Decoder for [HasOnlyReadOnly] - Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject) -> [HasOnlyReadOnly] in + Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject, instance: AnyObject?) -> [HasOnlyReadOnly] in return Decoders.decode(clazz: [HasOnlyReadOnly].self, source: source) } // Decoder for HasOnlyReadOnly - Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in + Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject, instance: AnyObject?) -> HasOnlyReadOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = HasOnlyReadOnly() - instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) - instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) - return instance + let result = instance == nil ? HasOnlyReadOnly() : instance as! HasOnlyReadOnly + + result.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) + result.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) + return result } // Decoder for [List] - Decoders.addDecoder(clazz: [List].self) { (source: AnyObject) -> [List] in + Decoders.addDecoder(clazz: [List].self) { (source: AnyObject, instance: AnyObject?) -> [List] in return Decoders.decode(clazz: [List].self, source: source) } // Decoder for List - Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in + Decoders.addDecoder(clazz: List.self) { (source: AnyObject, instance: AnyObject?) -> List in let sourceDictionary = source as! [AnyHashable: Any] - let instance = List() - instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) - return instance + let result = instance == nil ? List() : instance as! List + + result._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) + return result } // Decoder for [MapTest] - Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject) -> [MapTest] in + Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject, instance: AnyObject?) -> [MapTest] in return Decoders.decode(clazz: [MapTest].self, source: source) } // Decoder for MapTest - Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in + Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject, instance: AnyObject?) -> MapTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = MapTest() - instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?) + let result = instance == nil ? MapTest() : instance as! MapTest + + result.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?) if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario } - return instance + return result } // Decoder for [MixedPropertiesAndAdditionalPropertiesClass] - Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject) -> [MixedPropertiesAndAdditionalPropertiesClass] in + Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> [MixedPropertiesAndAdditionalPropertiesClass] in return Decoders.decode(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self, source: source) } // Decoder for MixedPropertiesAndAdditionalPropertiesClass - Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in + Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> MixedPropertiesAndAdditionalPropertiesClass in let sourceDictionary = source as! [AnyHashable: Any] - let instance = MixedPropertiesAndAdditionalPropertiesClass() - instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) - instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) - instance.map = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map"] as AnyObject?) - return instance + let result = instance == nil ? MixedPropertiesAndAdditionalPropertiesClass() : instance as! MixedPropertiesAndAdditionalPropertiesClass + + result.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) + result.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) + result.map = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map"] as AnyObject?) + return result } // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject) -> [Model200Response] in + Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject, instance: AnyObject?) -> [Model200Response] in return Decoders.decode(clazz: [Model200Response].self, source: source) } // Decoder for Model200Response - Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in + Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject, instance: AnyObject?) -> Model200Response in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Model200Response() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) - instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) - return instance + let result = instance == nil ? Model200Response() : instance as! Model200Response + + result.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) + result._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) + return result } // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject) -> [Name] in + Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject, instance: AnyObject?) -> [Name] in return Decoders.decode(clazz: [Name].self, source: source) } // Decoder for Name - Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in + Decoders.addDecoder(clazz: Name.self) { (source: AnyObject, instance: AnyObject?) -> Name in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Name() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) - instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) - instance.property = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) - instance._123Number = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) - return instance + let result = instance == nil ? Name() : instance as! Name + + result.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) + result.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) + result.property = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) + result._123Number = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) + return result } // Decoder for [NumberOnly] - Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject) -> [NumberOnly] in + Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [NumberOnly] in return Decoders.decode(clazz: [NumberOnly].self, source: source) } // Decoder for NumberOnly - Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in + Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> NumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = NumberOnly() - instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) - return instance + let result = instance == nil ? NumberOnly() : instance as! NumberOnly + + result.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) + return result } // Decoder for [Order] - Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in + Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject, instance: AnyObject?) -> [Order] in return Decoders.decode(clazz: [Order].self, source: source) } // Decoder for Order - Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in + Decoders.addDecoder(clazz: Order.self) { (source: AnyObject, instance: AnyObject?) -> Order in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Order() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) - instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) - instance.shipDate = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) + let result = instance == nil ? Order() : instance as! Order + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) + result.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) + result.shipDate = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) if let status = sourceDictionary["status"] as? String { - instance.status = Order.Status(rawValue: (status)) + result.status = Order.Status(rawValue: (status)) } - instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) - return instance + result.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) + return result } // Decoder for [OuterEnum] - Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject) -> [OuterEnum] in + Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject, instance: AnyObject?) -> [OuterEnum] in return Decoders.decode(clazz: [OuterEnum].self, source: source) } // Decoder for OuterEnum - Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject) -> OuterEnum in + Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject, instance: AnyObject?) -> OuterEnum in if let source = source as? String { if let result = OuterEnum(rawValue: source) { return result @@ -582,103 +607,109 @@ class Decoders { // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in + Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject, instance: AnyObject?) -> [Pet] in return Decoders.decode(clazz: [Pet].self, source: source) } // Decoder for Pet - Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in + Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject, instance: AnyObject?) -> Pet in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Pet() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"] as AnyObject?) - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"] as AnyObject?) + let result = instance == nil ? Pet() : instance as! Pet + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + result.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"] as AnyObject?) + result.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"] as AnyObject?) if let status = sourceDictionary["status"] as? String { - instance.status = Pet.Status(rawValue: (status)) + result.status = Pet.Status(rawValue: (status)) } - return instance + return result } // Decoder for [ReadOnlyFirst] - Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject) -> [ReadOnlyFirst] in + Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject, instance: AnyObject?) -> [ReadOnlyFirst] in return Decoders.decode(clazz: [ReadOnlyFirst].self, source: source) } // Decoder for ReadOnlyFirst - Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in + Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject, instance: AnyObject?) -> ReadOnlyFirst in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ReadOnlyFirst() - instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) - instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) - return instance + let result = instance == nil ? ReadOnlyFirst() : instance as! ReadOnlyFirst + + result.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) + result.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) + return result } // Decoder for [Return] - Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject) -> [Return] in + Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject, instance: AnyObject?) -> [Return] in return Decoders.decode(clazz: [Return].self, source: source) } // Decoder for Return - Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in + Decoders.addDecoder(clazz: Return.self) { (source: AnyObject, instance: AnyObject?) -> Return in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Return() - instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) - return instance + let result = instance == nil ? Return() : instance as! Return + + result._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) + return result } // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject) -> [SpecialModelName] in + Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject, instance: AnyObject?) -> [SpecialModelName] in return Decoders.decode(clazz: [SpecialModelName].self, source: source) } // Decoder for SpecialModelName - Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in + Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject, instance: AnyObject?) -> SpecialModelName in let sourceDictionary = source as! [AnyHashable: Any] - let instance = SpecialModelName() - instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) - return instance + let result = instance == nil ? SpecialModelName() : instance as! SpecialModelName + + result.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) + return result } // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in + Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject, instance: AnyObject?) -> [Tag] in return Decoders.decode(clazz: [Tag].self, source: source) } // Decoder for Tag - Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in + Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject, instance: AnyObject?) -> Tag in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Tag() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - return instance + let result = instance == nil ? Tag() : instance as! Tag + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + return result } // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in + Decoders.addDecoder(clazz: [User].self) { (source: AnyObject, instance: AnyObject?) -> [User] in return Decoders.decode(clazz: [User].self, source: source) } // Decoder for User - Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in + Decoders.addDecoder(clazz: User.self) { (source: AnyObject, instance: AnyObject?) -> User in let sourceDictionary = source as! [AnyHashable: Any] - let instance = User() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) - instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) - instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) - instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) - instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) - instance.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) - return instance + let result = instance == nil ? User() : instance as! User + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) + result.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) + result.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) + result.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) + result.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) + result.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) + result.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) + return result } }() diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift index 976fa6cc0da..621d44c387d 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift @@ -47,9 +47,9 @@ open class FakeAPI: APIBase { To test \"client\" model - PATCH /fake - To test \"client\" model - - examples: [{contentType=application/json, example={ + - examples: [{example={ "client" : "aeiou" -}}] +}, contentType=application/json}] - parameter body: (body) client model diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index 524ed037b61..52fd5a75647 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -181,7 +181,7 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -190,21 +190,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -213,20 +213,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] - parameter status: (query) Status values that need to be considered for filter @@ -287,7 +287,7 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -296,21 +296,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -319,20 +319,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example=[ { + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}] - parameter tags: (query) Tags to filter by @@ -393,7 +393,7 @@ open class PetAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 doggie @@ -402,21 +402,21 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example={ + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}}] - - examples: [{contentType=application/xml, example= + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}] + - examples: [{example= 123456789 doggie @@ -425,20 +425,20 @@ open class PetAPI: APIBase { aeiou -}, {contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}, {example={ + "tags" : [ { + "id" : 1, + "name" : "aeiou" + } ], "id" : 0, "category" : { - "name" : "aeiou", - "id" : 6 + "id" : 6, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}}] + "status" : "available", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}] - parameter petId: (path) ID of pet to return @@ -628,11 +628,11 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example={ + - examples: [{example={ + "message" : "aeiou", "code" : 0, - "type" : "aeiou", - "message" : "aeiou" -}}] + "type" : "aeiou" +}, contentType=application/json}] - parameter petId: (path) ID of pet to update - parameter additionalMetadata: (form) Additional data to pass to server (optional) diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index 5177e56f53c..2e899508dfb 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -103,9 +103,9 @@ open class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ + - examples: [{example={ "key" : 0 -}}] +}, contentType=application/json}] - returns: RequestBuilder<[String:Int32]> */ @@ -158,36 +158,36 @@ open class StoreAPI: APIBase { Find purchase order by ID - GET /store/order/{order_id} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] - - examples: [{contentType=application/xml, example= + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] - parameter orderId: (path) ID of pet that needs to be fetched @@ -243,36 +243,36 @@ open class StoreAPI: APIBase { Place an order for a pet - POST /store/order - - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] - - examples: [{contentType=application/xml, example= + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] + - examples: [{example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -}, {contentType=application/json, example={ - "petId" : 6, - "quantity" : 1, +, contentType=application/xml}, {example={ "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", + "petId" : 6, "complete" : false, - "status" : "placed" -}}] + "status" : "placed", + "quantity" : 1, + "shipDate" : "2000-01-23T04:56:07.000+00:00" +}, contentType=application/json}] - parameter body: (body) order placed for purchasing the pet diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index 1b7ce47f4ae..3e355b15f0f 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -264,7 +264,7 @@ open class UserAPI: APIBase { Get user by user name - GET /user/{username} - - - examples: [{contentType=application/xml, example= + - examples: [{example= 123456789 aeiou aeiou @@ -273,17 +273,17 @@ open class UserAPI: APIBase { aeiou aeiou 123 -}, {contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", +, contentType=application/xml}, {example={ "id" : 0, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}] - - examples: [{contentType=application/xml, example= + "userStatus" : 6, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}] + - examples: [{example= 123456789 aeiou aeiou @@ -292,16 +292,16 @@ open class UserAPI: APIBase { aeiou aeiou 123 -}, {contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", +, contentType=application/xml}, {example={ "id" : 0, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}] + "userStatus" : 6, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -361,8 +361,8 @@ open class UserAPI: APIBase { - - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] - responseHeaders: [X-Rate-Limit(Int32), X-Expires-After(Date)] - - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] - - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] + - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] - parameter username: (query) The user name for login - parameter password: (query) The password for login in clear text diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift index 27b86f4fb82..31dc40e1b29 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift @@ -197,7 +197,7 @@ open class AlamofireRequestBuilder: RequestBuilder { return } if let json: Any = response.result.value { - let body = Decoders.decode(clazz: T.self, source: json as AnyObject) + let body = Decoders.decode(clazz: T.self, source: json as AnyObject, instance: nil) completion(Response(response: response.response!, body: body), nil) return } else if "" is T { diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift index 68190ca646c..d2d50717ba6 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift @@ -37,17 +37,17 @@ open class Response { private var once = Int() class Decoders { - static fileprivate var decoders = Dictionary AnyObject)>() + static fileprivate var decoders = Dictionary AnyObject)>() - static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject) -> T)) { + static func addDecoder(clazz: T.Type, decoder: @escaping ((AnyObject, AnyObject?) -> T)) { let key = "\(T.self)" - decoders[key] = { decoder($0) as AnyObject } + decoders[key] = { decoder($0, $1) as AnyObject } } static func decode(clazz: T.Type, discriminator: String, source: AnyObject) -> T { let key = discriminator; if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, nil) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -55,19 +55,19 @@ class Decoders { static func decode(clazz: [T].Type, source: AnyObject) -> [T] { let array = source as! [AnyObject] - return array.map { Decoders.decode(clazz: T.self, source: $0) } + return array.map { Decoders.decode(clazz: T.self, source: $0, instance: nil) } } static func decode(clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { let sourceDictionary = source as! [Key: AnyObject] var dictionary = [Key:T]() for (key, value) in sourceDictionary { - dictionary[key] = Decoders.decode(clazz: T.self, source: value) + dictionary[key] = Decoders.decode(clazz: T.self, source: value, instance: nil) } return dictionary } - static func decode(clazz: T.Type, source: AnyObject) -> T { + static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T { initialize() if T.self is Int32.Type && source is NSNumber { return source.int32Value as! T; @@ -87,7 +87,7 @@ class Decoders { let key = "\(T.self)" if let decoder = decoders[key] { - return decoder(source) as! T + return decoder(source, instance) as! T } else { fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") } @@ -98,7 +98,7 @@ class Decoders { return nil } return source.map { (source: AnyObject) -> T in - Decoders.decode(clazz: clazz, source: source) + Decoders.decode(clazz: clazz, source: source, instance: nil) } } @@ -134,7 +134,7 @@ class Decoders { return formatter } // Decoder for Date - Decoders.addDecoder(clazz: Date.self) { (source: AnyObject) -> Date in + Decoders.addDecoder(clazz: Date.self) { (source: AnyObject, instance: AnyObject?) -> Date in if let sourceString = source as? String { for formatter in formatters { if let date = formatter.date(from: sourceString) { @@ -150,231 +150,246 @@ class Decoders { } // Decoder for [AdditionalPropertiesClass] - Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject) -> [AdditionalPropertiesClass] in + Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> [AdditionalPropertiesClass] in return Decoders.decode(clazz: [AdditionalPropertiesClass].self, source: source) } // Decoder for AdditionalPropertiesClass - Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject) -> AdditionalPropertiesClass in + Decoders.addDecoder(clazz: AdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> AdditionalPropertiesClass in let sourceDictionary = source as! [AnyHashable: Any] - let instance = AdditionalPropertiesClass() - instance.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?) - instance.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?) - return instance + let result = instance == nil ? AdditionalPropertiesClass() : instance as! AdditionalPropertiesClass + + result.mapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_property"] as AnyObject?) + result.mapOfMapProperty = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_of_map_property"] as AnyObject?) + return result } // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject) -> [Animal] in + Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject, instance: AnyObject?) -> [Animal] in return Decoders.decode(clazz: [Animal].self, source: source) } // Decoder for Animal - Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in + Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Animal in let sourceDictionary = source as! [AnyHashable: Any] // Check discriminator to support inheritance if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{ return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) } - let instance = Animal() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - return instance + let result = instance == nil ? Animal() : instance as! Animal + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + return result } // Decoder for [AnimalFarm] - Decoders.addDecoder(clazz: [AnimalFarm].self) { (source: AnyObject) -> [AnimalFarm] in + Decoders.addDecoder(clazz: [AnimalFarm].self) { (source: AnyObject, instance: AnyObject?) -> [AnimalFarm] in return Decoders.decode(clazz: [AnimalFarm].self, source: source) } // Decoder for AnimalFarm - Decoders.addDecoder(clazz: AnimalFarm.self) { (source: AnyObject) -> AnimalFarm in + Decoders.addDecoder(clazz: AnimalFarm.self) { (source: AnyObject, instance: AnyObject?) -> AnimalFarm in let sourceArray = source as! [AnyObject] - return sourceArray.map({ Decoders.decode(clazz: Animal.self, source: $0) }) + return sourceArray.map({ Decoders.decode(clazz: Animal.self, source: $0, instance: nil) }) } // Decoder for [ApiResponse] - Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject) -> [ApiResponse] in + Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject, instance: AnyObject?) -> [ApiResponse] in return Decoders.decode(clazz: [ApiResponse].self, source: source) } // Decoder for ApiResponse - Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject) -> ApiResponse in + Decoders.addDecoder(clazz: ApiResponse.self) { (source: AnyObject, instance: AnyObject?) -> ApiResponse in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ApiResponse() - instance.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) - instance.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) - instance.message = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) - return instance + let result = instance == nil ? ApiResponse() : instance as! ApiResponse + + result.code = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["code"] as AnyObject?) + result.type = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["type"] as AnyObject?) + result.message = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["message"] as AnyObject?) + return result } // Decoder for [ArrayOfArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject) -> [ArrayOfArrayOfNumberOnly] in + Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayOfArrayOfNumberOnly] in return Decoders.decode(clazz: [ArrayOfArrayOfNumberOnly].self, source: source) } // Decoder for ArrayOfArrayOfNumberOnly - Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfArrayOfNumberOnly in + Decoders.addDecoder(clazz: ArrayOfArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> ArrayOfArrayOfNumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayOfArrayOfNumberOnly() - instance.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) - return instance + let result = instance == nil ? ArrayOfArrayOfNumberOnly() : instance as! ArrayOfArrayOfNumberOnly + + result.arrayArrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayArrayNumber"] as AnyObject?) + return result } // Decoder for [ArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject) -> [ArrayOfNumberOnly] in + Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayOfNumberOnly] in return Decoders.decode(clazz: [ArrayOfNumberOnly].self, source: source) } // Decoder for ArrayOfNumberOnly - Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject) -> ArrayOfNumberOnly in + Decoders.addDecoder(clazz: ArrayOfNumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> ArrayOfNumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayOfNumberOnly() - instance.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?) - return instance + let result = instance == nil ? ArrayOfNumberOnly() : instance as! ArrayOfNumberOnly + + result.arrayNumber = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["ArrayNumber"] as AnyObject?) + return result } // Decoder for [ArrayTest] - Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject) -> [ArrayTest] in + Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject, instance: AnyObject?) -> [ArrayTest] in return Decoders.decode(clazz: [ArrayTest].self, source: source) } // Decoder for ArrayTest - Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject) -> ArrayTest in + Decoders.addDecoder(clazz: ArrayTest.self) { (source: AnyObject, instance: AnyObject?) -> ArrayTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ArrayTest() - instance.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?) - instance.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) - instance.arrayArrayOfModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_model"] as AnyObject?) - return instance + let result = instance == nil ? ArrayTest() : instance as! ArrayTest + + result.arrayOfString = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_of_string"] as AnyObject?) + result.arrayArrayOfInteger = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_integer"] as AnyObject?) + result.arrayArrayOfModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["array_array_of_model"] as AnyObject?) + return result } // Decoder for [Capitalization] - Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject) -> [Capitalization] in + Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject, instance: AnyObject?) -> [Capitalization] in return Decoders.decode(clazz: [Capitalization].self, source: source) } // Decoder for Capitalization - Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject) -> Capitalization in + Decoders.addDecoder(clazz: Capitalization.self) { (source: AnyObject, instance: AnyObject?) -> Capitalization in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Capitalization() - instance.smallCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) - instance.capitalCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) - instance.smallSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) - instance.capitalSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) - instance.sCAETHFlowPoints = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) - instance.ATT_NAME = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) - return instance + let result = instance == nil ? Capitalization() : instance as! Capitalization + + result.smallCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["smallCamel"] as AnyObject?) + result.capitalCamel = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["CapitalCamel"] as AnyObject?) + result.smallSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["small_Snake"] as AnyObject?) + result.capitalSnake = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["Capital_Snake"] as AnyObject?) + result.sCAETHFlowPoints = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["SCA_ETH_Flow_Points"] as AnyObject?) + result.ATT_NAME = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["ATT_NAME"] as AnyObject?) + return result } // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject) -> [Cat] in + Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject, instance: AnyObject?) -> [Cat] in return Decoders.decode(clazz: [Cat].self, source: source) } // Decoder for Cat - Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in + Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject, instance: AnyObject?) -> Cat in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Cat() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - instance.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) - return instance + let result = instance == nil ? Cat() : instance as! Cat + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + result.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"] as AnyObject?) + return result } // Decoder for [Category] - Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject) -> [Category] in + Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject, instance: AnyObject?) -> [Category] in return Decoders.decode(clazz: [Category].self, source: source) } // Decoder for Category - Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in + Decoders.addDecoder(clazz: Category.self) { (source: AnyObject, instance: AnyObject?) -> Category in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Category() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - return instance + let result = instance == nil ? Category() : instance as! Category + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + return result } // Decoder for [ClassModel] - Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject) -> [ClassModel] in + Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject, instance: AnyObject?) -> [ClassModel] in return Decoders.decode(clazz: [ClassModel].self, source: source) } // Decoder for ClassModel - Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject) -> ClassModel in + Decoders.addDecoder(clazz: ClassModel.self) { (source: AnyObject, instance: AnyObject?) -> ClassModel in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ClassModel() - instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) - return instance + let result = instance == nil ? ClassModel() : instance as! ClassModel + + result._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["_class"] as AnyObject?) + return result } // Decoder for [Client] - Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject) -> [Client] in + Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject, instance: AnyObject?) -> [Client] in return Decoders.decode(clazz: [Client].self, source: source) } // Decoder for Client - Decoders.addDecoder(clazz: Client.self) { (source: AnyObject) -> Client in + Decoders.addDecoder(clazz: Client.self) { (source: AnyObject, instance: AnyObject?) -> Client in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Client() - instance.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) - return instance + let result = instance == nil ? Client() : instance as! Client + + result.client = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["client"] as AnyObject?) + return result } // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject) -> [Dog] in + Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject, instance: AnyObject?) -> [Dog] in return Decoders.decode(clazz: [Dog].self, source: source) } // Decoder for Dog - Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in + Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject, instance: AnyObject?) -> Dog in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Dog() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) - instance.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) - instance.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) - return instance + let result = instance == nil ? Dog() : instance as! Dog + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + + result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) + result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) + result.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"] as AnyObject?) + return result } // Decoder for [EnumArrays] - Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject) -> [EnumArrays] in + Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject, instance: AnyObject?) -> [EnumArrays] in return Decoders.decode(clazz: [EnumArrays].self, source: source) } // Decoder for EnumArrays - Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject) -> EnumArrays in + Decoders.addDecoder(clazz: EnumArrays.self) { (source: AnyObject, instance: AnyObject?) -> EnumArrays in let sourceDictionary = source as! [AnyHashable: Any] - let instance = EnumArrays() + let result = instance == nil ? EnumArrays() : instance as! EnumArrays + if let justSymbol = sourceDictionary["just_symbol"] as? String { - instance.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol)) + result.justSymbol = EnumArrays.JustSymbol(rawValue: (justSymbol)) } if let arrayEnum = sourceDictionary["array_enum"] as? [String] { - instance.arrayEnum = arrayEnum.map ({ EnumArrays.ArrayEnum(rawValue: $0)! }) + result.arrayEnum = arrayEnum.map ({ EnumArrays.ArrayEnum(rawValue: $0)! }) } - return instance + return result } // Decoder for [EnumClass] - Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject) -> [EnumClass] in + Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject, instance: AnyObject?) -> [EnumClass] in return Decoders.decode(clazz: [EnumClass].self, source: source) } // Decoder for EnumClass - Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject) -> EnumClass in + Decoders.addDecoder(clazz: EnumClass.self) { (source: AnyObject, instance: AnyObject?) -> EnumClass in if let source = source as? String { if let result = EnumClass(rawValue: source) { return result @@ -385,193 +400,203 @@ class Decoders { // Decoder for [EnumTest] - Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject) -> [EnumTest] in + Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject, instance: AnyObject?) -> [EnumTest] in return Decoders.decode(clazz: [EnumTest].self, source: source) } // Decoder for EnumTest - Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject) -> EnumTest in + Decoders.addDecoder(clazz: EnumTest.self) { (source: AnyObject, instance: AnyObject?) -> EnumTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = EnumTest() + let result = instance == nil ? EnumTest() : instance as! EnumTest + if let enumString = sourceDictionary["enum_string"] as? String { - instance.enumString = EnumTest.EnumString(rawValue: (enumString)) + result.enumString = EnumTest.EnumString(rawValue: (enumString)) } if let enumInteger = sourceDictionary["enum_integer"] as? Int32 { - instance.enumInteger = EnumTest.EnumInteger(rawValue: (enumInteger)) + result.enumInteger = EnumTest.EnumInteger(rawValue: (enumInteger)) } if let enumNumber = sourceDictionary["enum_number"] as? Double { - instance.enumNumber = EnumTest.EnumNumber(rawValue: (enumNumber)) + result.enumNumber = EnumTest.EnumNumber(rawValue: (enumNumber)) } - instance.outerEnum = Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) - return instance + result.outerEnum = Decoders.decodeOptional(clazz: OuterEnum.self, source: sourceDictionary["outerEnum"] as AnyObject?) + return result } // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject) -> [FormatTest] in + Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject, instance: AnyObject?) -> [FormatTest] in return Decoders.decode(clazz: [FormatTest].self, source: source) } // Decoder for FormatTest - Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in + Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject, instance: AnyObject?) -> FormatTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = FormatTest() - instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) - instance.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) - instance.int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) - instance.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"] as AnyObject?) - instance.float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) - instance.double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) - instance.string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) - instance.byte = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["byte"] as AnyObject?) - instance.binary = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) - instance.date = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["date"] as AnyObject?) - instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) - instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) - return instance + let result = instance == nil ? FormatTest() : instance as! FormatTest + + result.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"] as AnyObject?) + result.int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"] as AnyObject?) + result.int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"] as AnyObject?) + result.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"] as AnyObject?) + result.float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"] as AnyObject?) + result.double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"] as AnyObject?) + result.string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"] as AnyObject?) + result.byte = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["byte"] as AnyObject?) + result.binary = Decoders.decodeOptional(clazz: Data.self, source: sourceDictionary["binary"] as AnyObject?) + result.date = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["date"] as AnyObject?) + result.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) + result.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) + result.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) + return result } // Decoder for [HasOnlyReadOnly] - Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject) -> [HasOnlyReadOnly] in + Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject, instance: AnyObject?) -> [HasOnlyReadOnly] in return Decoders.decode(clazz: [HasOnlyReadOnly].self, source: source) } // Decoder for HasOnlyReadOnly - Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject) -> HasOnlyReadOnly in + Decoders.addDecoder(clazz: HasOnlyReadOnly.self) { (source: AnyObject, instance: AnyObject?) -> HasOnlyReadOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = HasOnlyReadOnly() - instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) - instance.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) - return instance + let result = instance == nil ? HasOnlyReadOnly() : instance as! HasOnlyReadOnly + + result.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) + result.foo = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["foo"] as AnyObject?) + return result } // Decoder for [List] - Decoders.addDecoder(clazz: [List].self) { (source: AnyObject) -> [List] in + Decoders.addDecoder(clazz: [List].self) { (source: AnyObject, instance: AnyObject?) -> [List] in return Decoders.decode(clazz: [List].self, source: source) } // Decoder for List - Decoders.addDecoder(clazz: List.self) { (source: AnyObject) -> List in + Decoders.addDecoder(clazz: List.self) { (source: AnyObject, instance: AnyObject?) -> List in let sourceDictionary = source as! [AnyHashable: Any] - let instance = List() - instance._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) - return instance + let result = instance == nil ? List() : instance as! List + + result._123List = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["123-list"] as AnyObject?) + return result } // Decoder for [MapTest] - Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject) -> [MapTest] in + Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject, instance: AnyObject?) -> [MapTest] in return Decoders.decode(clazz: [MapTest].self, source: source) } // Decoder for MapTest - Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject) -> MapTest in + Decoders.addDecoder(clazz: MapTest.self) { (source: AnyObject, instance: AnyObject?) -> MapTest in let sourceDictionary = source as! [AnyHashable: Any] - let instance = MapTest() - instance.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?) + let result = instance == nil ? MapTest() : instance as! MapTest + + result.mapMapOfString = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map_map_of_string"] as AnyObject?) if let mapOfEnumString = sourceDictionary["map_of_enum_string"] as? [String:String] { //TODO: handle enum map scenario } - return instance + return result } // Decoder for [MixedPropertiesAndAdditionalPropertiesClass] - Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject) -> [MixedPropertiesAndAdditionalPropertiesClass] in + Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> [MixedPropertiesAndAdditionalPropertiesClass] in return Decoders.decode(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self, source: source) } // Decoder for MixedPropertiesAndAdditionalPropertiesClass - Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject) -> MixedPropertiesAndAdditionalPropertiesClass in + Decoders.addDecoder(clazz: MixedPropertiesAndAdditionalPropertiesClass.self) { (source: AnyObject, instance: AnyObject?) -> MixedPropertiesAndAdditionalPropertiesClass in let sourceDictionary = source as! [AnyHashable: Any] - let instance = MixedPropertiesAndAdditionalPropertiesClass() - instance.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) - instance.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) - instance.map = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map"] as AnyObject?) - return instance + let result = instance == nil ? MixedPropertiesAndAdditionalPropertiesClass() : instance as! MixedPropertiesAndAdditionalPropertiesClass + + result.uuid = Decoders.decodeOptional(clazz: UUID.self, source: sourceDictionary["uuid"] as AnyObject?) + result.dateTime = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["dateTime"] as AnyObject?) + result.map = Decoders.decodeOptional(clazz: Dictionary.self, source: sourceDictionary["map"] as AnyObject?) + return result } // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject) -> [Model200Response] in + Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject, instance: AnyObject?) -> [Model200Response] in return Decoders.decode(clazz: [Model200Response].self, source: source) } // Decoder for Model200Response - Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in + Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject, instance: AnyObject?) -> Model200Response in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Model200Response() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) - instance._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) - return instance + let result = instance == nil ? Model200Response() : instance as! Model200Response + + result.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) + result._class = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["class"] as AnyObject?) + return result } // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject) -> [Name] in + Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject, instance: AnyObject?) -> [Name] in return Decoders.decode(clazz: [Name].self, source: source) } // Decoder for Name - Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in + Decoders.addDecoder(clazz: Name.self) { (source: AnyObject, instance: AnyObject?) -> Name in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Name() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) - instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) - instance.property = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) - instance._123Number = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) - return instance + let result = instance == nil ? Name() : instance as! Name + + result.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"] as AnyObject?) + result.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"] as AnyObject?) + result.property = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["property"] as AnyObject?) + result._123Number = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["123Number"] as AnyObject?) + return result } // Decoder for [NumberOnly] - Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject) -> [NumberOnly] in + Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> [NumberOnly] in return Decoders.decode(clazz: [NumberOnly].self, source: source) } // Decoder for NumberOnly - Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject) -> NumberOnly in + Decoders.addDecoder(clazz: NumberOnly.self) { (source: AnyObject, instance: AnyObject?) -> NumberOnly in let sourceDictionary = source as! [AnyHashable: Any] - let instance = NumberOnly() - instance.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) - return instance + let result = instance == nil ? NumberOnly() : instance as! NumberOnly + + result.justNumber = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["JustNumber"] as AnyObject?) + return result } // Decoder for [Order] - Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in + Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject, instance: AnyObject?) -> [Order] in return Decoders.decode(clazz: [Order].self, source: source) } // Decoder for Order - Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in + Decoders.addDecoder(clazz: Order.self) { (source: AnyObject, instance: AnyObject?) -> Order in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Order() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) - instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) - instance.shipDate = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) + let result = instance == nil ? Order() : instance as! Order + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"] as AnyObject?) + result.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"] as AnyObject?) + result.shipDate = Decoders.decodeOptional(clazz: Date.self, source: sourceDictionary["shipDate"] as AnyObject?) if let status = sourceDictionary["status"] as? String { - instance.status = Order.Status(rawValue: (status)) + result.status = Order.Status(rawValue: (status)) } - instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) - return instance + result.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"] as AnyObject?) + return result } // Decoder for [OuterEnum] - Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject) -> [OuterEnum] in + Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject, instance: AnyObject?) -> [OuterEnum] in return Decoders.decode(clazz: [OuterEnum].self, source: source) } // Decoder for OuterEnum - Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject) -> OuterEnum in + Decoders.addDecoder(clazz: OuterEnum.self) { (source: AnyObject, instance: AnyObject?) -> OuterEnum in if let source = source as? String { if let result = OuterEnum(rawValue: source) { return result @@ -582,103 +607,109 @@ class Decoders { // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in + Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject, instance: AnyObject?) -> [Pet] in return Decoders.decode(clazz: [Pet].self, source: source) } // Decoder for Pet - Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in + Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject, instance: AnyObject?) -> Pet in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Pet() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"] as AnyObject?) - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"] as AnyObject?) + let result = instance == nil ? Pet() : instance as! Pet + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + result.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"] as AnyObject?) + result.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"] as AnyObject?) if let status = sourceDictionary["status"] as? String { - instance.status = Pet.Status(rawValue: (status)) + result.status = Pet.Status(rawValue: (status)) } - return instance + return result } // Decoder for [ReadOnlyFirst] - Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject) -> [ReadOnlyFirst] in + Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject, instance: AnyObject?) -> [ReadOnlyFirst] in return Decoders.decode(clazz: [ReadOnlyFirst].self, source: source) } // Decoder for ReadOnlyFirst - Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject) -> ReadOnlyFirst in + Decoders.addDecoder(clazz: ReadOnlyFirst.self) { (source: AnyObject, instance: AnyObject?) -> ReadOnlyFirst in let sourceDictionary = source as! [AnyHashable: Any] - let instance = ReadOnlyFirst() - instance.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) - instance.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) - return instance + let result = instance == nil ? ReadOnlyFirst() : instance as! ReadOnlyFirst + + result.bar = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["bar"] as AnyObject?) + result.baz = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["baz"] as AnyObject?) + return result } // Decoder for [Return] - Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject) -> [Return] in + Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject, instance: AnyObject?) -> [Return] in return Decoders.decode(clazz: [Return].self, source: source) } // Decoder for Return - Decoders.addDecoder(clazz: Return.self) { (source: AnyObject) -> Return in + Decoders.addDecoder(clazz: Return.self) { (source: AnyObject, instance: AnyObject?) -> Return in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Return() - instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) - return instance + let result = instance == nil ? Return() : instance as! Return + + result._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"] as AnyObject?) + return result } // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject) -> [SpecialModelName] in + Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject, instance: AnyObject?) -> [SpecialModelName] in return Decoders.decode(clazz: [SpecialModelName].self, source: source) } // Decoder for SpecialModelName - Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in + Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject, instance: AnyObject?) -> SpecialModelName in let sourceDictionary = source as! [AnyHashable: Any] - let instance = SpecialModelName() - instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) - return instance + let result = instance == nil ? SpecialModelName() : instance as! SpecialModelName + + result.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"] as AnyObject?) + return result } // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in + Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject, instance: AnyObject?) -> [Tag] in return Decoders.decode(clazz: [Tag].self, source: source) } // Decoder for Tag - Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in + Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject, instance: AnyObject?) -> Tag in let sourceDictionary = source as! [AnyHashable: Any] - let instance = Tag() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) - return instance + let result = instance == nil ? Tag() : instance as! Tag + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"] as AnyObject?) + return result } // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in + Decoders.addDecoder(clazz: [User].self) { (source: AnyObject, instance: AnyObject?) -> [User] in return Decoders.decode(clazz: [User].self, source: source) } // Decoder for User - Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in + Decoders.addDecoder(clazz: User.self) { (source: AnyObject, instance: AnyObject?) -> User in let sourceDictionary = source as! [AnyHashable: Any] - let instance = User() - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) - instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) - instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) - instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) - instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) - instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) - instance.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) - return instance + let result = instance == nil ? User() : instance as! User + + result.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"] as AnyObject?) + result.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"] as AnyObject?) + result.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"] as AnyObject?) + result.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"] as AnyObject?) + result.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"] as AnyObject?) + result.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"] as AnyObject?) + result.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"] as AnyObject?) + result.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"] as AnyObject?) + return result } }() From a17e80dfb1190799745728f83d6a8b1abcd700ac Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 18 Apr 2017 01:42:29 +0800 Subject: [PATCH 07/31] minor fix to spring use of examples --- .../main/resources/JavaSpring/api.mustache | 2 +- .../JavaSpring/apiController.mustache | 38 +++-- .../src/main/java/io/swagger/api/FakeApi.java | 3 +- .../io/swagger/api/FakeApiController.java | 20 +-- .../src/main/java/io/swagger/api/PetApi.java | 9 +- .../java/io/swagger/api/PetApiController.java | 135 +++++++++++++++--- .../main/java/io/swagger/api/StoreApi.java | 7 +- .../io/swagger/api/StoreApiController.java | 77 ++++++++-- .../src/main/java/io/swagger/api/UserApi.java | 5 +- .../io/swagger/api/UserApiController.java | 59 ++++++-- 10 files changed, 279 insertions(+), 76 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index 945e0c06eec..49d82ea73b2 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache @@ -50,7 +50,7 @@ public interface {{classname}} { produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{#examples}}throws IOException{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} { + {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} { // do some magic! return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; }{{/jdk8}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache index 8dfa6d8a1e9..95162cbd0b9 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache @@ -38,27 +38,45 @@ public class {{classname}}Controller implements {{classname}} { @org.springframework.beans.factory.annotation.Autowired public {{classname}}Controller({{classname}}Delegate delegate) { this.delegate = delegate; - }{{/isDelegate}} + } -{{^jdk8-no-delegate}}{{#operation}} +{{/isDelegate}} +{{^jdk8-no-delegate}} +{{#operation}} public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, - {{/hasMore}}{{/allParams}}) {{#examples}}throws IOException{{/examples}} { - // do some magic!{{^isDelegate}}{{^async}} - + {{/hasMore}}{{/allParams}}){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} { + // do some magic! + {{^isDelegate}} + {{^async}} {{#examples}} + {{#-first}} + ObjectMapper objectMapper = new ObjectMapper(); - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue({{{example}}},{{>exampleReturnTypes}}.class), HttpStatus.OK); + + {{/-first}} + if ("{{{contentType}}}".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{{example}}}",{{>exampleReturnTypes}}.class), HttpStatus.OK); + } + {{/examples}} {{^examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/examples}}{{/async}}{{#async}} + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); + {{/examples}} + {{/async}} + {{#async}} return new CallablereturnTypes}}>>() { @Override public ResponseEntity<{{>returnTypes}}> call() throws Exception { return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); } - };{{/async}}{{/isDelegate}}{{#isDelegate}} - return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/isDelegate}} + }; + {{/async}} + {{/isDelegate}} + {{#isDelegate}} + return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{/isDelegate}} } -{{/operation}}{{/jdk8-no-delegate}} +{{/operation}} +{{/jdk8-no-delegate}} } {{/operations}} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java index b0ed6f9a514..05783d1f44b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -31,7 +32,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException; @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java index 5cf609a4ae0..920f8a2274f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java @@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -24,14 +26,18 @@ import javax.validation.Valid; @Controller public class FakeApiController implements FakeApi { - - - - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("{ + "client" : "aeiou" +}",Client.class), HttpStatus.OK); + } + + } public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, @@ -49,7 +55,6 @@ public class FakeApiController implements FakeApi { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, @@ -61,5 +66,4 @@ public class FakeApiController implements FakeApi { // do some magic! return new ResponseEntity(HttpStatus.OK); } - } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 3cf98279345..59846383b86 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -66,7 +67,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); + ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException; @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -82,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException; @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -96,7 +97,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException; @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @@ -146,6 +147,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java index 973055a2f11..04fe59a4db4 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -23,52 +25,147 @@ import javax.validation.Valid; @Controller public class PetApiController implements PetApi { - - - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - - public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException { // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); - public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity>(objectMapper.readValue(" + 123456789 + doggie + + aeiou + + + + aeiou +",List.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity>(objectMapper.readValue("[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]",List.class), HttpStatus.OK); + } + + } + public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException { // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity>(objectMapper.readValue(" + 123456789 + doggie + + aeiou + + + + aeiou +",List.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity>(objectMapper.readValue("[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]",List.class), HttpStatus.OK); + } + + } + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue(" + 123456789 + doggie + + aeiou + + + + aeiou +",Pet.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("{ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "aeiou", + "id" : 6 + }, + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}",Pet.class), HttpStatus.OK); + } + + } public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("{ + "code" : 0, + "type" : "aeiou", + "message" : "aeiou" +}",ModelApiResponse.class), HttpStatus.OK); + } + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index 8b080a440dd..7301912a9c8 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -41,7 +42,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory(); + ResponseEntity> getInventory() throws IOException; @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -53,7 +54,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId); + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException; @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @@ -64,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java index 472bda2ada0..0c6cea2a4a6 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -22,27 +24,76 @@ import javax.validation.Valid; @Controller public class StoreApiController implements StoreApi { - - - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - - public ResponseEntity> getInventory() { + public ResponseEntity> getInventory() throws IOException { // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity>(objectMapper.readValue("{ + "key" : 0 +}",Map.class), HttpStatus.OK); + } + + } + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue(" + 123456789 + 123456789 + 123 + 2000-01-23T04:56:07.000Z + aeiou + true +",Order.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("{ + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}",Order.class), HttpStatus.OK); + } + + } + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue(" + 123456789 + 123456789 + 123 + 2000-01-23T04:56:07.000Z + aeiou + true +",Order.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("{ + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}",Order.class), HttpStatus.OK); + } + + } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index 4993fa21bfd..7d6729c23b9 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -71,7 +72,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException; @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @@ -82,7 +83,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException; @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java index 00d7e5deba1..c1a4eaf41f5 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -22,49 +24,76 @@ import javax.validation.Valid; @Controller public class UserApiController implements UserApi { - - - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue(" + 123456789 + aeiou + aeiou + aeiou + aeiou + aeiou + aeiou + 123 +",User.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("{ + "firstName" : "aeiou", + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}",User.class), HttpStatus.OK); + } + + } public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException { // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + + ObjectMapper objectMapper = new ObjectMapper(); + if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue("aeiou",String.class), HttpStatus.OK); + } + + if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" + return new ResponseEntity(objectMapper.readValue(""aeiou"",String.class), HttpStatus.OK); + } + + } public ResponseEntity logoutUser() { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - } From 71b12636e46d0e62bcf98eb743fd96d913f9385a Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 29 Mar 2017 12:06:23 +0200 Subject: [PATCH 08/31] [JAVA] Update gradle and android build tools --- .../src/main/resources/Java/build.gradle.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache index c969c9f7b08..c4a870358c1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache @@ -9,8 +9,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } @@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { {{#java8}} From 84dc2e1dd931592e997a635ea4ce698305361832 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:32:47 +0200 Subject: [PATCH 09/31] Update android --- .../src/main/resources/android/build.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/android/build.mustache b/modules/swagger-codegen/src/main/resources/android/build.mustache index 41c9a2dfbb1..e4e04be8d58 100644 --- a/modules/swagger-codegen/src/main/resources/android/build.mustache +++ b/modules/swagger-codegen/src/main/resources/android/build.mustache @@ -8,9 +8,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' + classpath 'com.android.tools.build:gradle:2.3.+' {{#useAndroidMavenGradlePlugin}} - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' {{/useAndroidMavenGradlePlugin}} } } @@ -28,12 +28,12 @@ apply plugin: 'com.github.dcendents.android-maven' {{/useAndroidMavenGradlePlugin}} android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' useLibrary 'org.apache.http.legacy' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 From 9652ce37f7afee2618d97ce28f8223a757e59c79 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:32:56 +0200 Subject: [PATCH 10/31] Update android/lib/volley --- .../resources/android/libraries/volley/build.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache index e8abab33c52..dc27b3d90e0 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache @@ -8,9 +8,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' + classpath 'com.android.tools.build:gradle:2.3.+' {{#useAndroidMavenGradlePlugin}} - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' {{/useAndroidMavenGradlePlugin}} } } @@ -28,11 +28,11 @@ apply plugin: 'com.github.dcendents.android-maven' {{/useAndroidMavenGradlePlugin}} android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 From 85a58f341430b824d1995d2d09998dc0174f6cb0 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:33:59 +0200 Subject: [PATCH 11/31] Update Java/lib/feign --- .../Java/libraries/feign/build.gradle.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache index c969ed307a9..7933f2f7a87 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache @@ -9,8 +9,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } @@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 From b2674feb1412cc3d92fc337b4a3186a5c389e2da Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:35:37 +0200 Subject: [PATCH 12/31] Java: Remove spaces at empty lines --- .../src/main/resources/Java/build.gradle.mustache | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache index c4a870358c1..944f12b3e66 100644 --- a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache @@ -23,7 +23,7 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' - + android { compileSdkVersion 25 buildToolsVersion '25.0.2' @@ -41,7 +41,7 @@ if(hasProperty('target') && target == 'android') { targetCompatibility JavaVersion.VERSION_1_7 {{/java8}} } - + // Rename the aar correctly libraryVariants.all { variant -> variant.outputs.each { output -> @@ -57,7 +57,7 @@ if(hasProperty('target') && target == 'android') { provided 'javax.annotation:jsr250-api:1.0' } } - + afterEvaluate { android.libraryVariants.all { variant -> def task = project.tasks.create "jar${variant.name.capitalize()}", Jar @@ -69,12 +69,12 @@ if(hasProperty('target') && target == 'android') { artifacts.add('archives', task); } } - + task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } - + artifacts { archives sourcesJar } @@ -92,13 +92,13 @@ if(hasProperty('target') && target == 'android') { sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 {{/java8}} - + install { repositories.mavenInstaller { pom.artifactId = '{{artifactId}}' } } - + task execute(type:JavaExec) { main = System.getProperty('mainClass') classpath = sourceSets.main.runtimeClasspath From 83e902ba3f18e593a1d528ef1b4afe959b7da3d1 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:36:05 +0200 Subject: [PATCH 13/31] Update java/lib/jersey2 --- .../Java/libraries/jersey2/build.gradle.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache index e150b8671ea..97c6f4edf85 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache @@ -9,8 +9,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } @@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { {{#java8}} From 5b475bcb1611fc6991d709c4715cb09e72371b94 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:37:14 +0200 Subject: [PATCH 14/31] Java/feign: Remove spaces at empty lines --- .../Java/libraries/feign/build.gradle.mustache | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache index 7933f2f7a87..fd64c5626ef 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache @@ -23,7 +23,7 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' - + android { compileSdkVersion 25 buildToolsVersion '25.0.2' @@ -35,7 +35,7 @@ if(hasProperty('target') && target == 'android') { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } - + // Rename the aar correctly libraryVariants.all { variant -> variant.outputs.each { output -> @@ -51,7 +51,7 @@ if(hasProperty('target') && target == 'android') { provided 'javax.annotation:jsr250-api:1.0' } } - + afterEvaluate { android.libraryVariants.all { variant -> def task = project.tasks.create "jar${variant.name.capitalize()}", Jar @@ -63,12 +63,12 @@ if(hasProperty('target') && target == 'android') { artifacts.add('archives', task); } } - + task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } - + artifacts { archives sourcesJar } @@ -77,16 +77,16 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'java' apply plugin: 'maven' - + sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}} targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}} - + install { repositories.mavenInstaller { pom.artifactId = '{{artifactId}}' } } - + task execute(type:JavaExec) { main = System.getProperty('mainClass') classpath = sourceSets.main.runtimeClasspath From ca87a4b81740aa29515186d246c20663c4f094d5 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:37:45 +0200 Subject: [PATCH 15/31] Update java/lib/retrofit --- .../libraries/retrofit/build.gradle.mustache | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache index 179bda3b8d8..86955dd32b6 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache @@ -9,8 +9,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } @@ -23,19 +23,19 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' - + android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } - + // Rename the aar correctly libraryVariants.all { variant -> variant.outputs.each { output -> @@ -51,7 +51,7 @@ if(hasProperty('target') && target == 'android') { provided 'javax.annotation:jsr250-api:1.0' } } - + afterEvaluate { android.libraryVariants.all { variant -> def task = project.tasks.create "jar${variant.name.capitalize()}", Jar @@ -63,12 +63,12 @@ if(hasProperty('target') && target == 'android') { artifacts.add('archives', task); } } - + task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } - + artifacts { archives sourcesJar } @@ -77,16 +77,16 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'java' apply plugin: 'maven' - + sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 - + install { repositories.mavenInstaller { pom.artifactId = '{{artifactId}}' } } - + task execute(type:JavaExec) { main = System.getProperty('mainClass') classpath = sourceSets.main.runtimeClasspath From 4b88374df48100aa20ecc1220ee4422c4088320b Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:39:20 +0200 Subject: [PATCH 16/31] Update java/lib/retrofit2 --- .../libraries/retrofit2/build.gradle.mustache | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 911a9b137c9..619e826e194 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -9,8 +9,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } @@ -21,76 +21,76 @@ repositories { if(hasProperty('target') && target == 'android') { - apply plugin: 'com.android.library' - apply plugin: 'com.github.dcendents.android-maven' + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' - android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' - defaultConfig { - minSdkVersion 14 - targetSdkVersion 23 - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } + android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 25 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } - // Rename the aar correctly - libraryVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = output.outputFile - if (outputFile != null && outputFile.name.endsWith('.aar')) { - def fileName = "${project.name}-${variant.baseName}-${version}.aar" - output.outputFile = new File(outputFile.parent, fileName) - } - } - } + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } dependencies { provided 'javax.annotation:jsr250-api:1.0' } - } + } - afterEvaluate { - android.libraryVariants.all { variant -> - def task = project.tasks.create "jar${variant.name.capitalize()}", Jar - task.description = "Create jar artifact for ${variant.name}" - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDir - task.destinationDir = project.file("${project.buildDir}/outputs/jar") - task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" - artifacts.add('archives', task); - } - } + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } - task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' - } + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } - artifacts { - archives sourcesJar - } + artifacts { + archives sourcesJar + } } else { - apply plugin: 'java' - apply plugin: 'maven' + apply plugin: 'java' + apply plugin: 'maven' sourceCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}} targetCompatibility = JavaVersion.VERSION_{{^java8}}1_7{{/java8}}{{#java8}}1_8{{/java8}} - install { - repositories.mavenInstaller { - pom.artifactId = '{{artifactId}}' - } - } + install { + repositories.mavenInstaller { + pom.artifactId = '{{artifactId}}' + } + } - task execute(type:JavaExec) { - main = System.getProperty('mainClass') - classpath = sourceSets.main.runtimeClasspath - } + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } } ext { From 9640e30f482aa368d04cfb11f2d4598f26490ff8 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:40:19 +0200 Subject: [PATCH 17/31] Update java/lib/okhttp-gson --- .../Java/libraries/okhttp-gson/build.gradle.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache index 24d2f19a7d5..22911d5207b 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache @@ -9,8 +9,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } @@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') { apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 23 - buildToolsVersion '23.0.2' + compileSdkVersion 25 + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 From 70e4dad72ea36b18317fdbc38c59023aa9bac5dc Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 18 Apr 2017 11:41:33 +0200 Subject: [PATCH 18/31] java/lib/retrofit2: Fix indent --- .../Java/libraries/retrofit2/build.gradle.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 619e826e194..fb63f11066b 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -47,9 +47,9 @@ if(hasProperty('target') && target == 'android') { } } - dependencies { - provided 'javax.annotation:jsr250-api:1.0' - } + dependencies { + provided 'javax.annotation:jsr250-api:1.0' + } } afterEvaluate { From 813949dd00a2e195a1f448b5e13c92d47082ec71 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 18 Apr 2017 18:14:00 +0800 Subject: [PATCH 19/31] add lamda to clean up examples, fix spring tempalate format --- .../codegen/languages/SpringCodegen.java | 20 + .../main/resources/JavaSpring/api.mustache | 8 +- .../JavaSpring/apiController.mustache | 11 +- .../src/main/java/io/swagger/api/PetApi.java | 9 +- .../main/java/io/swagger/api/StoreApi.java | 7 +- .../src/main/java/io/swagger/api/UserApi.java | 5 +- .../src/main/java/io/swagger/api/PetApi.java | 9 +- .../main/java/io/swagger/api/StoreApi.java | 7 +- .../src/main/java/io/swagger/api/UserApi.java | 5 +- .../src/main/java/io/swagger/api/FakeApi.java | 3 +- .../io/swagger/api/FakeApiController.java | 3 - .../src/main/java/io/swagger/api/PetApi.java | 9 +- .../java/io/swagger/api/PetApiController.java | 3 - .../main/java/io/swagger/api/StoreApi.java | 7 +- .../io/swagger/api/StoreApiController.java | 3 - .../src/main/java/io/swagger/api/UserApi.java | 5 +- .../io/swagger/api/UserApiController.java | 3 - .../src/main/java/io/swagger/api/FakeApi.java | 9 +- .../io/swagger/api/FakeApiController.java | 19 +- .../src/main/java/io/swagger/api/PetApi.java | 24 +- .../java/io/swagger/api/PetApiController.java | 134 ++----- .../main/java/io/swagger/api/StoreApi.java | 12 +- .../io/swagger/api/StoreApiController.java | 68 ++-- .../src/main/java/io/swagger/api/UserApi.java | 24 +- .../io/swagger/api/UserApiController.java | 67 ++-- .../.swagger-codegen-ignore | 23 -- .../springboot-beanvalidation/pom.xml | 73 ---- .../java/io/swagger/RFC3339DateFormat.java | 20 - .../java/io/swagger/Swagger2SpringBoot.java | 36 -- .../java/io/swagger/api/ApiException.java | 10 - .../java/io/swagger/api/ApiOriginFilter.java | 27 -- .../io/swagger/api/ApiResponseMessage.java | 69 ---- .../src/main/java/io/swagger/api/FakeApi.java | 62 --- .../io/swagger/api/FakeApiController.java | 65 ---- .../io/swagger/api/NotFoundException.java | 10 - .../src/main/java/io/swagger/api/PetApi.java | 151 ------- .../java/io/swagger/api/PetApiController.java | 74 ---- .../main/java/io/swagger/api/StoreApi.java | 69 ---- .../io/swagger/api/StoreApiController.java | 48 --- .../src/main/java/io/swagger/api/UserApi.java | 108 ----- .../io/swagger/api/UserApiController.java | 70 ---- .../swagger/configuration/HomeController.java | 16 - .../SwaggerDocumentationConfig.java | 40 -- .../model/AdditionalPropertiesClass.java | 116 ------ .../main/java/io/swagger/model/Animal.java | 105 ----- .../java/io/swagger/model/AnimalFarm.java | 50 --- .../model/ArrayOfArrayOfNumberOnly.java | 85 ---- .../io/swagger/model/ArrayOfNumberOnly.java | 85 ---- .../main/java/io/swagger/model/ArrayTest.java | 147 ------- .../java/io/swagger/model/Capitalization.java | 189 --------- .../src/main/java/io/swagger/model/Cat.java | 76 ---- .../main/java/io/swagger/model/Category.java | 97 ----- .../java/io/swagger/model/ClassModel.java | 75 ---- .../main/java/io/swagger/model/Client.java | 74 ---- .../src/main/java/io/swagger/model/Dog.java | 76 ---- .../java/io/swagger/model/EnumArrays.java | 170 -------- .../main/java/io/swagger/model/EnumClass.java | 41 -- .../main/java/io/swagger/model/EnumTest.java | 240 ------------ .../java/io/swagger/model/FormatTest.java | 368 ------------------ .../io/swagger/model/HasOnlyReadOnly.java | 97 ----- .../main/java/io/swagger/model/MapTest.java | 148 ------- ...ropertiesAndAdditionalPropertiesClass.java | 134 ------- .../io/swagger/model/Model200Response.java | 98 ----- .../io/swagger/model/ModelApiResponse.java | 120 ------ .../java/io/swagger/model/ModelReturn.java | 75 ---- .../src/main/java/io/swagger/model/Name.java | 145 ------- .../java/io/swagger/model/NumberOnly.java | 75 ---- .../src/main/java/io/swagger/model/Order.java | 224 ----------- .../main/java/io/swagger/model/OuterEnum.java | 41 -- .../src/main/java/io/swagger/model/Pet.java | 242 ------------ .../java/io/swagger/model/ReadOnlyFirst.java | 97 ----- .../io/swagger/model/SpecialModelName.java | 74 ---- .../src/main/java/io/swagger/model/Tag.java | 97 ----- .../src/main/java/io/swagger/model/User.java | 235 ----------- .../src/main/resources/application.properties | 5 - .../src/main/java/io/swagger/api/FakeApi.java | 3 +- .../io/swagger/api/FakeApiController.java | 12 +- .../src/main/java/io/swagger/api/PetApi.java | 9 +- .../java/io/swagger/api/PetApiController.java | 27 +- .../main/java/io/swagger/api/StoreApi.java | 7 +- .../io/swagger/api/StoreApiController.java | 15 +- .../src/main/java/io/swagger/api/UserApi.java | 5 +- .../io/swagger/api/UserApiController.java | 27 +- .../src/main/java/io/swagger/api/FakeApi.java | 3 +- .../io/swagger/api/FakeApiController.java | 12 +- .../src/main/java/io/swagger/api/PetApi.java | 9 +- .../java/io/swagger/api/PetApiController.java | 27 +- .../main/java/io/swagger/api/StoreApi.java | 7 +- .../io/swagger/api/StoreApiController.java | 15 +- .../src/main/java/io/swagger/api/UserApi.java | 5 +- .../io/swagger/api/UserApiController.java | 27 +- .../src/main/java/io/swagger/api/FakeApi.java | 7 +- .../io/swagger/api/FakeApiController.java | 21 +- .../src/main/java/io/swagger/api/PetApi.java | 17 +- .../java/io/swagger/api/PetApiController.java | 69 +++- .../main/java/io/swagger/api/StoreApi.java | 9 +- .../io/swagger/api/StoreApiController.java | 45 ++- .../src/main/java/io/swagger/api/UserApi.java | 17 +- .../io/swagger/api/UserApiController.java | 50 ++- 99 files changed, 515 insertions(+), 5276 deletions(-) delete mode 100644 samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore delete mode 100644 samples/server/petstore/springboot-beanvalidation/pom.xml delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java delete mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index 89fc3f4653a..151f8c0bfcc 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java @@ -1,5 +1,7 @@ package io.swagger.codegen.languages; +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template; import io.swagger.codegen.*; import io.swagger.codegen.languages.features.BeanValidationFeatures; import io.swagger.models.Operation; @@ -7,7 +9,12 @@ import io.swagger.models.Path; import io.swagger.models.Swagger; import java.io.File; +import java.io.IOException; +import java.io.Writer; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class SpringCodegen extends AbstractJavaCodegen implements BeanValidationFeatures { public static final String DEFAULT_LIBRARY = "spring-boot"; @@ -268,6 +275,19 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation break; } + // add lamda for mustache templates + additionalProperties.put("lamdaEscapeDoubleQuote", new Mustache.Lambda() { + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))); + } + }); + additionalProperties.put("lamdaRemoveLineBreak", new Mustache.Lambda() { + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + writer.write(fragment.execute().replaceAll("\\r|\\n", "")); + } + }); } @Override diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index 49d82ea73b2..0e23cd4f59b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache @@ -41,16 +41,18 @@ public interface {{classname}} { }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) @ApiResponses(value = { {{#responses}} @ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} }) - {{#implicitHeaders}}@ApiImplicitParams({ + {{#implicitHeaders}} + @ApiImplicitParams({ {{#headerParams}}{{>implicitHeader}}{{/headerParams}} - }){{/implicitHeaders}} + }) + {{/implicitHeaders}} @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} produces = "{{{vendorExtensions.x-accepts}}}", consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} { + {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} { // do some magic! return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; }{{/jdk8}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache index 95162cbd0b9..add32acf40a 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/apiController.mustache @@ -43,8 +43,8 @@ public class {{classname}}Controller implements {{classname}} { {{/isDelegate}} {{^jdk8-no-delegate}} {{#operation}} - public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, - {{/hasMore}}{{/allParams}}){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} { + public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}, + {{/allParams}}@RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} { // do some magic! {{^isDelegate}} {{^async}} @@ -54,14 +54,12 @@ public class {{classname}}Controller implements {{classname}} { ObjectMapper objectMapper = new ObjectMapper(); {{/-first}} - if ("{{{contentType}}}".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{{example}}}",{{>exampleReturnTypes}}.class), HttpStatus.OK); + if (accept != null && accept.contains("{{{contentType}}}")) { + return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lamdaRemoveLineBreak}}{{#lamdaEscapeDoubleQuote}}{{{example}}}{{/lamdaEscapeDoubleQuote}}{{/lamdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK); } {{/examples}} - {{^examples}} return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); - {{/examples}} {{/async}} {{#async}} return new CallablereturnTypes}}>>() { @@ -76,6 +74,7 @@ public class {{classname}}Controller implements {{classname}} { return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/isDelegate}} } + {{/operation}} {{/jdk8-no-delegate}} } diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java index 4d3e2792ebb..3b4a5482a87 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -68,7 +69,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); + com.netflix.hystrix.HystrixCommand>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException; @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -85,7 +86,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + com.netflix.hystrix.HystrixCommand>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException; @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -100,7 +101,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + com.netflix.hystrix.HystrixCommand> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException; @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @@ -150,6 +151,6 @@ public interface PetApi { produces = "application/json", consumes = "multipart/form-data", method = RequestMethod.POST) - com.netflix.hystrix.HystrixCommand> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file); + com.netflix.hystrix.HystrixCommand> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file) throws IOException; } diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java index fc5d6b4889e..34a96956d4b 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -43,7 +44,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand>> getInventory(); + com.netflix.hystrix.HystrixCommand>> getInventory() throws IOException; @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -56,7 +57,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId); + com.netflix.hystrix.HystrixCommand> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) throws IOException; @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @@ -68,6 +69,6 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - com.netflix.hystrix.HystrixCommand> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + com.netflix.hystrix.HystrixCommand> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException; } diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java index 003aed1eac2..14fc35e1e59 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -76,7 +77,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + com.netflix.hystrix.HystrixCommand> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException; @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @@ -88,7 +89,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + com.netflix.hystrix.HystrixCommand> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException; @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java index 617ad50e019..1dd3421891e 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -68,7 +69,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); + ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException; @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -85,7 +86,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException; @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -100,7 +101,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException; @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @@ -150,6 +151,6 @@ public interface PetApi { produces = "application/json", consumes = "multipart/form-data", method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException; } diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java index 2e3319c5b1f..f09b9ae08c9 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -43,7 +44,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity> getInventory(); + ResponseEntity> getInventory() throws IOException; @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -56,7 +57,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId); + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) throws IOException; @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @@ -68,6 +69,6 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException; } diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java index 2cb58f21b82..1c099b08d9c 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -76,7 +77,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException; @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @@ -88,7 +89,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException; @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java index 01174da7aa6..a08daecd72b 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -33,7 +34,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java index c3ae70f89c6..be29b9131ef 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApiController.java @@ -7,7 +7,4 @@ import javax.validation.Valid; @Controller public class FakeApiController implements FakeApi { - - - } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java index 4ee9bae9961..ed72275231e 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -74,7 +75,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + default CompletableFuture>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -93,7 +94,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + default CompletableFuture>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -110,7 +111,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -169,7 +170,7 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java index dc21c5e352f..b2774ec8115 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApiController.java @@ -7,7 +7,4 @@ import javax.validation.Valid; @Controller public class PetApiController implements PetApi { - - - } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java index 8a1056032ba..9c0c9015fa5 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -46,7 +47,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> getInventory() { + default CompletableFuture>> getInventory() throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -61,7 +62,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -75,7 +76,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java index 341bd1184af..b0bc99276d7 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApiController.java @@ -7,7 +7,4 @@ import javax.validation.Valid; @Controller public class StoreApiController implements StoreApi { - - - } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java index 077c7ab61a0..051b14989e6 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -85,7 +86,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -99,7 +100,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + default CompletableFuture> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java index f33d583cd75..f266cc48616 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApiController.java @@ -7,7 +7,4 @@ import javax.validation.Valid; @Controller public class UserApiController implements UserApi { - - - } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java index 05783d1f44b..d8b307a1f23 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java @@ -27,12 +27,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException; + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { @@ -41,23 +40,21 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/fake", produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader("Accept") String accept); @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = Void.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request", response = Void.class), @ApiResponse(code = 404, message = "Not found", response = Void.class) }) - @RequestMapping(value = "/fake", produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader("Accept") String accept); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java index 920f8a2274f..5bac24daffa 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java @@ -26,18 +26,19 @@ import javax.validation.Valid; @Controller public class FakeApiController implements FakeApi { - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException { + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("{ - "client" : "aeiou" -}",Client.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"aeiou\"}", Client.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, @@ -51,10 +52,12 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime, @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, @@ -62,8 +65,10 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 59846383b86..5816fb5b92e 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -31,12 +31,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - @RequestMapping(value = "/pet", produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { @@ -47,11 +46,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) - @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader("Accept") String accept); @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -63,11 +61,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) - @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException; + ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -79,11 +76,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) - @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException; + ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -93,11 +89,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) - @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @@ -110,12 +105,11 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 404, message = "Pet not found", response = Void.class), @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) - @RequestMapping(value = "/pet", produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { @@ -126,12 +120,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader("Accept") String accept); @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @@ -142,11 +135,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, @RequestHeader("Accept") String accept) throws IOException; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java index 04fe59a4db4..220aa32691d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java @@ -25,147 +25,97 @@ import javax.validation.Valid; @Controller public class PetApiController implements PetApi { - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException { + + public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity>(objectMapper.readValue(" - 123456789 - doggie - - aeiou - - - - aeiou -",List.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity>(objectMapper.readValue("[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "aeiou", - "id" : 6 - }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]",List.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); } + return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException { + + public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity>(objectMapper.readValue(" - 123456789 - doggie - - aeiou - - - - aeiou -",List.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity>(objectMapper.readValue("[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "aeiou", - "id" : 6 - }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -} ]",List.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); } + return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException { + + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue(" - 123456789 - doggie - - aeiou - - - - aeiou -",Pet.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("{ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "aeiou", - "id" : 6 - }, - "tags" : [ { - "name" : "aeiou", - "id" : 1 - } ], - "status" : "available" -}",Pet.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException { + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("{ - "code" : 0, - "type" : "aeiou", - "message" : "aeiou" -}",ModelApiResponse.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"aeiou\", \"message\" : \"aeiou\"}", ModelApiResponse.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } + } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index 7301912a9c8..fb8f3d706f5 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -26,11 +26,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) - @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId); + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader("Accept") String accept); @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -38,11 +37,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) - @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory() throws IOException; + ResponseEntity> getInventory( @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -50,21 +48,19 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) - @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) - @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException; + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader("Accept") String accept) throws IOException; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java index 0c6cea2a4a6..3eb23194cb1 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java @@ -24,76 +24,56 @@ import javax.validation.Valid; @Controller public class StoreApiController implements StoreApi { - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity> getInventory() throws IOException { + + public ResponseEntity> getInventory(@RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity>(objectMapper.readValue("{ - "key" : 0 -}",Map.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); } + return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException { + + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue(" - 123456789 - 123456789 - 123 - 2000-01-23T04:56:07.000Z - aeiou - true -",Order.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("{ - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" -}",Order.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException { + + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue(" - 123456789 - 123456789 - 123 - 2000-01-23T04:56:07.000Z - aeiou - true -",Order.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("{ - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" -}",Order.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } + } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index 7d6729c23b9..53899d1eddd 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -25,42 +25,38 @@ public interface UserApi { @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept); @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) @@ -68,42 +64,38 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @ApiResponse(code = 404, message = "User not found", response = User.class) }) - @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) - @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException; + ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( @RequestHeader("Accept") String accept); @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java index c1a4eaf41f5..d8cac8d5eb8 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java @@ -24,76 +24,75 @@ import javax.validation.Valid; @Controller public class UserApiController implements UserApi { - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { + + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException { + + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue(" - 123456789 - aeiou - aeiou - aeiou - aeiou - aeiou - aeiou - 123 -",User.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("{ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 6, - "phone" : "aeiou", - "id" : 0, - "email" : "aeiou", - "username" : "aeiou" -}",User.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"aeiou\", \"lastName\" : \"aeiou\", \"password\" : \"aeiou\", \"userStatus\" : 6, \"phone\" : \"aeiou\", \"id\" : 0, \"email\" : \"aeiou\", \"username\" : \"aeiou\"}", User.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException { + @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! ObjectMapper objectMapper = new ObjectMapper(); - if ("application/xml".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue("aeiou",String.class), HttpStatus.OK); + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); } - if ("application/json".equals("")) { //TODO need to compare HTTP request "Accept" - return new ResponseEntity(objectMapper.readValue(""aeiou"",String.class), HttpStatus.OK); + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("\"aeiou\"", String.class), HttpStatus.OK); } + return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity logoutUser() { + + public ResponseEntity logoutUser(@RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } + } diff --git a/samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore b/samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore deleted file mode 100644 index c5fa491b4c5..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/samples/server/petstore/springboot-beanvalidation/pom.xml b/samples/server/petstore/springboot-beanvalidation/pom.xml deleted file mode 100644 index 5af442938b5..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - io.swagger - spring-boot-beanvalidation - jar - spring-boot-beanvalidation - 1.0.0 - - 1.7 - ${java.version} - ${java.version} - 2.6.1 - - - org.springframework.boot - spring-boot-starter-parent - 1.4.5.RELEASE - - - src/main/java - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - joda-time - joda-time - - - - javax.validation - validation-api - 1.1.0.Final - provided - - - \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java deleted file mode 100644 index 0c3d276d2d4..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.swagger; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java deleted file mode 100644 index 75d822f027e..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.swagger; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.ExitCodeGenerator; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication -@EnableSwagger2 -@ComponentScan(basePackages = "io.swagger") -public class Swagger2SpringBoot implements CommandLineRunner { - - @Override - public void run(String... arg0) throws Exception { - if (arg0.length > 0 && arg0[0].equals("exitcode")) { - throw new ExitException(); - } - } - - public static void main(String[] args) throws Exception { - new SpringApplication(Swagger2SpringBoot.class).run(args); - } - - class ExitException extends RuntimeException implements ExitCodeGenerator { - private static final long serialVersionUID = 1L; - - @Override - public int getExitCode() { - return 10; - } - - } -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java deleted file mode 100644 index 97e535d3c21..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.swagger.api; - - -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java deleted file mode 100644 index 62646761f5a..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.swagger.api; - -import java.io.IOException; - -import javax.servlet.*; -import javax.servlet.http.HttpServletResponse; - - -public class ApiOriginFilter implements javax.servlet.Filter { - @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } - - @Override - public void destroy() { - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java deleted file mode 100644 index 162678c57e3..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.swagger.api; - -import javax.xml.bind.annotation.XmlTransient; - - -@javax.xml.bind.annotation.XmlRootElement -public class ApiResponseMessage { - public static final int ERROR = 1; - public static final int WARNING = 2; - public static final int INFO = 3; - public static final int OK = 4; - public static final int TOO_BUSY = 5; - - int code; - String type; - String message; - - public ApiResponseMessage(){} - - public ApiResponseMessage(int code, String message){ - this.code = code; - switch(code){ - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java deleted file mode 100644 index b0ed6f9a514..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.swagger.api; - -import java.math.BigDecimal; -import io.swagger.model.Client; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; - -import io.swagger.annotations.*; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Api(value = "fake", description = "the fake API") -public interface FakeApi { - - @ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - - @RequestMapping(value = "/fake", - produces = { "application/json" }, - consumes = { "application/json" }, - method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); - - - @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { - @Authorization(value = "http_basic_test") - }, tags={ "fake", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), - @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - - @RequestMapping(value = "/fake", - produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, - consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, - method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); - - - @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = Void.class, tags={ "fake", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid request", response = Void.class), - @ApiResponse(code = 404, message = "Not found", response = Void.class) }) - - @RequestMapping(value = "/fake", - produces = { "*/*" }, - consumes = { "*/*" }, - method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java deleted file mode 100644 index 5cf609a4ae0..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.swagger.api; - -import java.math.BigDecimal; -import io.swagger.model.Client; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Controller -public class FakeApiController implements FakeApi { - - - - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, - @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, - @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, - @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, - @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, - @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, - @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, - @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, - @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, - @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, - @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, - @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime, - @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, - @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, - @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, - @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, - @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, - @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, - @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java deleted file mode 100644 index b28b67ea4b2..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.swagger.api; - - -public class NotFoundException extends ApiException { - private int code; - public NotFoundException (int code, String msg) { - super(code, msg); - this.code = code; - } -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java deleted file mode 100644 index 3cf98279345..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java +++ /dev/null @@ -1,151 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.ModelApiResponse; -import io.swagger.model.Pet; -import org.springframework.core.io.Resource; - -import io.swagger.annotations.*; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Api(value = "pet", description = "the pet API") -public interface PetApi { - - @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - - @RequestMapping(value = "/pet", - produces = { "application/xml", "application/json" }, - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); - - - @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) - - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); - - - @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) - - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); - - - @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) - - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); - - - @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { - @Authorization(value = "api_key") - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), - @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) - - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); - - - @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), - @ApiResponse(code = 404, message = "Pet not found", response = Void.class), - @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) - - @RequestMapping(value = "/pet", - produces = { "application/xml", "application/json" }, - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); - - - @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); - - - @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }, tags={ "pet", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java deleted file mode 100644 index 973055a2f11..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.ModelApiResponse; -import io.swagger.model.Pet; -import org.springframework.core.io.Resource; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Controller -public class PetApiController implements PetApi { - - - - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } - - public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } - - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java deleted file mode 100644 index 8b080a440dd..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.swagger.api; - -import java.util.Map; -import io.swagger.model.Order; - -import io.swagger.annotations.*; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Api(value = "store", description = "the store API") -public interface StoreApi { - - @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), - @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) - - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId); - - - @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { - @Authorization(value = "api_key") - }, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) - - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) - ResponseEntity> getInventory(); - - - @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Order.class), - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), - @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) - - @RequestMapping(value = "/store/order/{order_id}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId); - - - @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Order.class), - @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) - - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java deleted file mode 100644 index 472bda2ada0..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.swagger.api; - -import java.util.Map; -import io.swagger.model.Order; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Controller -public class StoreApiController implements StoreApi { - - - - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity> getInventory() { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } - - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java deleted file mode 100644 index 4993fa21bfd..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java +++ /dev/null @@ -1,108 +0,0 @@ -package io.swagger.api; - -import java.util.List; -import io.swagger.model.User; - -import io.swagger.annotations.*; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Api(value = "user", description = "the user API") -public interface UserApi { - - @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - - @RequestMapping(value = "/user", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); - - - @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - - @RequestMapping(value = "/user/createWithArray", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); - - - @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - - @RequestMapping(value = "/user/createWithList", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); - - - @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), - @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); - - - @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = User.class), - @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), - @ApiResponse(code = 404, message = "User not found", response = User.class) }) - - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); - - - @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = String.class), - @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) - - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); - - - @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - - @RequestMapping(value = "/user/logout", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity logoutUser(); - - - @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), - @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java deleted file mode 100644 index 00d7e5deba1..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.swagger.api; - -import java.util.List; -import io.swagger.model.User; - -import io.swagger.annotations.*; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -import javax.validation.constraints.*; -import javax.validation.Valid; - -@Controller -public class UserApiController implements UserApi { - - - - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity logoutUser() { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java deleted file mode 100644 index f8328099284..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.swagger.configuration; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Home redirection to swagger api documentation - */ -@Controller -public class HomeController { - @RequestMapping(value = "/") - public String index() { - System.out.println("swagger-ui.html"); - return "redirect:swagger-ui.html"; - } -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java deleted file mode 100644 index 5658793e134..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.swagger.configuration; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -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.plugins.Docket; - - -@Configuration -public class SwaggerDocumentationConfig { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("Swagger 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("","", "apiteam@swagger.io")) - .build(); - } - - @Bean - public Docket customImplementation(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("io.swagger.api")) - .build() - .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); - } - -} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java deleted file mode 100644 index f4cfcadae51..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java +++ /dev/null @@ -1,116 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.validation.constraints.*; -/** - * AdditionalPropertiesClass - */ - -public class AdditionalPropertiesClass { - @JsonProperty("map_property") - private Map mapProperty = null; - - @JsonProperty("map_of_map_property") - private Map> mapOfMapProperty = null; - - public AdditionalPropertiesClass mapProperty(Map mapProperty) { - this.mapProperty = mapProperty; - return this; - } - - public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) { - if (this.mapProperty == null) { - this.mapProperty = new HashMap(); - } - this.mapProperty.put(key, mapPropertyItem); - return this; - } - - /** - * Get mapProperty - * @return mapProperty - **/ - @ApiModelProperty(value = "") - public Map getMapProperty() { - return mapProperty; - } - - public void setMapProperty(Map mapProperty) { - this.mapProperty = mapProperty; - } - - public AdditionalPropertiesClass mapOfMapProperty(Map> mapOfMapProperty) { - this.mapOfMapProperty = mapOfMapProperty; - return this; - } - - public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map mapOfMapPropertyItem) { - if (this.mapOfMapProperty == null) { - this.mapOfMapProperty = new HashMap>(); - } - this.mapOfMapProperty.put(key, mapOfMapPropertyItem); - return this; - } - - /** - * Get mapOfMapProperty - * @return mapOfMapProperty - **/ - @ApiModelProperty(value = "") - public Map> getMapOfMapProperty() { - return mapOfMapProperty; - } - - public void setMapOfMapProperty(Map> mapOfMapProperty) { - this.mapOfMapProperty = mapOfMapProperty; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; - return Objects.equals(this.mapProperty, additionalPropertiesClass.mapProperty) && - Objects.equals(this.mapOfMapProperty, additionalPropertiesClass.mapOfMapProperty); - } - - @Override - public int hashCode() { - return Objects.hash(mapProperty, mapOfMapProperty); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AdditionalPropertiesClass {\n"); - - sb.append(" mapProperty: ").append(toIndentedString(mapProperty)).append("\n"); - sb.append(" mapOfMapProperty: ").append(toIndentedString(mapOfMapProperty)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java deleted file mode 100644 index a218f0b5542..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java +++ /dev/null @@ -1,105 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Animal - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "className", visible = true ) -@JsonSubTypes({ - @JsonSubTypes.Type(value = Dog.class, name = "Dog"), - @JsonSubTypes.Type(value = Cat.class, name = "Cat"), -}) - -public class Animal { - @JsonProperty("className") - private String className = null; - - @JsonProperty("color") - private String color = "red"; - - public Animal className(String className) { - this.className = className; - return this; - } - - /** - * Get className - * @return className - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - public String getClassName() { - return className; - } - - public void setClassName(String className) { - this.className = className; - } - - public Animal color(String color) { - this.color = color; - return this; - } - - /** - * Get color - * @return color - **/ - @ApiModelProperty(value = "") - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Animal animal = (Animal) o; - return Objects.equals(this.className, animal.className) && - Objects.equals(this.color, animal.color); - } - - @Override - public int hashCode() { - return Objects.hash(className, color); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Animal {\n"); - - sb.append(" className: ").append(toIndentedString(className)).append("\n"); - sb.append(" color: ").append(toIndentedString(color)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java deleted file mode 100644 index 33dc04699af..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import io.swagger.model.Animal; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.*; -/** - * AnimalFarm - */ - -public class AnimalFarm extends ArrayList { - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AnimalFarm {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java deleted file mode 100644 index 8f975d8feda..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java +++ /dev/null @@ -1,85 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.*; -/** - * ArrayOfArrayOfNumberOnly - */ - -public class ArrayOfArrayOfNumberOnly { - @JsonProperty("ArrayArrayNumber") - private List> arrayArrayNumber = null; - - public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { - this.arrayArrayNumber = arrayArrayNumber; - return this; - } - - public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { - if (this.arrayArrayNumber == null) { - this.arrayArrayNumber = new ArrayList>(); - } - this.arrayArrayNumber.add(arrayArrayNumberItem); - return this; - } - - /** - * Get arrayArrayNumber - * @return arrayArrayNumber - **/ - @ApiModelProperty(value = "") - public List> getArrayArrayNumber() { - return arrayArrayNumber; - } - - public void setArrayArrayNumber(List> arrayArrayNumber) { - this.arrayArrayNumber = arrayArrayNumber; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; - return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); - } - - @Override - public int hashCode() { - return Objects.hash(arrayArrayNumber); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ArrayOfArrayOfNumberOnly {\n"); - - sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java deleted file mode 100644 index 2c556008554..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java +++ /dev/null @@ -1,85 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.*; -/** - * ArrayOfNumberOnly - */ - -public class ArrayOfNumberOnly { - @JsonProperty("ArrayNumber") - private List arrayNumber = null; - - public ArrayOfNumberOnly arrayNumber(List arrayNumber) { - this.arrayNumber = arrayNumber; - return this; - } - - public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { - if (this.arrayNumber == null) { - this.arrayNumber = new ArrayList(); - } - this.arrayNumber.add(arrayNumberItem); - return this; - } - - /** - * Get arrayNumber - * @return arrayNumber - **/ - @ApiModelProperty(value = "") - public List getArrayNumber() { - return arrayNumber; - } - - public void setArrayNumber(List arrayNumber) { - this.arrayNumber = arrayNumber; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; - return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); - } - - @Override - public int hashCode() { - return Objects.hash(arrayNumber); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ArrayOfNumberOnly {\n"); - - sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java deleted file mode 100644 index 664e319cd35..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.ReadOnlyFirst; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.*; -/** - * ArrayTest - */ - -public class ArrayTest { - @JsonProperty("array_of_string") - private List arrayOfString = null; - - @JsonProperty("array_array_of_integer") - private List> arrayArrayOfInteger = null; - - @JsonProperty("array_array_of_model") - private List> arrayArrayOfModel = null; - - public ArrayTest arrayOfString(List arrayOfString) { - this.arrayOfString = arrayOfString; - return this; - } - - public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { - if (this.arrayOfString == null) { - this.arrayOfString = new ArrayList(); - } - this.arrayOfString.add(arrayOfStringItem); - return this; - } - - /** - * Get arrayOfString - * @return arrayOfString - **/ - @ApiModelProperty(value = "") - public List getArrayOfString() { - return arrayOfString; - } - - public void setArrayOfString(List arrayOfString) { - this.arrayOfString = arrayOfString; - } - - public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { - this.arrayArrayOfInteger = arrayArrayOfInteger; - return this; - } - - public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { - if (this.arrayArrayOfInteger == null) { - this.arrayArrayOfInteger = new ArrayList>(); - } - this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); - return this; - } - - /** - * Get arrayArrayOfInteger - * @return arrayArrayOfInteger - **/ - @ApiModelProperty(value = "") - public List> getArrayArrayOfInteger() { - return arrayArrayOfInteger; - } - - public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { - this.arrayArrayOfInteger = arrayArrayOfInteger; - } - - public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { - this.arrayArrayOfModel = arrayArrayOfModel; - return this; - } - - public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { - if (this.arrayArrayOfModel == null) { - this.arrayArrayOfModel = new ArrayList>(); - } - this.arrayArrayOfModel.add(arrayArrayOfModelItem); - return this; - } - - /** - * Get arrayArrayOfModel - * @return arrayArrayOfModel - **/ - @ApiModelProperty(value = "") - public List> getArrayArrayOfModel() { - return arrayArrayOfModel; - } - - public void setArrayArrayOfModel(List> arrayArrayOfModel) { - this.arrayArrayOfModel = arrayArrayOfModel; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ArrayTest arrayTest = (ArrayTest) o; - return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && - Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && - Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); - } - - @Override - public int hashCode() { - return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ArrayTest {\n"); - - sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); - sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); - sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java deleted file mode 100644 index d7ad5642ccf..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java +++ /dev/null @@ -1,189 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Capitalization - */ - -public class Capitalization { - @JsonProperty("smallCamel") - private String smallCamel = null; - - @JsonProperty("CapitalCamel") - private String capitalCamel = null; - - @JsonProperty("small_Snake") - private String smallSnake = null; - - @JsonProperty("Capital_Snake") - private String capitalSnake = null; - - @JsonProperty("SCA_ETH_Flow_Points") - private String scAETHFlowPoints = null; - - @JsonProperty("ATT_NAME") - private String ATT_NAME = null; - - public Capitalization smallCamel(String smallCamel) { - this.smallCamel = smallCamel; - return this; - } - - /** - * Get smallCamel - * @return smallCamel - **/ - @ApiModelProperty(value = "") - public String getSmallCamel() { - return smallCamel; - } - - public void setSmallCamel(String smallCamel) { - this.smallCamel = smallCamel; - } - - public Capitalization capitalCamel(String capitalCamel) { - this.capitalCamel = capitalCamel; - return this; - } - - /** - * Get capitalCamel - * @return capitalCamel - **/ - @ApiModelProperty(value = "") - public String getCapitalCamel() { - return capitalCamel; - } - - public void setCapitalCamel(String capitalCamel) { - this.capitalCamel = capitalCamel; - } - - public Capitalization smallSnake(String smallSnake) { - this.smallSnake = smallSnake; - return this; - } - - /** - * Get smallSnake - * @return smallSnake - **/ - @ApiModelProperty(value = "") - public String getSmallSnake() { - return smallSnake; - } - - public void setSmallSnake(String smallSnake) { - this.smallSnake = smallSnake; - } - - public Capitalization capitalSnake(String capitalSnake) { - this.capitalSnake = capitalSnake; - return this; - } - - /** - * Get capitalSnake - * @return capitalSnake - **/ - @ApiModelProperty(value = "") - public String getCapitalSnake() { - return capitalSnake; - } - - public void setCapitalSnake(String capitalSnake) { - this.capitalSnake = capitalSnake; - } - - public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { - this.scAETHFlowPoints = scAETHFlowPoints; - return this; - } - - /** - * Get scAETHFlowPoints - * @return scAETHFlowPoints - **/ - @ApiModelProperty(value = "") - public String getScAETHFlowPoints() { - return scAETHFlowPoints; - } - - public void setScAETHFlowPoints(String scAETHFlowPoints) { - this.scAETHFlowPoints = scAETHFlowPoints; - } - - public Capitalization ATT_NAME(String ATT_NAME) { - this.ATT_NAME = ATT_NAME; - return this; - } - - /** - * Name of the pet - * @return ATT_NAME - **/ - @ApiModelProperty(value = "Name of the pet ") - public String getATTNAME() { - return ATT_NAME; - } - - public void setATTNAME(String ATT_NAME) { - this.ATT_NAME = ATT_NAME; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Capitalization capitalization = (Capitalization) o; - return Objects.equals(this.smallCamel, capitalization.smallCamel) && - Objects.equals(this.capitalCamel, capitalization.capitalCamel) && - Objects.equals(this.smallSnake, capitalization.smallSnake) && - Objects.equals(this.capitalSnake, capitalization.capitalSnake) && - Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && - Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); - } - - @Override - public int hashCode() { - return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Capitalization {\n"); - - sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); - sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); - sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); - sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); - sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); - sb.append(" ATT_NAME: ").append(toIndentedString(ATT_NAME)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java deleted file mode 100644 index 747e5dc0c7e..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; -import javax.validation.constraints.*; -/** - * Cat - */ - -public class Cat extends Animal { - @JsonProperty("declawed") - private Boolean declawed = null; - - public Cat declawed(Boolean declawed) { - this.declawed = declawed; - return this; - } - - /** - * Get declawed - * @return declawed - **/ - @ApiModelProperty(value = "") - public Boolean getDeclawed() { - return declawed; - } - - public void setDeclawed(Boolean declawed) { - this.declawed = declawed; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Cat cat = (Cat) o; - return Objects.equals(this.declawed, cat.declawed) && - super.equals(o); - } - - @Override - public int hashCode() { - return Objects.hash(declawed, super.hashCode()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Cat {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java deleted file mode 100644 index 9629da6500e..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Category - */ - -public class Category { - @JsonProperty("id") - private Long id = null; - - @JsonProperty("name") - private String name = null; - - public Category id(Long id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Category name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @ApiModelProperty(value = "") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Category category = (Category) o; - return Objects.equals(this.id, category.id) && - Objects.equals(this.name, category.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java deleted file mode 100644 index d69acffefa8..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Model for testing model with \"_class\" property - */ -@ApiModel(description = "Model for testing model with \"_class\" property") - -public class ClassModel { - @JsonProperty("_class") - private String propertyClass = null; - - public ClassModel propertyClass(String propertyClass) { - this.propertyClass = propertyClass; - return this; - } - - /** - * Get propertyClass - * @return propertyClass - **/ - @ApiModelProperty(value = "") - public String getPropertyClass() { - return propertyClass; - } - - public void setPropertyClass(String propertyClass) { - this.propertyClass = propertyClass; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ClassModel classModel = (ClassModel) o; - return Objects.equals(this.propertyClass, classModel.propertyClass); - } - - @Override - public int hashCode() { - return Objects.hash(propertyClass); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ClassModel {\n"); - - sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java deleted file mode 100644 index f9cec5a225e..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Client - */ - -public class Client { - @JsonProperty("client") - private String client = null; - - public Client client(String client) { - this.client = client; - return this; - } - - /** - * Get client - * @return client - **/ - @ApiModelProperty(value = "") - public String getClient() { - return client; - } - - public void setClient(String client) { - this.client = client; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Client client = (Client) o; - return Objects.equals(this.client, client.client); - } - - @Override - public int hashCode() { - return Objects.hash(client); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Client {\n"); - - sb.append(" client: ").append(toIndentedString(client)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java deleted file mode 100644 index 9057e840fc3..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; -import javax.validation.constraints.*; -/** - * Dog - */ - -public class Dog extends Animal { - @JsonProperty("breed") - private String breed = null; - - public Dog breed(String breed) { - this.breed = breed; - return this; - } - - /** - * Get breed - * @return breed - **/ - @ApiModelProperty(value = "") - public String getBreed() { - return breed; - } - - public void setBreed(String breed) { - this.breed = breed; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Dog dog = (Dog) o; - return Objects.equals(this.breed, dog.breed) && - super.equals(o); - } - - @Override - public int hashCode() { - return Objects.hash(breed, super.hashCode()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Dog {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" breed: ").append(toIndentedString(breed)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java deleted file mode 100644 index f904035e482..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java +++ /dev/null @@ -1,170 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.*; -/** - * EnumArrays - */ - -public class EnumArrays { - /** - * Gets or Sets justSymbol - */ - public enum JustSymbolEnum { - GREATER_THAN_OR_EQUAL_TO(">="), - - DOLLAR("$"); - - private String value; - - JustSymbolEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static JustSymbolEnum fromValue(String text) { - for (JustSymbolEnum b : JustSymbolEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("just_symbol") - private JustSymbolEnum justSymbol = null; - - /** - * Gets or Sets arrayEnum - */ - public enum ArrayEnumEnum { - FISH("fish"), - - CRAB("crab"); - - private String value; - - ArrayEnumEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static ArrayEnumEnum fromValue(String text) { - for (ArrayEnumEnum b : ArrayEnumEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("array_enum") - private List arrayEnum = null; - - public EnumArrays justSymbol(JustSymbolEnum justSymbol) { - this.justSymbol = justSymbol; - return this; - } - - /** - * Get justSymbol - * @return justSymbol - **/ - @ApiModelProperty(value = "") - public JustSymbolEnum getJustSymbol() { - return justSymbol; - } - - public void setJustSymbol(JustSymbolEnum justSymbol) { - this.justSymbol = justSymbol; - } - - public EnumArrays arrayEnum(List arrayEnum) { - this.arrayEnum = arrayEnum; - return this; - } - - public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { - if (this.arrayEnum == null) { - this.arrayEnum = new ArrayList(); - } - this.arrayEnum.add(arrayEnumItem); - return this; - } - - /** - * Get arrayEnum - * @return arrayEnum - **/ - @ApiModelProperty(value = "") - public List getArrayEnum() { - return arrayEnum; - } - - public void setArrayEnum(List arrayEnum) { - this.arrayEnum = arrayEnum; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EnumArrays enumArrays = (EnumArrays) o; - return Objects.equals(this.justSymbol, enumArrays.justSymbol) && - Objects.equals(this.arrayEnum, enumArrays.arrayEnum); - } - - @Override - public int hashCode() { - return Objects.hash(justSymbol, arrayEnum); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class EnumArrays {\n"); - - sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); - sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java deleted file mode 100644 index cdfc0933c3e..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Gets or Sets EnumClass - */ -public enum EnumClass { - - _ABC("_abc"), - - _EFG("-efg"), - - _XYZ_("(xyz)"); - - private String value; - - EnumClass(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static EnumClass fromValue(String text) { - for (EnumClass b : EnumClass.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java deleted file mode 100644 index 9f2a0275a6a..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java +++ /dev/null @@ -1,240 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.OuterEnum; -import javax.validation.constraints.*; -/** - * EnumTest - */ - -public class EnumTest { - /** - * Gets or Sets enumString - */ - public enum EnumStringEnum { - UPPER("UPPER"), - - LOWER("lower"), - - EMPTY(""); - - private String value; - - EnumStringEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static EnumStringEnum fromValue(String text) { - for (EnumStringEnum b : EnumStringEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("enum_string") - private EnumStringEnum enumString = null; - - /** - * Gets or Sets enumInteger - */ - public enum EnumIntegerEnum { - NUMBER_1(1), - - NUMBER_MINUS_1(-1); - - private Integer value; - - EnumIntegerEnum(Integer value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static EnumIntegerEnum fromValue(String text) { - for (EnumIntegerEnum b : EnumIntegerEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("enum_integer") - private EnumIntegerEnum enumInteger = null; - - /** - * Gets or Sets enumNumber - */ - public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), - - NUMBER_MINUS_1_DOT_2(-1.2); - - private Double value; - - EnumNumberEnum(Double value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static EnumNumberEnum fromValue(String text) { - for (EnumNumberEnum b : EnumNumberEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("enum_number") - private EnumNumberEnum enumNumber = null; - - @JsonProperty("outerEnum") - private OuterEnum outerEnum = null; - - public EnumTest enumString(EnumStringEnum enumString) { - this.enumString = enumString; - return this; - } - - /** - * Get enumString - * @return enumString - **/ - @ApiModelProperty(value = "") - public EnumStringEnum getEnumString() { - return enumString; - } - - public void setEnumString(EnumStringEnum enumString) { - this.enumString = enumString; - } - - public EnumTest enumInteger(EnumIntegerEnum enumInteger) { - this.enumInteger = enumInteger; - return this; - } - - /** - * Get enumInteger - * @return enumInteger - **/ - @ApiModelProperty(value = "") - public EnumIntegerEnum getEnumInteger() { - return enumInteger; - } - - public void setEnumInteger(EnumIntegerEnum enumInteger) { - this.enumInteger = enumInteger; - } - - public EnumTest enumNumber(EnumNumberEnum enumNumber) { - this.enumNumber = enumNumber; - return this; - } - - /** - * Get enumNumber - * @return enumNumber - **/ - @ApiModelProperty(value = "") - public EnumNumberEnum getEnumNumber() { - return enumNumber; - } - - public void setEnumNumber(EnumNumberEnum enumNumber) { - this.enumNumber = enumNumber; - } - - public EnumTest outerEnum(OuterEnum outerEnum) { - this.outerEnum = outerEnum; - return this; - } - - /** - * Get outerEnum - * @return outerEnum - **/ - @ApiModelProperty(value = "") - public OuterEnum getOuterEnum() { - return outerEnum; - } - - public void setOuterEnum(OuterEnum outerEnum) { - this.outerEnum = outerEnum; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EnumTest enumTest = (EnumTest) o; - return Objects.equals(this.enumString, enumTest.enumString) && - Objects.equals(this.enumInteger, enumTest.enumInteger) && - Objects.equals(this.enumNumber, enumTest.enumNumber) && - Objects.equals(this.outerEnum, enumTest.outerEnum); - } - - @Override - public int hashCode() { - return Objects.hash(enumString, enumInteger, enumNumber, outerEnum); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class EnumTest {\n"); - - sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); - sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); - sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); - sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java deleted file mode 100644 index ad8680a3beb..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java +++ /dev/null @@ -1,368 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; -import java.util.UUID; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; -import javax.validation.constraints.*; -/** - * FormatTest - */ - -public class FormatTest { - @JsonProperty("integer") - private Integer integer = null; - - @JsonProperty("int32") - private Integer int32 = null; - - @JsonProperty("int64") - private Long int64 = null; - - @JsonProperty("number") - private BigDecimal number = null; - - @JsonProperty("float") - private Float _float = null; - - @JsonProperty("double") - private Double _double = null; - - @JsonProperty("string") - private String string = null; - - @JsonProperty("byte") - private byte[] _byte = null; - - @JsonProperty("binary") - private byte[] binary = null; - - @JsonProperty("date") - private LocalDate date = null; - - @JsonProperty("dateTime") - private DateTime dateTime = null; - - @JsonProperty("uuid") - private UUID uuid = null; - - @JsonProperty("password") - private String password = null; - - public FormatTest integer(Integer integer) { - this.integer = integer; - return this; - } - - /** - * Get integer - * minimum: 10 - * maximum: 100 - * @return integer - **/ - @ApiModelProperty(value = "") - @Min(10) @Max(100) public Integer getInteger() { - return integer; - } - - public void setInteger(Integer integer) { - this.integer = integer; - } - - public FormatTest int32(Integer int32) { - this.int32 = int32; - return this; - } - - /** - * Get int32 - * minimum: 20 - * maximum: 200 - * @return int32 - **/ - @ApiModelProperty(value = "") - @Min(20) @Max(200) public Integer getInt32() { - return int32; - } - - public void setInt32(Integer int32) { - this.int32 = int32; - } - - public FormatTest int64(Long int64) { - this.int64 = int64; - return this; - } - - /** - * Get int64 - * @return int64 - **/ - @ApiModelProperty(value = "") - public Long getInt64() { - return int64; - } - - public void setInt64(Long int64) { - this.int64 = int64; - } - - public FormatTest number(BigDecimal number) { - this.number = number; - return this; - } - - /** - * Get number - * minimum: 32.1 - * maximum: 543.2 - * @return number - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - @DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { - return number; - } - - public void setNumber(BigDecimal number) { - this.number = number; - } - - public FormatTest _float(Float _float) { - this._float = _float; - return this; - } - - /** - * Get _float - * minimum: 54.3 - * maximum: 987.6 - * @return _float - **/ - @ApiModelProperty(value = "") - @DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { - return _float; - } - - public void setFloat(Float _float) { - this._float = _float; - } - - public FormatTest _double(Double _double) { - this._double = _double; - return this; - } - - /** - * Get _double - * minimum: 67.8 - * maximum: 123.4 - * @return _double - **/ - @ApiModelProperty(value = "") - @DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { - return _double; - } - - public void setDouble(Double _double) { - this._double = _double; - } - - public FormatTest string(String string) { - this.string = string; - return this; - } - - /** - * Get string - * @return string - **/ - @ApiModelProperty(value = "") - @Pattern(regexp="/[a-z]/i") public String getString() { - return string; - } - - public void setString(String string) { - this.string = string; - } - - public FormatTest _byte(byte[] _byte) { - this._byte = _byte; - return this; - } - - /** - * Get _byte - * @return _byte - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - public byte[] getByte() { - return _byte; - } - - public void setByte(byte[] _byte) { - this._byte = _byte; - } - - public FormatTest binary(byte[] binary) { - this.binary = binary; - return this; - } - - /** - * Get binary - * @return binary - **/ - @ApiModelProperty(value = "") - public byte[] getBinary() { - return binary; - } - - public void setBinary(byte[] binary) { - this.binary = binary; - } - - public FormatTest date(LocalDate date) { - this.date = date; - return this; - } - - /** - * Get date - * @return date - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - public LocalDate getDate() { - return date; - } - - public void setDate(LocalDate date) { - this.date = date; - } - - public FormatTest dateTime(DateTime dateTime) { - this.dateTime = dateTime; - return this; - } - - /** - * Get dateTime - * @return dateTime - **/ - @ApiModelProperty(value = "") - public DateTime getDateTime() { - return dateTime; - } - - public void setDateTime(DateTime dateTime) { - this.dateTime = dateTime; - } - - public FormatTest uuid(UUID uuid) { - this.uuid = uuid; - return this; - } - - /** - * Get uuid - * @return uuid - **/ - @ApiModelProperty(value = "") - public UUID getUuid() { - return uuid; - } - - public void setUuid(UUID uuid) { - this.uuid = uuid; - } - - public FormatTest password(String password) { - this.password = password; - return this; - } - - /** - * Get password - * @return password - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - @Size(min=10,max=64) public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FormatTest formatTest = (FormatTest) o; - return Objects.equals(this.integer, formatTest.integer) && - Objects.equals(this.int32, formatTest.int32) && - Objects.equals(this.int64, formatTest.int64) && - Objects.equals(this.number, formatTest.number) && - Objects.equals(this._float, formatTest._float) && - Objects.equals(this._double, formatTest._double) && - Objects.equals(this.string, formatTest.string) && - Objects.equals(this._byte, formatTest._byte) && - Objects.equals(this.binary, formatTest.binary) && - Objects.equals(this.date, formatTest.date) && - Objects.equals(this.dateTime, formatTest.dateTime) && - Objects.equals(this.uuid, formatTest.uuid) && - Objects.equals(this.password, formatTest.password); - } - - @Override - public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class FormatTest {\n"); - - sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); - sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); - sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); - sb.append(" number: ").append(toIndentedString(number)).append("\n"); - sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); - sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); - sb.append(" string: ").append(toIndentedString(string)).append("\n"); - sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); - sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); - sb.append(" date: ").append(toIndentedString(date)).append("\n"); - sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); - sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java deleted file mode 100644 index a26492e4912..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * HasOnlyReadOnly - */ - -public class HasOnlyReadOnly { - @JsonProperty("bar") - private String bar = null; - - @JsonProperty("foo") - private String foo = null; - - public HasOnlyReadOnly bar(String bar) { - this.bar = bar; - return this; - } - - /** - * Get bar - * @return bar - **/ - @ApiModelProperty(readOnly = true, value = "") - public String getBar() { - return bar; - } - - public void setBar(String bar) { - this.bar = bar; - } - - public HasOnlyReadOnly foo(String foo) { - this.foo = foo; - return this; - } - - /** - * Get foo - * @return foo - **/ - @ApiModelProperty(readOnly = true, value = "") - public String getFoo() { - return foo; - } - - public void setFoo(String foo) { - this.foo = foo; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; - return Objects.equals(this.bar, hasOnlyReadOnly.bar) && - Objects.equals(this.foo, hasOnlyReadOnly.foo); - } - - @Override - public int hashCode() { - return Objects.hash(bar, foo); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class HasOnlyReadOnly {\n"); - - sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); - sb.append(" foo: ").append(toIndentedString(foo)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java deleted file mode 100644 index 434c3a8f1b5..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java +++ /dev/null @@ -1,148 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.validation.constraints.*; -/** - * MapTest - */ - -public class MapTest { - @JsonProperty("map_map_of_string") - private Map> mapMapOfString = null; - - /** - * Gets or Sets inner - */ - public enum InnerEnum { - UPPER("UPPER"), - - LOWER("lower"); - - private String value; - - InnerEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static InnerEnum fromValue(String text) { - for (InnerEnum b : InnerEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("map_of_enum_string") - private Map mapOfEnumString = null; - - public MapTest mapMapOfString(Map> mapMapOfString) { - this.mapMapOfString = mapMapOfString; - return this; - } - - public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { - if (this.mapMapOfString == null) { - this.mapMapOfString = new HashMap>(); - } - this.mapMapOfString.put(key, mapMapOfStringItem); - return this; - } - - /** - * Get mapMapOfString - * @return mapMapOfString - **/ - @ApiModelProperty(value = "") - public Map> getMapMapOfString() { - return mapMapOfString; - } - - public void setMapMapOfString(Map> mapMapOfString) { - this.mapMapOfString = mapMapOfString; - } - - public MapTest mapOfEnumString(Map mapOfEnumString) { - this.mapOfEnumString = mapOfEnumString; - return this; - } - - public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { - if (this.mapOfEnumString == null) { - this.mapOfEnumString = new HashMap(); - } - this.mapOfEnumString.put(key, mapOfEnumStringItem); - return this; - } - - /** - * Get mapOfEnumString - * @return mapOfEnumString - **/ - @ApiModelProperty(value = "") - public Map getMapOfEnumString() { - return mapOfEnumString; - } - - public void setMapOfEnumString(Map mapOfEnumString) { - this.mapOfEnumString = mapOfEnumString; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MapTest mapTest = (MapTest) o; - return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && - Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString); - } - - @Override - public int hashCode() { - return Objects.hash(mapMapOfString, mapOfEnumString); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MapTest {\n"); - - sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); - sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java deleted file mode 100644 index dba1241f6d6..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ /dev/null @@ -1,134 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.joda.time.DateTime; -import javax.validation.constraints.*; -/** - * MixedPropertiesAndAdditionalPropertiesClass - */ - -public class MixedPropertiesAndAdditionalPropertiesClass { - @JsonProperty("uuid") - private UUID uuid = null; - - @JsonProperty("dateTime") - private DateTime dateTime = null; - - @JsonProperty("map") - private Map map = null; - - public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { - this.uuid = uuid; - return this; - } - - /** - * Get uuid - * @return uuid - **/ - @ApiModelProperty(value = "") - public UUID getUuid() { - return uuid; - } - - public void setUuid(UUID uuid) { - this.uuid = uuid; - } - - public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) { - this.dateTime = dateTime; - return this; - } - - /** - * Get dateTime - * @return dateTime - **/ - @ApiModelProperty(value = "") - public DateTime getDateTime() { - return dateTime; - } - - public void setDateTime(DateTime dateTime) { - this.dateTime = dateTime; - } - - public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { - this.map = map; - return this; - } - - public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { - if (this.map == null) { - this.map = new HashMap(); - } - this.map.put(key, mapItem); - return this; - } - - /** - * Get map - * @return map - **/ - @ApiModelProperty(value = "") - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; - return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && - Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && - Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); - } - - @Override - public int hashCode() { - return Objects.hash(uuid, dateTime, map); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); - - sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); - sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); - sb.append(" map: ").append(toIndentedString(map)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java deleted file mode 100644 index 4d47f6c03c9..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Model for testing model name starting with number - */ -@ApiModel(description = "Model for testing model name starting with number") - -public class Model200Response { - @JsonProperty("name") - private Integer name = null; - - @JsonProperty("class") - private String propertyClass = null; - - public Model200Response name(Integer name) { - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @ApiModelProperty(value = "") - public Integer getName() { - return name; - } - - public void setName(Integer name) { - this.name = name; - } - - public Model200Response propertyClass(String propertyClass) { - this.propertyClass = propertyClass; - return this; - } - - /** - * Get propertyClass - * @return propertyClass - **/ - @ApiModelProperty(value = "") - public String getPropertyClass() { - return propertyClass; - } - - public void setPropertyClass(String propertyClass) { - this.propertyClass = propertyClass; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Model200Response _200Response = (Model200Response) o; - return Objects.equals(this.name, _200Response.name) && - Objects.equals(this.propertyClass, _200Response.propertyClass); - } - - @Override - public int hashCode() { - return Objects.hash(name, propertyClass); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Model200Response {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java deleted file mode 100644 index 36da9b20d9d..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java +++ /dev/null @@ -1,120 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * ModelApiResponse - */ - -public class ModelApiResponse { - @JsonProperty("code") - private Integer code = null; - - @JsonProperty("type") - private String type = null; - - @JsonProperty("message") - private String message = null; - - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - /** - * Get code - * @return code - **/ - @ApiModelProperty(value = "") - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type - **/ - @ApiModelProperty(value = "") - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - /** - * Get message - * @return message - **/ - @ApiModelProperty(value = "") - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(this.code, _apiResponse.code) && - Objects.equals(this.type, _apiResponse.type) && - Objects.equals(this.message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java deleted file mode 100644 index 7ffc24a0144..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Model for testing reserved words - */ -@ApiModel(description = "Model for testing reserved words") - -public class ModelReturn { - @JsonProperty("return") - private Integer _return = null; - - public ModelReturn _return(Integer _return) { - this._return = _return; - return this; - } - - /** - * Get _return - * @return _return - **/ - @ApiModelProperty(value = "") - public Integer getReturn() { - return _return; - } - - public void setReturn(Integer _return) { - this._return = _return; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelReturn _return = (ModelReturn) o; - return Objects.equals(this._return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelReturn {\n"); - - sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java deleted file mode 100644 index 953199166ff..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java +++ /dev/null @@ -1,145 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Model for testing model name same as property name - */ -@ApiModel(description = "Model for testing model name same as property name") - -public class Name { - @JsonProperty("name") - private Integer name = null; - - @JsonProperty("snake_case") - private Integer snakeCase = null; - - @JsonProperty("property") - private String property = null; - - @JsonProperty("123Number") - private Integer _123Number = null; - - public Name name(Integer name) { - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - public Integer getName() { - return name; - } - - public void setName(Integer name) { - this.name = name; - } - - public Name snakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; - return this; - } - - /** - * Get snakeCase - * @return snakeCase - **/ - @ApiModelProperty(readOnly = true, value = "") - public Integer getSnakeCase() { - return snakeCase; - } - - public void setSnakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; - } - - public Name property(String property) { - this.property = property; - return this; - } - - /** - * Get property - * @return property - **/ - @ApiModelProperty(value = "") - public String getProperty() { - return property; - } - - public void setProperty(String property) { - this.property = property; - } - - public Name _123Number(Integer _123Number) { - this._123Number = _123Number; - return this; - } - - /** - * Get _123Number - * @return _123Number - **/ - @ApiModelProperty(readOnly = true, value = "") - public Integer get123Number() { - return _123Number; - } - - public void set123Number(Integer _123Number) { - this._123Number = _123Number; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Name name = (Name) o; - return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase) && - Objects.equals(this.property, name.property) && - Objects.equals(this._123Number, name._123Number); - } - - @Override - public int hashCode() { - return Objects.hash(name, snakeCase, property, _123Number); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Name {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); - sb.append(" property: ").append(toIndentedString(property)).append("\n"); - sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java deleted file mode 100644 index e6dbf3139e2..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; -import javax.validation.constraints.*; -/** - * NumberOnly - */ - -public class NumberOnly { - @JsonProperty("JustNumber") - private BigDecimal justNumber = null; - - public NumberOnly justNumber(BigDecimal justNumber) { - this.justNumber = justNumber; - return this; - } - - /** - * Get justNumber - * @return justNumber - **/ - @ApiModelProperty(value = "") - public BigDecimal getJustNumber() { - return justNumber; - } - - public void setJustNumber(BigDecimal justNumber) { - this.justNumber = justNumber; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NumberOnly numberOnly = (NumberOnly) o; - return Objects.equals(this.justNumber, numberOnly.justNumber); - } - - @Override - public int hashCode() { - return Objects.hash(justNumber); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NumberOnly {\n"); - - sb.append(" justNumber: ").append(toIndentedString(justNumber)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java deleted file mode 100644 index 41dec079587..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java +++ /dev/null @@ -1,224 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.joda.time.DateTime; -import javax.validation.constraints.*; -/** - * Order - */ - -public class Order { - @JsonProperty("id") - private Long id = null; - - @JsonProperty("petId") - private Long petId = null; - - @JsonProperty("quantity") - private Integer quantity = null; - - @JsonProperty("shipDate") - private DateTime shipDate = null; - - /** - * Order Status - */ - public enum StatusEnum { - PLACED("placed"), - - APPROVED("approved"), - - DELIVERED("delivered"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("status") - private StatusEnum status = null; - - @JsonProperty("complete") - private Boolean complete = false; - - public Order id(Long id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Order petId(Long petId) { - this.petId = petId; - return this; - } - - /** - * Get petId - * @return petId - **/ - @ApiModelProperty(value = "") - public Long getPetId() { - return petId; - } - - public void setPetId(Long petId) { - this.petId = petId; - } - - public Order quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - /** - * Get quantity - * @return quantity - **/ - @ApiModelProperty(value = "") - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - public Order shipDate(DateTime shipDate) { - this.shipDate = shipDate; - return this; - } - - /** - * Get shipDate - * @return shipDate - **/ - @ApiModelProperty(value = "") - public DateTime getShipDate() { - return shipDate; - } - - public void setShipDate(DateTime shipDate) { - this.shipDate = shipDate; - } - - public Order status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * Order Status - * @return status - **/ - @ApiModelProperty(value = "Order Status") - public StatusEnum getStatus() { - return status; - } - - public void setStatus(StatusEnum status) { - this.status = status; - } - - public Order complete(Boolean complete) { - this.complete = complete; - return this; - } - - /** - * Get complete - * @return complete - **/ - @ApiModelProperty(value = "") - public Boolean getComplete() { - return complete; - } - - public void setComplete(Boolean complete) { - this.complete = complete; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Order order = (Order) o; - return Objects.equals(this.id, order.id) && - Objects.equals(this.petId, order.petId) && - Objects.equals(this.quantity, order.quantity) && - Objects.equals(this.shipDate, order.shipDate) && - Objects.equals(this.status, order.status) && - Objects.equals(this.complete, order.complete); - } - - @Override - public int hashCode() { - return Objects.hash(id, petId, quantity, shipDate, status, complete); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java deleted file mode 100644 index 5f0075e4457..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import com.fasterxml.jackson.annotation.JsonCreator; - -/** - * Gets or Sets OuterEnum - */ -public enum OuterEnum { - - PLACED("placed"), - - APPROVED("approved"), - - DELIVERED("delivered"); - - private String value; - - OuterEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static OuterEnum fromValue(String text) { - for (OuterEnum b : OuterEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java deleted file mode 100644 index b013846b4d6..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java +++ /dev/null @@ -1,242 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Category; -import io.swagger.model.Tag; -import java.util.ArrayList; -import java.util.List; -import javax.validation.constraints.*; -/** - * Pet - */ - -public class Pet { - @JsonProperty("id") - private Long id = null; - - @JsonProperty("category") - private Category category = null; - - @JsonProperty("name") - private String name = null; - - @JsonProperty("photoUrls") - private List photoUrls = new ArrayList(); - - @JsonProperty("tags") - private List tags = null; - - /** - * pet status in the store - */ - public enum StatusEnum { - AVAILABLE("available"), - - PENDING("pending"), - - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } - - @JsonProperty("status") - private StatusEnum status = null; - - public Pet id(Long id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Pet category(Category category) { - this.category = category; - return this; - } - - /** - * Get category - * @return category - **/ - @ApiModelProperty(value = "") - public Category getCategory() { - return category; - } - - public void setCategory(Category category) { - this.category = category; - } - - public Pet name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @ApiModelProperty(example = "doggie", required = true, value = "") - @NotNull - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Pet photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - public Pet addPhotoUrlsItem(String photoUrlsItem) { - this.photoUrls.add(photoUrlsItem); - return this; - } - - /** - * Get photoUrls - * @return photoUrls - **/ - @ApiModelProperty(required = true, value = "") - @NotNull - public List getPhotoUrls() { - return photoUrls; - } - - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - public Pet tags(List tags) { - this.tags = tags; - return this; - } - - public Pet addTagsItem(Tag tagsItem) { - if (this.tags == null) { - this.tags = new ArrayList(); - } - this.tags.add(tagsItem); - return this; - } - - /** - * Get tags - * @return tags - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public Pet status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * pet status in the store - * @return status - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Pet pet = (Pet) o; - return Objects.equals(this.id, pet.id) && - Objects.equals(this.category, pet.category) && - Objects.equals(this.name, pet.name) && - Objects.equals(this.photoUrls, pet.photoUrls) && - Objects.equals(this.tags, pet.tags) && - Objects.equals(this.status, pet.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java deleted file mode 100644 index 47700659fd2..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * ReadOnlyFirst - */ - -public class ReadOnlyFirst { - @JsonProperty("bar") - private String bar = null; - - @JsonProperty("baz") - private String baz = null; - - public ReadOnlyFirst bar(String bar) { - this.bar = bar; - return this; - } - - /** - * Get bar - * @return bar - **/ - @ApiModelProperty(readOnly = true, value = "") - public String getBar() { - return bar; - } - - public void setBar(String bar) { - this.bar = bar; - } - - public ReadOnlyFirst baz(String baz) { - this.baz = baz; - return this; - } - - /** - * Get baz - * @return baz - **/ - @ApiModelProperty(value = "") - public String getBaz() { - return baz; - } - - public void setBaz(String baz) { - this.baz = baz; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; - return Objects.equals(this.bar, readOnlyFirst.bar) && - Objects.equals(this.baz, readOnlyFirst.baz); - } - - @Override - public int hashCode() { - return Objects.hash(bar, baz); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ReadOnlyFirst {\n"); - - sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); - sb.append(" baz: ").append(toIndentedString(baz)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java deleted file mode 100644 index 880d70599b0..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * SpecialModelName - */ - -public class SpecialModelName { - @JsonProperty("$special[property.name]") - private Long specialPropertyName = null; - - public SpecialModelName specialPropertyName(Long specialPropertyName) { - this.specialPropertyName = specialPropertyName; - return this; - } - - /** - * Get specialPropertyName - * @return specialPropertyName - **/ - @ApiModelProperty(value = "") - public Long getSpecialPropertyName() { - return specialPropertyName; - } - - public void setSpecialPropertyName(Long specialPropertyName) { - this.specialPropertyName = specialPropertyName; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SpecialModelName specialModelName = (SpecialModelName) o; - return Objects.equals(this.specialPropertyName, specialModelName.specialPropertyName); - } - - @Override - public int hashCode() { - return Objects.hash(specialPropertyName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SpecialModelName {\n"); - - sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java deleted file mode 100644 index 298085317a4..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java +++ /dev/null @@ -1,97 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * Tag - */ - -public class Tag { - @JsonProperty("id") - private Long id = null; - - @JsonProperty("name") - private String name = null; - - public Tag id(Long id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Tag name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * @return name - **/ - @ApiModelProperty(value = "") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Tag tag = (Tag) o; - return Objects.equals(this.id, tag.id) && - Objects.equals(this.name, tag.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java deleted file mode 100644 index 8e40f7e0594..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java +++ /dev/null @@ -1,235 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.*; -/** - * User - */ - -public class User { - @JsonProperty("id") - private Long id = null; - - @JsonProperty("username") - private String username = null; - - @JsonProperty("firstName") - private String firstName = null; - - @JsonProperty("lastName") - private String lastName = null; - - @JsonProperty("email") - private String email = null; - - @JsonProperty("password") - private String password = null; - - @JsonProperty("phone") - private String phone = null; - - @JsonProperty("userStatus") - private Integer userStatus = null; - - public User id(Long id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public User username(String username) { - this.username = username; - return this; - } - - /** - * Get username - * @return username - **/ - @ApiModelProperty(value = "") - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - /** - * Get firstName - * @return firstName - **/ - @ApiModelProperty(value = "") - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - /** - * Get lastName - * @return lastName - **/ - @ApiModelProperty(value = "") - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public User email(String email) { - this.email = email; - return this; - } - - /** - * Get email - * @return email - **/ - @ApiModelProperty(value = "") - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public User password(String password) { - this.password = password; - return this; - } - - /** - * Get password - * @return password - **/ - @ApiModelProperty(value = "") - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public User phone(String phone) { - this.phone = phone; - return this; - } - - /** - * Get phone - * @return phone - **/ - @ApiModelProperty(value = "") - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - /** - * User Status - * @return userStatus - **/ - @ApiModelProperty(value = "User Status") - public Integer getUserStatus() { - return userStatus; - } - - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User user = (User) o; - return Objects.equals(this.id, user.id) && - Objects.equals(this.username, user.username) && - Objects.equals(this.firstName, user.firstName) && - Objects.equals(this.lastName, user.lastName) && - Objects.equals(this.email, user.email) && - Objects.equals(this.password, user.password) && - Objects.equals(this.phone, user.phone) && - Objects.equals(this.userStatus, user.userStatus); - } - - @Override - public int hashCode() { - return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties b/samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties deleted file mode 100644 index a72d110dea9..00000000000 --- a/samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.contextPath=/v2 -server.port=80 -spring.jackson.date-format=io.swagger.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false \ No newline at end of file diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java index 2caea165cfe..0464f5d15a5 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -32,7 +33,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + default ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java index 91dda49d6df..a3043c39b14 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java @@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -31,12 +33,13 @@ public class FakeApiController implements FakeApi { this.delegate = delegate; } - - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + @RequestHeader("Accept") + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client bodyString accept) throws IOException { // do some magic! return delegate.testClientModel(body); } + @RequestHeader("Accept") public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, @@ -50,11 +53,12 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime, @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallbackString accept) { // do some magic! return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } + @RequestHeader("Accept") public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, @@ -62,7 +66,7 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDoubleString accept) { // do some magic! return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java index f310e2cdc0d..4f3a278304c 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -73,7 +74,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + default ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException { // do some magic! return new ResponseEntity>(HttpStatus.OK); } @@ -92,7 +93,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + default ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException { // do some magic! return new ResponseEntity>(HttpStatus.OK); } @@ -109,7 +110,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -168,7 +169,7 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java index 3c23ed5674a..4a9ec7142b1 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -30,48 +32,55 @@ public class PetApiController implements PetApi { this.delegate = delegate; } - - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + @RequestHeader("Accept") + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet bodyString accept) { // do some magic! return delegate.addPet(body); } + @RequestHeader("Accept") public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKeyString accept) { // do some magic! return delegate.deletePet(petId, apiKey); } - public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + @RequestHeader("Accept") + public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List statusString accept) throws IOException { // do some magic! return delegate.findPetsByStatus(status); } - public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + @RequestHeader("Accept") + public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tagsString accept) throws IOException { // do some magic! return delegate.findPetsByTags(tags); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + @RequestHeader("Accept") + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petIdString accept) throws IOException { // do some magic! return delegate.getPetById(petId); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + @RequestHeader("Accept") + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet bodyString accept) { // do some magic! return delegate.updatePet(body); } + @RequestHeader("Accept") public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String statusString accept) { // do some magic! return delegate.updatePetWithForm(petId, name, status); } + @RequestHeader("Accept") public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileString accept) throws IOException { // do some magic! return delegate.uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java index c3745d9ec54..7273626269f 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -45,7 +46,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - default ResponseEntity> getInventory() { + default ResponseEntity> getInventory() throws IOException { // do some magic! return new ResponseEntity>(HttpStatus.OK); } @@ -60,7 +61,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + default ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -74,7 +75,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + default ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java index 9ca8e80b316..2985da15528 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -29,23 +31,26 @@ public class StoreApiController implements StoreApi { this.delegate = delegate; } - - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { + @RequestHeader("Accept") + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderIdString accept) { // do some magic! return delegate.deleteOrder(orderId); } - public ResponseEntity> getInventory() { + @RequestHeader("Accept") + public ResponseEntity> getInventory(String accept) throws IOException { // do some magic! return delegate.getInventory(); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + @RequestHeader("Accept") + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderIdString accept) throws IOException { // do some magic! return delegate.getOrderById(orderId); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + @RequestHeader("Accept") + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order bodyString accept) throws IOException { // do some magic! return delegate.placeOrder(body); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java index 8bb822cf45a..e4cfd9df832 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -84,7 +85,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -98,7 +99,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + default ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java index 7eafb8b6745..cc95ebc5af8 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -29,45 +31,52 @@ public class UserApiController implements UserApi { this.delegate = delegate; } - - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + @RequestHeader("Accept") + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User bodyString accept) { // do some magic! return delegate.createUser(body); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + @RequestHeader("Accept") + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List bodyString accept) { // do some magic! return delegate.createUsersWithArrayInput(body); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + @RequestHeader("Accept") + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List bodyString accept) { // do some magic! return delegate.createUsersWithListInput(body); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { + @RequestHeader("Accept") + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String usernameString accept) { // do some magic! return delegate.deleteUser(username); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + @RequestHeader("Accept") + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String usernameString accept) throws IOException { // do some magic! return delegate.getUserByName(username); } + @RequestHeader("Accept") public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String passwordString accept) throws IOException { // do some magic! return delegate.loginUser(username, password); } - public ResponseEntity logoutUser() { + @RequestHeader("Accept") + public ResponseEntity logoutUser(String accept) { // do some magic! return delegate.logoutUser(); } + @RequestHeader("Accept") public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User bodyString accept) { // do some magic! return delegate.updateUser(username, body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java index b0ed6f9a514..05783d1f44b 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -31,7 +32,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException; @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java index f8dd3f68a57..8ed565d18ce 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java @@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -31,12 +33,13 @@ public class FakeApiController implements FakeApi { this.delegate = delegate; } - - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + @RequestHeader("Accept") + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client bodyString accept) throws IOException { // do some magic! return delegate.testClientModel(body); } + @RequestHeader("Accept") public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, @@ -50,11 +53,12 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime, @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallbackString accept) { // do some magic! return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } + @RequestHeader("Accept") public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, @@ -62,7 +66,7 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDoubleString accept) { // do some magic! return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java index 3cf98279345..59846383b86 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -66,7 +67,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); + ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException; @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -82,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException; @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -96,7 +97,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException; @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @@ -146,6 +147,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException; } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java index 3c23ed5674a..4a9ec7142b1 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -30,48 +32,55 @@ public class PetApiController implements PetApi { this.delegate = delegate; } - - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + @RequestHeader("Accept") + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet bodyString accept) { // do some magic! return delegate.addPet(body); } + @RequestHeader("Accept") public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKeyString accept) { // do some magic! return delegate.deletePet(petId, apiKey); } - public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + @RequestHeader("Accept") + public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List statusString accept) throws IOException { // do some magic! return delegate.findPetsByStatus(status); } - public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + @RequestHeader("Accept") + public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tagsString accept) throws IOException { // do some magic! return delegate.findPetsByTags(tags); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + @RequestHeader("Accept") + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petIdString accept) throws IOException { // do some magic! return delegate.getPetById(petId); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + @RequestHeader("Accept") + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet bodyString accept) { // do some magic! return delegate.updatePet(body); } + @RequestHeader("Accept") public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String statusString accept) { // do some magic! return delegate.updatePetWithForm(petId, name, status); } + @RequestHeader("Accept") public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileString accept) throws IOException { // do some magic! return delegate.uploadFile(petId, additionalMetadata, file); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java index 8b080a440dd..7301912a9c8 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -41,7 +42,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory(); + ResponseEntity> getInventory() throws IOException; @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -53,7 +54,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId); + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException; @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @@ -64,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException; } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java index 9ca8e80b316..2985da15528 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -29,23 +31,26 @@ public class StoreApiController implements StoreApi { this.delegate = delegate; } - - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { + @RequestHeader("Accept") + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderIdString accept) { // do some magic! return delegate.deleteOrder(orderId); } - public ResponseEntity> getInventory() { + @RequestHeader("Accept") + public ResponseEntity> getInventory(String accept) throws IOException { // do some magic! return delegate.getInventory(); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + @RequestHeader("Accept") + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderIdString accept) throws IOException { // do some magic! return delegate.getOrderById(orderId); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + @RequestHeader("Accept") + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order bodyString accept) throws IOException { // do some magic! return delegate.placeOrder(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java index 4993fa21bfd..7d6729c23b9 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -71,7 +72,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException; @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @@ -82,7 +83,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException; @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java index 7eafb8b6745..cc95ebc5af8 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -29,45 +31,52 @@ public class UserApiController implements UserApi { this.delegate = delegate; } - - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + @RequestHeader("Accept") + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User bodyString accept) { // do some magic! return delegate.createUser(body); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + @RequestHeader("Accept") + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List bodyString accept) { // do some magic! return delegate.createUsersWithArrayInput(body); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + @RequestHeader("Accept") + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List bodyString accept) { // do some magic! return delegate.createUsersWithListInput(body); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { + @RequestHeader("Accept") + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String usernameString accept) { // do some magic! return delegate.deleteUser(username); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + @RequestHeader("Accept") + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String usernameString accept) throws IOException { // do some magic! return delegate.getUserByName(username); } + @RequestHeader("Accept") public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String passwordString accept) throws IOException { // do some magic! return delegate.loginUser(username, password); } - public ResponseEntity logoutUser() { + @RequestHeader("Accept") + public ResponseEntity logoutUser(String accept) { // do some magic! return delegate.logoutUser(); } + @RequestHeader("Accept") public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User bodyString accept) { // do some magic! return delegate.updateUser(username, body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java index b0ed6f9a514..5ad1ca0d95c 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -31,7 +32,7 @@ public interface FakeApi { produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body); + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { @@ -45,7 +46,7 @@ public interface FakeApi { produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback); + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader("Accept") String accept); @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = Void.class, tags={ "fake", }) @@ -57,6 +58,6 @@ public interface FakeApi { produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble); + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader("Accept") String accept); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java index 5cf609a4ae0..853d2fa2e22 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java @@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -24,11 +26,16 @@ import javax.validation.Valid; @Controller public class FakeApiController implements FakeApi { - - - - public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) { + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"aeiou\"}",Client.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } @@ -45,7 +52,8 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime, @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, - @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -57,7 +65,8 @@ public class FakeApiController implements FakeApi { @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, - @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java index 3cf98279345..ea6fbde10ac 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -35,7 +36,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { @@ -50,7 +51,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader("Accept") String accept); @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -66,7 +67,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status); + ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @@ -82,7 +83,7 @@ public interface PetApi { @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @@ -96,7 +97,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @@ -114,7 +115,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body); + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { @@ -130,7 +131,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status); + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader("Accept") String accept); @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @@ -146,6 +147,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, @RequestHeader("Accept") String accept) throws IOException; } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java index 973055a2f11..f02c2e76a8b 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -23,51 +25,96 @@ import javax.validation.Valid; @Controller public class PetApiController implements PetApi { - - - - public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) { + public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou",List.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"} ]",List.class), HttpStatus.OK); + } + return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { + public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou",List.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"} ]",List.class), HttpStatus.OK); + } + return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou",Pet.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"}",Pet.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"aeiou\", \"message\" : \"aeiou\"}",ModelApiResponse.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java index 8b080a440dd..beaa348db1c 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -29,7 +30,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId); + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader("Accept") String accept); @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -41,7 +42,7 @@ public interface StoreApi { @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - ResponseEntity> getInventory(); + ResponseEntity> getInventory( @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) @@ -53,7 +54,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId); + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @@ -64,6 +65,6 @@ public interface StoreApi { @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body); + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader("Accept") String accept) throws IOException; } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java index 472bda2ada0..9587daf4673 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -22,26 +24,55 @@ import javax.validation.Valid; @Controller public class StoreApiController implements StoreApi { - - - - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity> getInventory() { + public ResponseEntity> getInventory(@RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}",Map.class), HttpStatus.OK); + } + return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) { + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true",Order.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}",Order.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) { + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true",Order.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}",Order.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java index 4993fa21bfd..e32fdff69b4 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.List; import javax.validation.constraints.*; @@ -28,7 +29,7 @@ public interface UserApi { @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body); + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @@ -38,7 +39,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @@ -48,7 +49,7 @@ public interface UserApi { @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body); + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept); @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @@ -59,7 +60,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept); @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) @@ -71,7 +72,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @@ -82,7 +83,7 @@ public interface UserApi { @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, @RequestHeader("Accept") String accept) throws IOException; @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) @@ -92,7 +93,7 @@ public interface UserApi { @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity logoutUser(); + ResponseEntity logoutUser( @RequestHeader("Accept") String accept); @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @@ -103,6 +104,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java index 00d7e5deba1..03a6894d2dd 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import java.util.List; @@ -22,47 +24,73 @@ import javax.validation.Valid; @Controller public class UserApiController implements UserApi { - - - - public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123",User.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"aeiou\", \"lastName\" : \"aeiou\", \"password\" : \"aeiou\", \"userStatus\" : 6, \"phone\" : \"aeiou\", \"id\" : 0, \"email\" : \"aeiou\", \"username\" : \"aeiou\"}",User.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, + @RequestHeader("Accept") String accept) throws IOException { // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue("aeiou",String.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("\"aeiou\"",String.class), HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity logoutUser() { + public ResponseEntity logoutUser(@RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, + @RequestHeader("Accept") String accept) { // do some magic! return new ResponseEntity(HttpStatus.OK); } From a1e745bdda308f88d88b7b3e45c47e6bddea2e5a Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 19 Apr 2017 01:09:14 +0800 Subject: [PATCH 20/31] add back petstore sample for spring boot with bean validation --- .../src/main/java/io/swagger/api/FakeApi.java | 9 +- .../src/main/java/io/swagger/api/PetApi.java | 24 +- .../main/java/io/swagger/api/StoreApi.java | 12 +- .../src/main/java/io/swagger/api/UserApi.java | 24 +- .../.swagger-codegen-ignore | 23 ++ .../springboot-beanvalidation/pom.xml | 73 ++++ .../java/io/swagger/RFC3339DateFormat.java | 20 + .../java/io/swagger/Swagger2SpringBoot.java | 36 ++ .../java/io/swagger/api/ApiException.java | 10 + .../java/io/swagger/api/ApiOriginFilter.java | 27 ++ .../io/swagger/api/ApiResponseMessage.java | 69 ++++ .../src/main/java/io/swagger/api/FakeApi.java | 60 +++ .../io/swagger/api/FakeApiController.java | 74 ++++ .../io/swagger/api/NotFoundException.java | 10 + .../src/main/java/io/swagger/api/PetApi.java | 144 +++++++ .../java/io/swagger/api/PetApiController.java | 121 ++++++ .../main/java/io/swagger/api/StoreApi.java | 66 ++++ .../io/swagger/api/StoreApiController.java | 79 ++++ .../src/main/java/io/swagger/api/UserApi.java | 101 +++++ .../io/swagger/api/UserApiController.java | 98 +++++ .../swagger/configuration/HomeController.java | 16 + .../SwaggerDocumentationConfig.java | 40 ++ .../model/AdditionalPropertiesClass.java | 116 ++++++ .../main/java/io/swagger/model/Animal.java | 105 +++++ .../java/io/swagger/model/AnimalFarm.java | 50 +++ .../model/ArrayOfArrayOfNumberOnly.java | 85 ++++ .../io/swagger/model/ArrayOfNumberOnly.java | 85 ++++ .../main/java/io/swagger/model/ArrayTest.java | 147 +++++++ .../java/io/swagger/model/Capitalization.java | 189 +++++++++ .../src/main/java/io/swagger/model/Cat.java | 76 ++++ .../main/java/io/swagger/model/Category.java | 97 +++++ .../java/io/swagger/model/ClassModel.java | 75 ++++ .../main/java/io/swagger/model/Client.java | 74 ++++ .../src/main/java/io/swagger/model/Dog.java | 76 ++++ .../java/io/swagger/model/EnumArrays.java | 170 ++++++++ .../main/java/io/swagger/model/EnumClass.java | 41 ++ .../main/java/io/swagger/model/EnumTest.java | 240 ++++++++++++ .../java/io/swagger/model/FormatTest.java | 368 ++++++++++++++++++ .../io/swagger/model/HasOnlyReadOnly.java | 97 +++++ .../main/java/io/swagger/model/MapTest.java | 148 +++++++ ...ropertiesAndAdditionalPropertiesClass.java | 134 +++++++ .../io/swagger/model/Model200Response.java | 98 +++++ .../io/swagger/model/ModelApiResponse.java | 120 ++++++ .../java/io/swagger/model/ModelReturn.java | 75 ++++ .../src/main/java/io/swagger/model/Name.java | 145 +++++++ .../java/io/swagger/model/NumberOnly.java | 75 ++++ .../src/main/java/io/swagger/model/Order.java | 224 +++++++++++ .../main/java/io/swagger/model/OuterEnum.java | 41 ++ .../src/main/java/io/swagger/model/Pet.java | 242 ++++++++++++ .../java/io/swagger/model/ReadOnlyFirst.java | 97 +++++ .../io/swagger/model/SpecialModelName.java | 74 ++++ .../src/main/java/io/swagger/model/Tag.java | 97 +++++ .../src/main/java/io/swagger/model/User.java | 235 +++++++++++ .../src/main/resources/application.properties | 5 + 54 files changed, 4991 insertions(+), 46 deletions(-) create mode 100644 samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore create mode 100644 samples/server/petstore/springboot-beanvalidation/pom.xml create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java index a08daecd72b..83e1a78e6bd 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java @@ -29,12 +29,11 @@ public interface FakeApi { @ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) - @RequestMapping(value = "/fake", produces = { "application/json" }, consumes = { "application/json" }, method = RequestMethod.PATCH) - default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) throws IOException { + default CompletableFuture> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -46,12 +45,11 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/fake", produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, method = RequestMethod.POST) - default CompletableFuture> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback) { + default CompletableFuture> testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) OffsetDateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -61,12 +59,11 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request", response = Void.class), @ApiResponse(code = 404, message = "Not found", response = Void.class) }) - @RequestMapping(value = "/fake", produces = { "*/*" }, consumes = { "*/*" }, method = RequestMethod.GET) - default CompletableFuture> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble) { + default CompletableFuture> testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java index ed72275231e..a261cf7d4a4 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java @@ -33,12 +33,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - @RequestMapping(value = "/pet", produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.POST) - default CompletableFuture> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + default CompletableFuture> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -52,11 +51,10 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) - @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -71,11 +69,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) - @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status) throws IOException { + default CompletableFuture>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -90,11 +87,10 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) - @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) throws IOException { + default CompletableFuture>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -107,11 +103,10 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) - @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException { + default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -127,12 +122,11 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 404, message = "Pet not found", response = Void.class), @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) - @RequestMapping(value = "/pet", produces = { "application/xml", "application/json" }, consumes = { "application/json", "application/xml" }, method = RequestMethod.PUT) - default CompletableFuture> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { + default CompletableFuture> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -146,12 +140,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status) { + default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -165,12 +158,11 @@ public interface PetApi { }, tags={ "pet", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) throws IOException { + default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java index 9c0c9015fa5..3039796d0c5 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java @@ -28,11 +28,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) - @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId) { + default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -43,11 +42,10 @@ public interface StoreApi { }, tags={ "store", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) - @RequestMapping(value = "/store/inventory", produces = { "application/json" }, method = RequestMethod.GET) - default CompletableFuture>> getInventory() throws IOException { + default CompletableFuture>> getInventory( @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -58,11 +56,10 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) - @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId) throws IOException { + default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -72,11 +69,10 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) - @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException { + default CompletableFuture> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java index 051b14989e6..f4d9d3dca8f 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java @@ -27,11 +27,10 @@ public interface UserApi { @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body) { + default CompletableFuture> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -40,11 +39,10 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + default CompletableFuture> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -53,11 +51,10 @@ public interface UserApi { @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, method = RequestMethod.POST) - default CompletableFuture> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body) { + default CompletableFuture> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -67,11 +64,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { + default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -82,11 +78,10 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @ApiResponse(code = 404, message = "User not found", response = User.class) }) - @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException { + default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -96,11 +91,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) - @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException { + default CompletableFuture> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -109,11 +103,10 @@ public interface UserApi { @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> logoutUser() { + default CompletableFuture> logoutUser( @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -123,11 +116,10 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body) { + default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept) { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore b/samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/springboot-beanvalidation/pom.xml b/samples/server/petstore/springboot-beanvalidation/pom.xml new file mode 100644 index 00000000000..5af442938b5 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + io.swagger + spring-boot-beanvalidation + jar + spring-boot-beanvalidation + 1.0.0 + + 1.7 + ${java.version} + ${java.version} + 2.6.1 + + + org.springframework.boot + spring-boot-starter-parent + 1.4.5.RELEASE + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + io.springfox + springfox-swagger2 + ${springfox-version} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + joda-time + joda-time + + + + javax.validation + validation-api + 1.1.0.Final + provided + + + \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java new file mode 100644 index 00000000000..0c3d276d2d4 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/RFC3339DateFormat.java @@ -0,0 +1,20 @@ +package io.swagger; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + +import java.text.FieldPosition; +import java.util.Date; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java new file mode 100644 index 00000000000..75d822f027e --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/Swagger2SpringBoot.java @@ -0,0 +1,36 @@ +package io.swagger; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@SpringBootApplication +@EnableSwagger2 +@ComponentScan(basePackages = "io.swagger") +public class Swagger2SpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(Swagger2SpringBoot.class).run(args); + } + + class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java new file mode 100644 index 00000000000..97e535d3c21 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + + +public class ApiException extends Exception{ + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java new file mode 100644 index 00000000000..62646761f5a --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -0,0 +1,27 @@ +package io.swagger.api; + +import java.io.IOException; + +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + + +public class ApiOriginFilter implements javax.servlet.Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java new file mode 100644 index 00000000000..162678c57e3 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package io.swagger.api; + +import javax.xml.bind.annotation.XmlTransient; + + +@javax.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java new file mode 100644 index 00000000000..d8b307a1f23 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java @@ -0,0 +1,60 @@ +package io.swagger.api; + +import java.math.BigDecimal; +import io.swagger.model.Client; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; + +import java.util.List; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "fake", description = "the fake API") +public interface FakeApi { + + @ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + @RequestMapping(value = "/fake", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", response = Void.class, authorizations = { + @Authorization(value = "http_basic_test") + }, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + @RequestMapping(value = "/fake", + produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, + consumes = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number,@ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double,@ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter,@ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte,@ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer,@ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32,@ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64,@ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float,@ApiParam(value = "None") @RequestPart(value="string", required=false) String string,@ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary,@ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date,@ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime,@ApiParam(value = "None") @RequestPart(value="password", required=false) String password,@ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", response = Void.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid request", response = Void.class), + @ApiResponse(code = 404, message = "Not found", response = Void.class) }) + @RequestMapping(value = "/fake", + produces = { "*/*" }, + consumes = { "*/*" }, + method = RequestMethod.GET) + ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader("Accept") String accept); + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java new file mode 100644 index 00000000000..5bac24daffa --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java @@ -0,0 +1,74 @@ +package io.swagger.api; + +import java.math.BigDecimal; +import io.swagger.model.Client; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; + +import java.util.List; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class FakeApiController implements FakeApi { + public ResponseEntity testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"client\" : \"aeiou\"}", Client.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity testEndpointParameters(@ApiParam(value = "None", required=true) @RequestPart(value="number", required=true) BigDecimal number, + @ApiParam(value = "None", required=true) @RequestPart(value="double", required=true) Double _double, + @ApiParam(value = "None", required=true) @RequestPart(value="pattern_without_delimiter", required=true) String patternWithoutDelimiter, + @ApiParam(value = "None", required=true) @RequestPart(value="byte", required=true) byte[] _byte, + @ApiParam(value = "None") @RequestPart(value="integer", required=false) Integer integer, + @ApiParam(value = "None") @RequestPart(value="int32", required=false) Integer int32, + @ApiParam(value = "None") @RequestPart(value="int64", required=false) Long int64, + @ApiParam(value = "None") @RequestPart(value="float", required=false) Float _float, + @ApiParam(value = "None") @RequestPart(value="string", required=false) String string, + @ApiParam(value = "None") @RequestPart(value="binary", required=false) byte[] binary, + @ApiParam(value = "None") @RequestPart(value="date", required=false) LocalDate date, + @ApiParam(value = "None") @RequestPart(value="dateTime", required=false) DateTime dateTime, + @ApiParam(value = "None") @RequestPart(value="password", required=false) String password, + @ApiParam(value = "None") @RequestPart(value="callback", required=false) String paramCallback, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray, + @ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString, + @ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray, + @ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString, + @ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray, + @ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString, + @ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger, + @ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java new file mode 100644 index 00000000000..b28b67ea4b2 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/NotFoundException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + + +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..5816fb5b92e --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java @@ -0,0 +1,144 @@ +package io.swagger.api; + +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; +import org.springframework.core.io.Resource; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; + +import java.util.List; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "pet", description = "the pet API") +public interface PetApi { + + @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + @RequestMapping(value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.POST) + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) + @RequestMapping(value = "/pet/findByStatus", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) + @RequestMapping(value = "/pet/findByTags", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { + @Authorization(value = "api_key") + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), + @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Pet not found", response = Void.class), + @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) + @RequestMapping(value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.PUT) + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + consumes = { "application/x-www-form-urlencoded" }, + method = RequestMethod.POST) + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, @RequestHeader("Accept") String accept) throws IOException; + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java new file mode 100644 index 00000000000..220aa32691d --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java @@ -0,0 +1,121 @@ +package io.swagger.api; + +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; +import org.springframework.core.io.Resource; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; + +import java.util.List; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class PetApiController implements PetApi { + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List status, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + } + + return new ResponseEntity>(HttpStatus.OK); + } + + public ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity>(objectMapper.readValue(" 123456789 doggie aeiou aeiou", List.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("[ { \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"} ]", List.class), HttpStatus.OK); + } + + return new ResponseEntity>(HttpStatus.OK); + } + + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 doggie aeiou aeiou", Pet.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"photoUrls\" : [ \"aeiou\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"aeiou\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"aeiou\", \"id\" : 1 } ], \"status\" : \"available\"}", Pet.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"code\" : 0, \"type\" : \"aeiou\", \"message\" : \"aeiou\"}", ModelApiResponse.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..fb8f3d706f5 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java @@ -0,0 +1,66 @@ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; + +import java.util.List; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "store", description = "the store API") +public interface StoreApi { + + @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) + @RequestMapping(value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { + @Authorization(value = "api_key") + }, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) + @RequestMapping(value = "/store/inventory", + produces = { "application/json" }, + method = RequestMethod.GET) + ResponseEntity> getInventory( @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), + @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) + @RequestMapping(value = "/store/order/{order_id}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) + @RequestMapping(value = "/store/order", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, @RequestHeader("Accept") String accept) throws IOException; + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java new file mode 100644 index 00000000000..3eb23194cb1 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java @@ -0,0 +1,79 @@ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; + +import java.util.List; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class StoreApiController implements StoreApi { + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity> getInventory(@RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity>(objectMapper.readValue("{ \"key\" : 0}", Map.class), HttpStatus.OK); + } + + return new ResponseEntity>(HttpStatus.OK); + } + + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true", Order.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}", Order.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..53899d1eddd --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java @@ -0,0 +1,101 @@ +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import io.swagger.annotations.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; + +import java.util.List; +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Api(value = "user", description = "the user API") +public interface UserApi { + + @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user/createWithArray", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user/createWithList", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = User.class), + @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), + @ApiResponse(code = 404, message = "User not found", response = User.class) }) + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = String.class), + @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) + @RequestMapping(value = "/user/login", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, @RequestHeader("Accept") String accept) throws IOException; + + + @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user/logout", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity logoutUser( @RequestHeader("Accept") String accept); + + + @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.PUT) + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader("Accept") String accept); + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java new file mode 100644 index 00000000000..d8cac8d5eb8 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java @@ -0,0 +1,98 @@ +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import io.swagger.annotations.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; + +import java.util.List; + +import javax.validation.constraints.*; +import javax.validation.Valid; + +@Controller +public class UserApiController implements UserApi { + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List body, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue(" 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123", User.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("{ \"firstName\" : \"aeiou\", \"lastName\" : \"aeiou\", \"password\" : \"aeiou\", \"userStatus\" : 6, \"phone\" : \"aeiou\", \"id\" : 0, \"email\" : \"aeiou\", \"username\" : \"aeiou\"}", User.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, + @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password, + @RequestHeader("Accept") String accept) throws IOException { + // do some magic! + + ObjectMapper objectMapper = new ObjectMapper(); + + if (accept != null && accept.contains("application/xml")) { + return new ResponseEntity(objectMapper.readValue("aeiou", String.class), HttpStatus.OK); + } + + if (accept != null && accept.contains("application/json")) { + return new ResponseEntity(objectMapper.readValue("\"aeiou\"", String.class), HttpStatus.OK); + } + + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity logoutUser(@RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, + @RequestHeader("Accept") String accept) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java new file mode 100644 index 00000000000..f8328099284 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/HomeController.java @@ -0,0 +1,16 @@ +package io.swagger.configuration; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Home redirection to swagger api documentation + */ +@Controller +public class HomeController { + @RequestMapping(value = "/") + public String index() { + System.out.println("swagger-ui.html"); + return "redirect:swagger-ui.html"; + } +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java new file mode 100644 index 00000000000..5658793e134 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java @@ -0,0 +1,40 @@ +package io.swagger.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +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.plugins.Docket; + + +@Configuration +public class SwaggerDocumentationConfig { + + ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("Swagger 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("","", "apiteam@swagger.io")) + .build(); + } + + @Bean + public Docket customImplementation(){ + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("io.swagger.api")) + .build() + .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); + } + +} diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java new file mode 100644 index 00000000000..f4cfcadae51 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AdditionalPropertiesClass.java @@ -0,0 +1,116 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.constraints.*; +/** + * AdditionalPropertiesClass + */ + +public class AdditionalPropertiesClass { + @JsonProperty("map_property") + private Map mapProperty = null; + + @JsonProperty("map_of_map_property") + private Map> mapOfMapProperty = null; + + public AdditionalPropertiesClass mapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + return this; + } + + public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) { + if (this.mapProperty == null) { + this.mapProperty = new HashMap(); + } + this.mapProperty.put(key, mapPropertyItem); + return this; + } + + /** + * Get mapProperty + * @return mapProperty + **/ + @ApiModelProperty(value = "") + public Map getMapProperty() { + return mapProperty; + } + + public void setMapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + } + + public AdditionalPropertiesClass mapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + return this; + } + + public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map mapOfMapPropertyItem) { + if (this.mapOfMapProperty == null) { + this.mapOfMapProperty = new HashMap>(); + } + this.mapOfMapProperty.put(key, mapOfMapPropertyItem); + return this; + } + + /** + * Get mapOfMapProperty + * @return mapOfMapProperty + **/ + @ApiModelProperty(value = "") + public Map> getMapOfMapProperty() { + return mapOfMapProperty; + } + + public void setMapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(this.mapProperty, additionalPropertiesClass.mapProperty) && + Objects.equals(this.mapOfMapProperty, additionalPropertiesClass.mapOfMapProperty); + } + + @Override + public int hashCode() { + return Objects.hash(mapProperty, mapOfMapProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapProperty: ").append(toIndentedString(mapProperty)).append("\n"); + sb.append(" mapOfMapProperty: ").append(toIndentedString(mapOfMapProperty)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java new file mode 100644 index 00000000000..a218f0b5542 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Animal.java @@ -0,0 +1,105 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Animal + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "className", visible = true ) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat"), +}) + +public class Animal { + @JsonProperty("className") + private String className = null; + + @JsonProperty("color") + private String color = "red"; + + public Animal className(String className) { + this.className = className; + return this; + } + + /** + * Get className + * @return className + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Animal color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + **/ + @ApiModelProperty(value = "") + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(this.className, animal.className) && + Objects.equals(this.color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java new file mode 100644 index 00000000000..33dc04699af --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/AnimalFarm.java @@ -0,0 +1,50 @@ +package io.swagger.model; + +import java.util.Objects; +import io.swagger.model.Animal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.*; +/** + * AnimalFarm + */ + +public class AnimalFarm extends ArrayList { + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 00000000000..8f975d8feda --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,85 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.*; +/** + * ArrayOfArrayOfNumberOnly + */ + +public class ArrayOfArrayOfNumberOnly { + @JsonProperty("ArrayArrayNumber") + private List> arrayArrayNumber = null; + + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { + if (this.arrayArrayNumber == null) { + this.arrayArrayNumber = new ArrayList>(); + } + this.arrayArrayNumber.add(arrayArrayNumberItem); + return this; + } + + /** + * Get arrayArrayNumber + * @return arrayArrayNumber + **/ + @ApiModelProperty(value = "") + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java new file mode 100644 index 00000000000..2c556008554 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayOfNumberOnly.java @@ -0,0 +1,85 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.*; +/** + * ArrayOfNumberOnly + */ + +public class ArrayOfNumberOnly { + @JsonProperty("ArrayNumber") + private List arrayNumber = null; + + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { + if (this.arrayNumber == null) { + this.arrayNumber = new ArrayList(); + } + this.arrayNumber.add(arrayNumberItem); + return this; + } + + /** + * Get arrayNumber + * @return arrayNumber + **/ + @ApiModelProperty(value = "") + public List getArrayNumber() { + return arrayNumber; + } + + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java new file mode 100644 index 00000000000..664e319cd35 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ArrayTest.java @@ -0,0 +1,147 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.ReadOnlyFirst; +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.*; +/** + * ArrayTest + */ + +public class ArrayTest { + @JsonProperty("array_of_string") + private List arrayOfString = null; + + @JsonProperty("array_array_of_integer") + private List> arrayArrayOfInteger = null; + + @JsonProperty("array_array_of_model") + private List> arrayArrayOfModel = null; + + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { + if (this.arrayOfString == null) { + this.arrayOfString = new ArrayList(); + } + this.arrayOfString.add(arrayOfStringItem); + return this; + } + + /** + * Get arrayOfString + * @return arrayOfString + **/ + @ApiModelProperty(value = "") + public List getArrayOfString() { + return arrayOfString; + } + + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { + if (this.arrayArrayOfInteger == null) { + this.arrayArrayOfInteger = new ArrayList>(); + } + this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); + return this; + } + + /** + * Get arrayArrayOfInteger + * @return arrayArrayOfInteger + **/ + @ApiModelProperty(value = "") + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { + if (this.arrayArrayOfModel == null) { + this.arrayArrayOfModel = new ArrayList>(); + } + this.arrayArrayOfModel.add(arrayArrayOfModelItem); + return this; + } + + /** + * Get arrayArrayOfModel + * @return arrayArrayOfModel + **/ + @ApiModelProperty(value = "") + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) && + Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java new file mode 100644 index 00000000000..d7ad5642ccf --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Capitalization.java @@ -0,0 +1,189 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Capitalization + */ + +public class Capitalization { + @JsonProperty("smallCamel") + private String smallCamel = null; + + @JsonProperty("CapitalCamel") + private String capitalCamel = null; + + @JsonProperty("small_Snake") + private String smallSnake = null; + + @JsonProperty("Capital_Snake") + private String capitalSnake = null; + + @JsonProperty("SCA_ETH_Flow_Points") + private String scAETHFlowPoints = null; + + @JsonProperty("ATT_NAME") + private String ATT_NAME = null; + + public Capitalization smallCamel(String smallCamel) { + this.smallCamel = smallCamel; + return this; + } + + /** + * Get smallCamel + * @return smallCamel + **/ + @ApiModelProperty(value = "") + public String getSmallCamel() { + return smallCamel; + } + + public void setSmallCamel(String smallCamel) { + this.smallCamel = smallCamel; + } + + public Capitalization capitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + return this; + } + + /** + * Get capitalCamel + * @return capitalCamel + **/ + @ApiModelProperty(value = "") + public String getCapitalCamel() { + return capitalCamel; + } + + public void setCapitalCamel(String capitalCamel) { + this.capitalCamel = capitalCamel; + } + + public Capitalization smallSnake(String smallSnake) { + this.smallSnake = smallSnake; + return this; + } + + /** + * Get smallSnake + * @return smallSnake + **/ + @ApiModelProperty(value = "") + public String getSmallSnake() { + return smallSnake; + } + + public void setSmallSnake(String smallSnake) { + this.smallSnake = smallSnake; + } + + public Capitalization capitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + return this; + } + + /** + * Get capitalSnake + * @return capitalSnake + **/ + @ApiModelProperty(value = "") + public String getCapitalSnake() { + return capitalSnake; + } + + public void setCapitalSnake(String capitalSnake) { + this.capitalSnake = capitalSnake; + } + + public Capitalization scAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + return this; + } + + /** + * Get scAETHFlowPoints + * @return scAETHFlowPoints + **/ + @ApiModelProperty(value = "") + public String getScAETHFlowPoints() { + return scAETHFlowPoints; + } + + public void setScAETHFlowPoints(String scAETHFlowPoints) { + this.scAETHFlowPoints = scAETHFlowPoints; + } + + public Capitalization ATT_NAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + return this; + } + + /** + * Name of the pet + * @return ATT_NAME + **/ + @ApiModelProperty(value = "Name of the pet ") + public String getATTNAME() { + return ATT_NAME; + } + + public void setATTNAME(String ATT_NAME) { + this.ATT_NAME = ATT_NAME; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Capitalization capitalization = (Capitalization) o; + return Objects.equals(this.smallCamel, capitalization.smallCamel) && + Objects.equals(this.capitalCamel, capitalization.capitalCamel) && + Objects.equals(this.smallSnake, capitalization.smallSnake) && + Objects.equals(this.capitalSnake, capitalization.capitalSnake) && + Objects.equals(this.scAETHFlowPoints, capitalization.scAETHFlowPoints) && + Objects.equals(this.ATT_NAME, capitalization.ATT_NAME); + } + + @Override + public int hashCode() { + return Objects.hash(smallCamel, capitalCamel, smallSnake, capitalSnake, scAETHFlowPoints, ATT_NAME); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Capitalization {\n"); + + sb.append(" smallCamel: ").append(toIndentedString(smallCamel)).append("\n"); + sb.append(" capitalCamel: ").append(toIndentedString(capitalCamel)).append("\n"); + sb.append(" smallSnake: ").append(toIndentedString(smallSnake)).append("\n"); + sb.append(" capitalSnake: ").append(toIndentedString(capitalSnake)).append("\n"); + sb.append(" scAETHFlowPoints: ").append(toIndentedString(scAETHFlowPoints)).append("\n"); + sb.append(" ATT_NAME: ").append(toIndentedString(ATT_NAME)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java new file mode 100644 index 00000000000..747e5dc0c7e --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Cat.java @@ -0,0 +1,76 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Animal; +import javax.validation.constraints.*; +/** + * Cat + */ + +public class Cat extends Animal { + @JsonProperty("declawed") + private Boolean declawed = null; + + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + /** + * Get declawed + * @return declawed + **/ + @ApiModelProperty(value = "") + public Boolean getDeclawed() { + return declawed; + } + + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.declawed, cat.declawed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(declawed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java new file mode 100644 index 00000000000..9629da6500e --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Category.java @@ -0,0 +1,97 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Category + */ + +public class Category { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("name") + private String name = null; + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java new file mode 100644 index 00000000000..d69acffefa8 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ClassModel.java @@ -0,0 +1,75 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Model for testing model with \"_class\" property + */ +@ApiModel(description = "Model for testing model with \"_class\" property") + +public class ClassModel { + @JsonProperty("_class") + private String propertyClass = null; + + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(this.propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java new file mode 100644 index 00000000000..f9cec5a225e --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Client.java @@ -0,0 +1,74 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Client + */ + +public class Client { + @JsonProperty("client") + private String client = null; + + public Client client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + **/ + @ApiModelProperty(value = "") + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(this.client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java new file mode 100644 index 00000000000..9057e840fc3 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Dog.java @@ -0,0 +1,76 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Animal; +import javax.validation.constraints.*; +/** + * Dog + */ + +public class Dog extends Animal { + @JsonProperty("breed") + private String breed = null; + + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + **/ + @ApiModelProperty(value = "") + public String getBreed() { + return breed; + } + + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java new file mode 100644 index 00000000000..f904035e482 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumArrays.java @@ -0,0 +1,170 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.*; +/** + * EnumArrays + */ + +public class EnumArrays { + /** + * Gets or Sets justSymbol + */ + public enum JustSymbolEnum { + GREATER_THAN_OR_EQUAL_TO(">="), + + DOLLAR("$"); + + private String value; + + JustSymbolEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static JustSymbolEnum fromValue(String text) { + for (JustSymbolEnum b : JustSymbolEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("just_symbol") + private JustSymbolEnum justSymbol = null; + + /** + * Gets or Sets arrayEnum + */ + public enum ArrayEnumEnum { + FISH("fish"), + + CRAB("crab"); + + private String value; + + ArrayEnumEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ArrayEnumEnum fromValue(String text) { + for (ArrayEnumEnum b : ArrayEnumEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("array_enum") + private List arrayEnum = null; + + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + /** + * Get justSymbol + * @return justSymbol + **/ + @ApiModelProperty(value = "") + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { + if (this.arrayEnum == null) { + this.arrayEnum = new ArrayList(); + } + this.arrayEnum.add(arrayEnumItem); + return this; + } + + /** + * Get arrayEnum + * @return arrayEnum + **/ + @ApiModelProperty(value = "") + public List getArrayEnum() { + return arrayEnum; + } + + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(this.justSymbol, enumArrays.justSymbol) && + Objects.equals(this.arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java new file mode 100644 index 00000000000..cdfc0933c3e --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumClass.java @@ -0,0 +1,41 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Gets or Sets EnumClass + */ +public enum EnumClass { + + _ABC("_abc"), + + _EFG("-efg"), + + _XYZ_("(xyz)"); + + private String value; + + EnumClass(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumClass fromValue(String text) { + for (EnumClass b : EnumClass.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java new file mode 100644 index 00000000000..9f2a0275a6a --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/EnumTest.java @@ -0,0 +1,240 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.OuterEnum; +import javax.validation.constraints.*; +/** + * EnumTest + */ + +public class EnumTest { + /** + * Gets or Sets enumString + */ + public enum EnumStringEnum { + UPPER("UPPER"), + + LOWER("lower"), + + EMPTY(""); + + private String value; + + EnumStringEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumStringEnum fromValue(String text) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("enum_string") + private EnumStringEnum enumString = null; + + /** + * Gets or Sets enumInteger + */ + public enum EnumIntegerEnum { + NUMBER_1(1), + + NUMBER_MINUS_1(-1); + + private Integer value; + + EnumIntegerEnum(Integer value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumIntegerEnum fromValue(String text) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("enum_integer") + private EnumIntegerEnum enumInteger = null; + + /** + * Gets or Sets enumNumber + */ + public enum EnumNumberEnum { + NUMBER_1_DOT_1(1.1), + + NUMBER_MINUS_1_DOT_2(-1.2); + + private Double value; + + EnumNumberEnum(Double value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumNumberEnum fromValue(String text) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("enum_number") + private EnumNumberEnum enumNumber = null; + + @JsonProperty("outerEnum") + private OuterEnum outerEnum = null; + + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + /** + * Get enumString + * @return enumString + **/ + @ApiModelProperty(value = "") + public EnumStringEnum getEnumString() { + return enumString; + } + + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + /** + * Get enumInteger + * @return enumInteger + **/ + @ApiModelProperty(value = "") + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + /** + * Get enumNumber + * @return enumNumber + **/ + @ApiModelProperty(value = "") + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + /** + * Get outerEnum + * @return outerEnum + **/ + @ApiModelProperty(value = "") + public OuterEnum getOuterEnum() { + return outerEnum; + } + + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(this.enumString, enumTest.enumString) && + Objects.equals(this.enumInteger, enumTest.enumInteger) && + Objects.equals(this.enumNumber, enumTest.enumNumber) && + Objects.equals(this.outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java new file mode 100644 index 00000000000..ad8680a3beb --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/FormatTest.java @@ -0,0 +1,368 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.UUID; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import javax.validation.constraints.*; +/** + * FormatTest + */ + +public class FormatTest { + @JsonProperty("integer") + private Integer integer = null; + + @JsonProperty("int32") + private Integer int32 = null; + + @JsonProperty("int64") + private Long int64 = null; + + @JsonProperty("number") + private BigDecimal number = null; + + @JsonProperty("float") + private Float _float = null; + + @JsonProperty("double") + private Double _double = null; + + @JsonProperty("string") + private String string = null; + + @JsonProperty("byte") + private byte[] _byte = null; + + @JsonProperty("binary") + private byte[] binary = null; + + @JsonProperty("date") + private LocalDate date = null; + + @JsonProperty("dateTime") + private DateTime dateTime = null; + + @JsonProperty("uuid") + private UUID uuid = null; + + @JsonProperty("password") + private String password = null; + + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + /** + * Get integer + * minimum: 10 + * maximum: 100 + * @return integer + **/ + @ApiModelProperty(value = "") + @Min(10) @Max(100) public Integer getInteger() { + return integer; + } + + public void setInteger(Integer integer) { + this.integer = integer; + } + + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + /** + * Get int32 + * minimum: 20 + * maximum: 200 + * @return int32 + **/ + @ApiModelProperty(value = "") + @Min(20) @Max(200) public Integer getInt32() { + return int32; + } + + public void setInt32(Integer int32) { + this.int32 = int32; + } + + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + /** + * Get int64 + * @return int64 + **/ + @ApiModelProperty(value = "") + public Long getInt64() { + return int64; + } + + public void setInt64(Long int64) { + this.int64 = int64; + } + + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + /** + * Get number + * minimum: 32.1 + * maximum: 543.2 + * @return number + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + @DecimalMin("32.1") @DecimalMax("543.2") public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + /** + * Get _float + * minimum: 54.3 + * maximum: 987.6 + * @return _float + **/ + @ApiModelProperty(value = "") + @DecimalMin("54.3") @DecimalMax("987.6") public Float getFloat() { + return _float; + } + + public void setFloat(Float _float) { + this._float = _float; + } + + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + /** + * Get _double + * minimum: 67.8 + * maximum: 123.4 + * @return _double + **/ + @ApiModelProperty(value = "") + @DecimalMin("67.8") @DecimalMax("123.4") public Double getDouble() { + return _double; + } + + public void setDouble(Double _double) { + this._double = _double; + } + + public FormatTest string(String string) { + this.string = string; + return this; + } + + /** + * Get string + * @return string + **/ + @ApiModelProperty(value = "") + @Pattern(regexp="/[a-z]/i") public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + /** + * Get _byte + * @return _byte + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + public byte[] getByte() { + return _byte; + } + + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest binary(byte[] binary) { + this.binary = binary; + return this; + } + + /** + * Get binary + * @return binary + **/ + @ApiModelProperty(value = "") + public byte[] getBinary() { + return binary; + } + + public void setBinary(byte[] binary) { + this.binary = binary; + } + + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + /** + * Get date + * @return date + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public FormatTest dateTime(DateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + **/ + @ApiModelProperty(value = "") + public DateTime getDateTime() { + return dateTime; + } + + public void setDateTime(DateTime dateTime) { + this.dateTime = dateTime; + } + + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @ApiModelProperty(value = "") + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public FormatTest password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + @Size(min=10,max=64) public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(this.integer, formatTest.integer) && + Objects.equals(this.int32, formatTest.int32) && + Objects.equals(this.int64, formatTest.int64) && + Objects.equals(this.number, formatTest.number) && + Objects.equals(this._float, formatTest._float) && + Objects.equals(this._double, formatTest._double) && + Objects.equals(this.string, formatTest.string) && + Objects.equals(this._byte, formatTest._byte) && + Objects.equals(this.binary, formatTest.binary) && + Objects.equals(this.date, formatTest.date) && + Objects.equals(this.dateTime, formatTest.dateTime) && + Objects.equals(this.uuid, formatTest.uuid) && + Objects.equals(this.password, formatTest.password); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java new file mode 100644 index 00000000000..a26492e4912 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/HasOnlyReadOnly.java @@ -0,0 +1,97 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * HasOnlyReadOnly + */ + +public class HasOnlyReadOnly { + @JsonProperty("bar") + private String bar = null; + + @JsonProperty("foo") + private String foo = null; + + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + **/ + @ApiModelProperty(readOnly = true, value = "") + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + **/ + @ApiModelProperty(readOnly = true, value = "") + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(this.bar, hasOnlyReadOnly.bar) && + Objects.equals(this.foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java new file mode 100644 index 00000000000..434c3a8f1b5 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MapTest.java @@ -0,0 +1,148 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.constraints.*; +/** + * MapTest + */ + +public class MapTest { + @JsonProperty("map_map_of_string") + private Map> mapMapOfString = null; + + /** + * Gets or Sets inner + */ + public enum InnerEnum { + UPPER("UPPER"), + + LOWER("lower"); + + private String value; + + InnerEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InnerEnum fromValue(String text) { + for (InnerEnum b : InnerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("map_of_enum_string") + private Map mapOfEnumString = null; + + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { + if (this.mapMapOfString == null) { + this.mapMapOfString = new HashMap>(); + } + this.mapMapOfString.put(key, mapMapOfStringItem); + return this; + } + + /** + * Get mapMapOfString + * @return mapMapOfString + **/ + @ApiModelProperty(value = "") + public Map> getMapMapOfString() { + return mapMapOfString; + } + + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { + if (this.mapOfEnumString == null) { + this.mapOfEnumString = new HashMap(); + } + this.mapOfEnumString.put(key, mapOfEnumStringItem); + return this; + } + + /** + * Get mapOfEnumString + * @return mapOfEnumString + **/ + @ApiModelProperty(value = "") + public Map getMapOfEnumString() { + return mapOfEnumString; + } + + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 00000000000..dba1241f6d6 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,134 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Animal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.joda.time.DateTime; +import javax.validation.constraints.*; +/** + * MixedPropertiesAndAdditionalPropertiesClass + */ + +public class MixedPropertiesAndAdditionalPropertiesClass { + @JsonProperty("uuid") + private UUID uuid = null; + + @JsonProperty("dateTime") + private DateTime dateTime = null; + + @JsonProperty("map") + private Map map = null; + + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + /** + * Get uuid + * @return uuid + **/ + @ApiModelProperty(value = "") + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) { + this.dateTime = dateTime; + return this; + } + + /** + * Get dateTime + * @return dateTime + **/ + @ApiModelProperty(value = "") + public DateTime getDateTime() { + return dateTime; + } + + public void setDateTime(DateTime dateTime) { + this.dateTime = dateTime; + } + + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { + if (this.map == null) { + this.map = new HashMap(); + } + this.map.put(key, mapItem); + return this; + } + + /** + * Get map + * @return map + **/ + @ApiModelProperty(value = "") + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java new file mode 100644 index 00000000000..4d47f6c03c9 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Model200Response.java @@ -0,0 +1,98 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Model for testing model name starting with number + */ +@ApiModel(description = "Model for testing model name starting with number") + +public class Model200Response { + @JsonProperty("name") + private Integer name = null; + + @JsonProperty("class") + private String propertyClass = null; + + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + /** + * Get propertyClass + * @return propertyClass + **/ + @ApiModelProperty(value = "") + public String getPropertyClass() { + return propertyClass; + } + + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200Response = (Model200Response) o; + return Objects.equals(this.name, _200Response.name) && + Objects.equals(this.propertyClass, _200Response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..36da9b20d9d --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,120 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * ModelApiResponse + */ + +public class ModelApiResponse { + @JsonProperty("code") + private Integer code = null; + + @JsonProperty("type") + private String type = null; + + @JsonProperty("message") + private String message = null; + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java new file mode 100644 index 00000000000..7ffc24a0144 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ModelReturn.java @@ -0,0 +1,75 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Model for testing reserved words + */ +@ApiModel(description = "Model for testing reserved words") + +public class ModelReturn { + @JsonProperty("return") + private Integer _return = null; + + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + /** + * Get _return + * @return _return + **/ + @ApiModelProperty(value = "") + public Integer getReturn() { + return _return; + } + + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(this._return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java new file mode 100644 index 00000000000..953199166ff --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Name.java @@ -0,0 +1,145 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Model for testing model name same as property name + */ +@ApiModel(description = "Model for testing model name same as property name") + +public class Name { + @JsonProperty("name") + private Integer name = null; + + @JsonProperty("snake_case") + private Integer snakeCase = null; + + @JsonProperty("property") + private String property = null; + + @JsonProperty("123Number") + private Integer _123Number = null; + + public Name name(Integer name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + public Integer getName() { + return name; + } + + public void setName(Integer name) { + this.name = name; + } + + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + /** + * Get snakeCase + * @return snakeCase + **/ + @ApiModelProperty(readOnly = true, value = "") + public Integer getSnakeCase() { + return snakeCase; + } + + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + public Name property(String property) { + this.property = property; + return this; + } + + /** + * Get property + * @return property + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + + public Name _123Number(Integer _123Number) { + this._123Number = _123Number; + return this; + } + + /** + * Get _123Number + * @return _123Number + **/ + @ApiModelProperty(readOnly = true, value = "") + public Integer get123Number() { + return _123Number; + } + + public void set123Number(Integer _123Number) { + this._123Number = _123Number; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.name, name.name) && + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property) && + Objects.equals(this._123Number, name._123Number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123Number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java new file mode 100644 index 00000000000..e6dbf3139e2 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/NumberOnly.java @@ -0,0 +1,75 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import javax.validation.constraints.*; +/** + * NumberOnly + */ + +public class NumberOnly { + @JsonProperty("JustNumber") + private BigDecimal justNumber = null; + + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + /** + * Get justNumber + * @return justNumber + **/ + @ApiModelProperty(value = "") + public BigDecimal getJustNumber() { + return justNumber; + } + + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(this.justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java new file mode 100644 index 00000000000..41dec079587 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Order.java @@ -0,0 +1,224 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.joda.time.DateTime; +import javax.validation.constraints.*; +/** + * Order + */ + +public class Order { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("petId") + private Long petId = null; + + @JsonProperty("quantity") + private Integer quantity = null; + + @JsonProperty("shipDate") + private DateTime shipDate = null; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + @JsonProperty("complete") + private Boolean complete = false; + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + **/ + @ApiModelProperty(value = "") + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + **/ + @ApiModelProperty(value = "") + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order shipDate(DateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + **/ + @ApiModelProperty(value = "") + public DateTime getShipDate() { + return shipDate; + } + + public void setShipDate(DateTime shipDate) { + this.shipDate = shipDate; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Order Status + * @return status + **/ + @ApiModelProperty(value = "Order Status") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + **/ + @ApiModelProperty(value = "") + public Boolean getComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java new file mode 100644 index 00000000000..5f0075e4457 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/OuterEnum.java @@ -0,0 +1,41 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonCreator; + +/** + * Gets or Sets OuterEnum + */ +public enum OuterEnum { + + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + OuterEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OuterEnum fromValue(String text) { + for (OuterEnum b : OuterEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java new file mode 100644 index 00000000000..b013846b4d6 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Pet.java @@ -0,0 +1,242 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +import javax.validation.constraints.*; +/** + * Pet + */ + +public class Pet { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("category") + private Category category = null; + + @JsonProperty("name") + private String name = null; + + @JsonProperty("photoUrls") + private List photoUrls = new ArrayList(); + + @JsonProperty("tags") + private List tags = null; + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + + @JsonProperty("status") + private StatusEnum status = null; + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + @ApiModelProperty(value = "") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "doggie", required = true, value = "") + @NotNull + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + @ApiModelProperty(required = true, value = "") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java new file mode 100644 index 00000000000..47700659fd2 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/ReadOnlyFirst.java @@ -0,0 +1,97 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * ReadOnlyFirst + */ + +public class ReadOnlyFirst { + @JsonProperty("bar") + private String bar = null; + + @JsonProperty("baz") + private String baz = null; + + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + **/ + @ApiModelProperty(readOnly = true, value = "") + public String getBar() { + return bar; + } + + public void setBar(String bar) { + this.bar = bar; + } + + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + /** + * Get baz + * @return baz + **/ + @ApiModelProperty(value = "") + public String getBaz() { + return baz; + } + + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(this.bar, readOnlyFirst.bar) && + Objects.equals(this.baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java new file mode 100644 index 00000000000..880d70599b0 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/SpecialModelName.java @@ -0,0 +1,74 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * SpecialModelName + */ + +public class SpecialModelName { + @JsonProperty("$special[property.name]") + private Long specialPropertyName = null; + + public SpecialModelName specialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + return this; + } + + /** + * Get specialPropertyName + * @return specialPropertyName + **/ + @ApiModelProperty(value = "") + public Long getSpecialPropertyName() { + return specialPropertyName; + } + + public void setSpecialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName specialModelName = (SpecialModelName) o; + return Objects.equals(this.specialPropertyName, specialModelName.specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash(specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java new file mode 100644 index 00000000000..298085317a4 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/Tag.java @@ -0,0 +1,97 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * Tag + */ + +public class Tag { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("name") + private String name = null; + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java new file mode 100644 index 00000000000..8e40f7e0594 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/model/User.java @@ -0,0 +1,235 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; +/** + * User + */ + +public class User { + @JsonProperty("id") + private Long id = null; + + @JsonProperty("username") + private String username = null; + + @JsonProperty("firstName") + private String firstName = null; + + @JsonProperty("lastName") + private String lastName = null; + + @JsonProperty("email") + private String email = null; + + @JsonProperty("password") + private String password = null; + + @JsonProperty("phone") + private String phone = null; + + @JsonProperty("userStatus") + private Integer userStatus = null; + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + @ApiModelProperty(value = "") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @ApiModelProperty(value = "") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @ApiModelProperty(value = "") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @ApiModelProperty(value = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(value = "") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + **/ + @ApiModelProperty(value = "") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + **/ + @ApiModelProperty(value = "User Status") + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties b/samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties new file mode 100644 index 00000000000..a72d110dea9 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/resources/application.properties @@ -0,0 +1,5 @@ +springfox.documentation.swagger.v2.path=/api-docs +server.contextPath=/v2 +server.port=80 +spring.jackson.date-format=io.swagger.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false \ No newline at end of file From d5ac248e4146164bfbfa5c312ebfbba412b16f8d Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 19 Apr 2017 01:56:13 +0800 Subject: [PATCH 21/31] comment out test for spring cloud client for the time being --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b0a70e427b1..620cfa52d80 100644 --- a/pom.xml +++ b/pom.xml @@ -830,7 +830,8 @@ samples/server/petstore/jaxrs-resteasy/joda samples/server/petstore/scalatra samples/server/petstore/spring-mvc - samples/client/petstore/spring-cloud + samples/server/petstore/springboot samples/server/petstore/springboot-beanvalidation samples/server/petstore/jaxrs-cxf From edf9f56e80699186882ebc19bed345191ebe42cf Mon Sep 17 00:00:00 2001 From: Mert Sarac Date: Tue, 18 Apr 2017 23:16:18 +0300 Subject: [PATCH 22/31] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 31cfbf02651..5f4d2b880f7 100644 --- a/README.md +++ b/README.md @@ -794,6 +794,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Stingray](http://www.stingray.com) - [StyleRecipe](http://stylerecipe.co.jp) - [Svenska Spel AB](https://www.svenskaspel.se/) +- [Switch Database](https://www.switchdatabase.com/) - [TaskData](http://www.taskdata.com/) - [ThoughtWorks](https://www.thoughtworks.com) - [Trexle](https://trexle.com/) From 77bb6132f13ac64bfafa4180e1f74bad4174d452 Mon Sep 17 00:00:00 2001 From: weiyang Date: Wed, 19 Apr 2017 15:04:05 +0800 Subject: [PATCH 23/31] [README] Add XSky to company list Signed-off-by: weiyang --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5f4d2b880f7..ced6f545200 100644 --- a/README.md +++ b/README.md @@ -805,6 +805,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Wealthfront](https://www.wealthfront.com/) - [Webever GmbH](https://www.webever.de/) - [WEXO A/S](https://www.wexo.dk/) +- [XSky](http://www.xsky.com/) - [Zalando](https://tech.zalando.com) - [ZEEF.com](https://zeef.com/) From edb80df0ba0d85f0080ea41f6aac730df8eca1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fouilh=C3=A9?= Date: Thu, 20 Apr 2017 16:54:35 +0200 Subject: [PATCH 24/31] fix(swift3): fix infinite loop with inheritance and check if parent decoder exists before calling (#5416) --- .../src/main/resources/swift3/Models.mustache | 6 ++++-- .../PetstoreClient/Classes/Swaggers/Models.swift | 10 +++++++--- .../PetstoreClient/Classes/Swaggers/Models.swift | 10 +++++++--- .../PetstoreClient/Classes/Swaggers/Models.swift | 10 +++++++--- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache index 087559d1e6f..769c02db776 100644 --- a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache @@ -179,7 +179,7 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] {{#discriminator}} // Check discriminator to support inheritance - if let discriminator = sourceDictionary["{{discriminator}}"] as? String, discriminator != "{{classname}}"{ + if let discriminator = sourceDictionary["{{discriminator}}"] as? String, instance == nil && discriminator != "{{classname}}" { return Decoders.decode(clazz: {{classname}}.self, discriminator: discriminator, source: source) } {{/discriminator}} @@ -197,7 +197,9 @@ class Decoders { {{^unwrapRequired}} let result = instance == nil ? {{classname}}() : instance as! {{classname}} {{#parent}} - _ = Decoders.decode(clazz: {{parent}}.self, source: source, instance: result) + if decoders["\({{parent}}.self)"] != nil { + _ = Decoders.decode(clazz: {{parent}}.self, source: source, instance: result) + } {{/parent}} {{#allVars}}{{#isEnum}} if let {{name}} = sourceDictionary["{{baseName}}"] as? {{datatype}} { {{^isContainer}} diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift index d2d50717ba6..dbf9aadf8f2 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift @@ -173,7 +173,7 @@ class Decoders { Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Animal in let sourceDictionary = source as! [AnyHashable: Any] // Check discriminator to support inheritance - if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{ + if let discriminator = sourceDictionary["className"] as? String, instance == nil && discriminator != "Animal" { return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) } @@ -289,7 +289,9 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] let result = instance == nil ? Cat() : instance as! Cat - _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + if decoders["\(Animal.self)"] != nil { + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + } result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) @@ -353,7 +355,9 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] let result = instance == nil ? Dog() : instance as! Dog - _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + if decoders["\(Animal.self)"] != nil { + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + } result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift index d2d50717ba6..dbf9aadf8f2 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift @@ -173,7 +173,7 @@ class Decoders { Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Animal in let sourceDictionary = source as! [AnyHashable: Any] // Check discriminator to support inheritance - if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{ + if let discriminator = sourceDictionary["className"] as? String, instance == nil && discriminator != "Animal" { return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) } @@ -289,7 +289,9 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] let result = instance == nil ? Cat() : instance as! Cat - _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + if decoders["\(Animal.self)"] != nil { + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + } result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) @@ -353,7 +355,9 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] let result = instance == nil ? Dog() : instance as! Dog - _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + if decoders["\(Animal.self)"] != nil { + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + } result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift index d2d50717ba6..dbf9aadf8f2 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift @@ -173,7 +173,7 @@ class Decoders { Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject, instance: AnyObject?) -> Animal in let sourceDictionary = source as! [AnyHashable: Any] // Check discriminator to support inheritance - if let discriminator = sourceDictionary["className"] as? String, discriminator != "Animal"{ + if let discriminator = sourceDictionary["className"] as? String, instance == nil && discriminator != "Animal" { return Decoders.decode(clazz: Animal.self, discriminator: discriminator, source: source) } @@ -289,7 +289,9 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] let result = instance == nil ? Cat() : instance as! Cat - _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + if decoders["\(Animal.self)"] != nil { + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + } result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) @@ -353,7 +355,9 @@ class Decoders { let sourceDictionary = source as! [AnyHashable: Any] let result = instance == nil ? Dog() : instance as! Dog - _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + if decoders["\(Animal.self)"] != nil { + _ = Decoders.decode(clazz: Animal.self, source: source, instance: result) + } result.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"] as AnyObject?) result.color = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["color"] as AnyObject?) From 6ea4b4d6f33ea021d7b930362c032dd0369b5102 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Thu, 20 Apr 2017 10:32:27 -0700 Subject: [PATCH 25/31] fixes #5446 --- modules/swagger-generator/Dockerfile | 2 +- .../src/main/webapp/index.html | 181 ++++++++---------- 2 files changed, 86 insertions(+), 97 deletions(-) diff --git a/modules/swagger-generator/Dockerfile b/modules/swagger-generator/Dockerfile index 0360aa66ce0..ba999000e16 100644 --- a/modules/swagger-generator/Dockerfile +++ b/modules/swagger-generator/Dockerfile @@ -1,4 +1,4 @@ -FROM java:8-jre-alpine +FROM openjdk:8-jre-alpine WORKDIR /generator diff --git a/modules/swagger-generator/src/main/webapp/index.html b/modules/swagger-generator/src/main/webapp/index.html index 694a55049b9..5e7489a0f57 100644 --- a/modules/swagger-generator/src/main/webapp/index.html +++ b/modules/swagger-generator/src/main/webapp/index.html @@ -1,104 +1,93 @@ + - + + Swagger UI - - - - - - - - - - - - - - - - - - - - + + + + + - - + -
 
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + - + + \ No newline at end of file From 456b54b24fb55aea89babdb64bbcef9cc2b1a125 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Thu, 20 Apr 2017 16:49:58 -0700 Subject: [PATCH 26/31] fix cache skip --- modules/swagger-generator/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index f7ee4de0ba7..6bb0c8ee45a 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -114,6 +114,7 @@ https://github.com/swagger-api/swagger-ui/archive/master.tar.gz true + true ${project.build.directory} From 8144ab6870ebfe00ddcf7c94f65d9f45128bdf44 Mon Sep 17 00:00:00 2001 From: Jean-Maxime Fillau Date: Fri, 21 Apr 2017 16:01:37 +0200 Subject: [PATCH 27/31] Add json format in case contentType is application/json. (#5427) Signed-off-by: FILLAU Jean-Maxime --- .../cpprest/apiclient-source.mustache | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache index 99532a11dcb..d1232aaaa2d 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache @@ -113,12 +113,24 @@ pplx::task ApiClient::callApi( } else { - web::http::uri_builder formData; - for (auto& kvp : formParams) + if (contentType == U("application/json")) { - formData.append_query(kvp.first, kvp.second); + web::json::value body_data = web::json::value::object(); + for (auto& kvp : formParams) + { + body_data[U(kvp.first)] = ModelBase::toJson(kvp.second); + } + request.set_body(body_data); + } + else + { + web::http::uri_builder formData; + for (auto& kvp : formParams) + { + formData.append_query(kvp.first, kvp.second); + } + request.set_body(formData.query(), U("application/x-www-form-urlencoded")); } - request.set_body(formData.query(), U("application/x-www-form-urlencoded")); } } From 122db78b1ac247af4f4785d7e2e7293356195266 Mon Sep 17 00:00:00 2001 From: Cas Perl Date: Fri, 21 Apr 2017 16:05:54 +0200 Subject: [PATCH 28/31] Issue 5375 (#5403) * use py3 instead of py34 * fixed test to test invalid enum * ADDED: assign variable in the ctor with property setter to check validity if possible. CHANGE: move required property check to proper place. CHANGE: remove double quotes from allowed_values for none-string enum property * rebuilt samples * comment for improvement * ADDED: post process enum model for python. * comment * rebuilt samples * rebuilt samples --- .../languages/PythonClientCodegen.java | 7 +++ .../src/main/resources/python/model.mustache | 28 ++++++++-- .../src/main/resources/python/tox.mustache | 2 +- .../petstore_api/models/model_return.py | 8 ++- .../petstore-security-test/python/tox.ini | 2 +- .../models/additional_properties_class.py | 12 +++- .../python/petstore_api/models/animal.py | 12 +++- .../python/petstore_api/models/animal_farm.py | 4 ++ .../petstore_api/models/api_response.py | 16 +++++- .../models/array_of_array_of_number_only.py | 8 ++- .../models/array_of_number_only.py | 8 ++- .../python/petstore_api/models/array_test.py | 16 +++++- .../petstore_api/models/capitalization.py | 28 ++++++++-- .../python/petstore_api/models/cat.py | 16 +++++- .../python/petstore_api/models/category.py | 12 +++- .../python/petstore_api/models/class_model.py | 8 ++- .../python/petstore_api/models/client.py | 8 ++- .../python/petstore_api/models/dog.py | 16 +++++- .../python/petstore_api/models/enum_arrays.py | 12 +++- .../python/petstore_api/models/enum_class.py | 9 +++ .../python/petstore_api/models/enum_test.py | 24 ++++++-- .../python/petstore_api/models/format_test.py | 56 ++++++++++++++----- .../petstore_api/models/has_only_read_only.py | 12 +++- .../python/petstore_api/models/list.py | 8 ++- .../python/petstore_api/models/map_test.py | 12 +++- ...perties_and_additional_properties_class.py | 16 +++++- .../petstore_api/models/model_200_response.py | 12 +++- .../petstore_api/models/model_return.py | 8 ++- .../python/petstore_api/models/name.py | 20 +++++-- .../python/petstore_api/models/number_only.py | 8 ++- .../python/petstore_api/models/order.py | 28 ++++++++-- .../python/petstore_api/models/outer_enum.py | 9 +++ .../python/petstore_api/models/pet.py | 28 ++++++++-- .../petstore_api/models/read_only_first.py | 12 +++- .../petstore_api/models/special_model_name.py | 8 ++- .../python/petstore_api/models/tag.py | 12 +++- .../python/petstore_api/models/user.py | 36 +++++++++--- .../petstore/python/tests/test_enum_arrays.py | 13 ++--- .../petstore/python/tests/test_map_test.py | 3 +- samples/client/petstore/python/tox.ini | 2 +- 40 files changed, 451 insertions(+), 108 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 92c24648aa9..054005cfc51 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -196,6 +196,13 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig return str.replaceAll("\\.", "_"); } + + @Override + public Map postProcessModels(Map objs) { + // process enum in models + return postProcessModelsEnum(objs); + } + @Override public void postProcessParameter(CodegenParameter parameter){ postProcessPattern(parameter.pattern, parameter.vendorExtensions); diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index dcf3c755020..44504dbfb6b 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -14,6 +14,13 @@ class {{classname}}(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ +{{#allowableValues}} + +{{#enumVars}} + {{name}} = {{{value}}} +{{/enumVars}} + +{{/allowableValues}} def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): """ {{classname}} - a model defined in Swagger @@ -34,7 +41,15 @@ class {{classname}}(object): } {{#vars}} - self._{{name}} = {{name}} + self._{{name}} = None +{{/vars}} + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well +{{#vars}} + if {{name}} is not None: + self.{{name}} = {{name}} {{/vars}} {{#vars}} @@ -62,9 +77,13 @@ class {{classname}}(object): :param {{name}}: The {{name}} of this {{classname}}. :type: {{datatype}} """ +{{#required}} + if {{name}} is None: + raise ValueError("Invalid value for `{{name}}`, must not be `None`") +{{/required}} {{#isEnum}} - allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] {{#isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] {{#isListContainer}} if not set({{{name}}}).issubset(set(allowed_values)): raise ValueError( @@ -83,6 +102,7 @@ class {{classname}}(object): {{/isMapContainer}} {{/isContainer}} {{^isContainer}} + allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] if {{{name}}} not in allowed_values: raise ValueError( "Invalid value for `{{{name}}}` ({0}), must be one of {1}" @@ -91,10 +111,6 @@ class {{classname}}(object): {{/isContainer}} {{/isEnum}} {{^isEnum}} -{{#required}} - if {{name}} is None: - raise ValueError("Invalid value for `{{name}}`, must not be `None`") -{{/required}} {{#hasValidation}} {{#maxLength}} if {{name}} is not None and len({{name}}) > {{maxLength}}: diff --git a/modules/swagger-codegen/src/main/resources/python/tox.mustache b/modules/swagger-codegen/src/main/resources/python/tox.mustache index d99517b76b6..1cf0829dc93 100644 --- a/modules/swagger-codegen/src/main/resources/python/tox.mustache +++ b/modules/swagger-codegen/src/main/resources/python/tox.mustache @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34 +envlist = py27, py3 [testenv] deps=-r{toxinidir}/requirements.txt diff --git a/samples/client/petstore-security-test/python/petstore_api/models/model_return.py b/samples/client/petstore-security-test/python/petstore_api/models/model_return.py index 2b6f2a45172..80673374e7a 100644 --- a/samples/client/petstore-security-test/python/petstore_api/models/model_return.py +++ b/samples/client/petstore-security-test/python/petstore_api/models/model_return.py @@ -38,7 +38,13 @@ class ModelReturn(object): '_return': 'return' } - self.__return = _return + self.__return = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if _return is not None: + self._return = _return @property def _return(self): diff --git a/samples/client/petstore-security-test/python/tox.ini b/samples/client/petstore-security-test/python/tox.ini index d99517b76b6..1cf0829dc93 100644 --- a/samples/client/petstore-security-test/python/tox.ini +++ b/samples/client/petstore-security-test/python/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34 +envlist = py27, py3 [testenv] deps=-r{toxinidir}/requirements.txt diff --git a/samples/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python/petstore_api/models/additional_properties_class.py index 5873f70643f..4d8206aa013 100644 --- a/samples/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -40,8 +40,16 @@ class AdditionalPropertiesClass(object): 'map_of_map_property': 'map_of_map_property' } - self._map_property = map_property - self._map_of_map_property = map_of_map_property + self._map_property = None + self._map_of_map_property = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if map_property is not None: + self.map_property = map_property + if map_of_map_property is not None: + self.map_of_map_property = map_of_map_property @property def map_property(self): diff --git a/samples/client/petstore/python/petstore_api/models/animal.py b/samples/client/petstore/python/petstore_api/models/animal.py index c46cfb28ddb..db1febb58ec 100644 --- a/samples/client/petstore/python/petstore_api/models/animal.py +++ b/samples/client/petstore/python/petstore_api/models/animal.py @@ -40,8 +40,16 @@ class Animal(object): 'color': 'color' } - self._class_name = class_name - self._color = color + self._class_name = None + self._color = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if class_name is not None: + self.class_name = class_name + if color is not None: + self.color = color @property def class_name(self): diff --git a/samples/client/petstore/python/petstore_api/models/animal_farm.py b/samples/client/petstore/python/petstore_api/models/animal_farm.py index ff8a3794e90..3766a4f39a4 100644 --- a/samples/client/petstore/python/petstore_api/models/animal_farm.py +++ b/samples/client/petstore/python/petstore_api/models/animal_farm.py @@ -39,6 +39,10 @@ class AnimalFarm(object): } + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/petstore_api/models/api_response.py b/samples/client/petstore/python/petstore_api/models/api_response.py index ba5c434abc7..bc072ca025a 100644 --- a/samples/client/petstore/python/petstore_api/models/api_response.py +++ b/samples/client/petstore/python/petstore_api/models/api_response.py @@ -42,9 +42,19 @@ class ApiResponse(object): 'message': 'message' } - self._code = code - self._type = type - self._message = message + self._code = None + self._type = None + self._message = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if code is not None: + self.code = code + if type is not None: + self.type = type + if message is not None: + self.message = message @property def code(self): diff --git a/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 16c6345baad..a06f0528433 100644 --- a/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -38,7 +38,13 @@ class ArrayOfArrayOfNumberOnly(object): 'array_array_number': 'ArrayArrayNumber' } - self._array_array_number = array_array_number + self._array_array_number = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if array_array_number is not None: + self.array_array_number = array_array_number @property def array_array_number(self): diff --git a/samples/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python/petstore_api/models/array_of_number_only.py index 0db1d9591d5..c166ebc4901 100644 --- a/samples/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -38,7 +38,13 @@ class ArrayOfNumberOnly(object): 'array_number': 'ArrayNumber' } - self._array_number = array_number + self._array_number = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if array_number is not None: + self.array_number = array_number @property def array_number(self): diff --git a/samples/client/petstore/python/petstore_api/models/array_test.py b/samples/client/petstore/python/petstore_api/models/array_test.py index bd1858faa0d..8959dd96a8e 100644 --- a/samples/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/client/petstore/python/petstore_api/models/array_test.py @@ -42,9 +42,19 @@ class ArrayTest(object): 'array_array_of_model': 'array_array_of_model' } - self._array_of_string = array_of_string - self._array_array_of_integer = array_array_of_integer - self._array_array_of_model = array_array_of_model + self._array_of_string = None + self._array_array_of_integer = None + self._array_array_of_model = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if array_of_string is not None: + self.array_of_string = array_of_string + if array_array_of_integer is not None: + self.array_array_of_integer = array_array_of_integer + if array_array_of_model is not None: + self.array_array_of_model = array_array_of_model @property def array_of_string(self): diff --git a/samples/client/petstore/python/petstore_api/models/capitalization.py b/samples/client/petstore/python/petstore_api/models/capitalization.py index b9030b5b76d..9b329d456c5 100644 --- a/samples/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python/petstore_api/models/capitalization.py @@ -48,12 +48,28 @@ class Capitalization(object): 'att_name': 'ATT_NAME' } - self._small_camel = small_camel - self._capital_camel = capital_camel - self._small_snake = small_snake - self._capital_snake = capital_snake - self._sca_eth_flow_points = sca_eth_flow_points - self._att_name = att_name + self._small_camel = None + self._capital_camel = None + self._small_snake = None + self._capital_snake = None + self._sca_eth_flow_points = None + self._att_name = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if small_camel is not None: + self.small_camel = small_camel + if capital_camel is not None: + self.capital_camel = capital_camel + if small_snake is not None: + self.small_snake = small_snake + if capital_snake is not None: + self.capital_snake = capital_snake + if sca_eth_flow_points is not None: + self.sca_eth_flow_points = sca_eth_flow_points + if att_name is not None: + self.att_name = att_name @property def small_camel(self): diff --git a/samples/client/petstore/python/petstore_api/models/cat.py b/samples/client/petstore/python/petstore_api/models/cat.py index 67cae27ae8a..c0f522f3a5e 100644 --- a/samples/client/petstore/python/petstore_api/models/cat.py +++ b/samples/client/petstore/python/petstore_api/models/cat.py @@ -42,9 +42,19 @@ class Cat(object): 'declawed': 'declawed' } - self._class_name = class_name - self._color = color - self._declawed = declawed + self._class_name = None + self._color = None + self._declawed = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if class_name is not None: + self.class_name = class_name + if color is not None: + self.color = color + if declawed is not None: + self.declawed = declawed @property def class_name(self): diff --git a/samples/client/petstore/python/petstore_api/models/category.py b/samples/client/petstore/python/petstore_api/models/category.py index 2cdc9911d4e..956d3416c34 100644 --- a/samples/client/petstore/python/petstore_api/models/category.py +++ b/samples/client/petstore/python/petstore_api/models/category.py @@ -40,8 +40,16 @@ class Category(object): 'name': 'name' } - self._id = id - self._name = name + self._id = None + self._name = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if id is not None: + self.id = id + if name is not None: + self.name = name @property def id(self): diff --git a/samples/client/petstore/python/petstore_api/models/class_model.py b/samples/client/petstore/python/petstore_api/models/class_model.py index cf93b27c760..65dd5433771 100644 --- a/samples/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/client/petstore/python/petstore_api/models/class_model.py @@ -38,7 +38,13 @@ class ClassModel(object): '_class': '_class' } - self.__class = _class + self.__class = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if _class is not None: + self._class = _class @property def _class(self): diff --git a/samples/client/petstore/python/petstore_api/models/client.py b/samples/client/petstore/python/petstore_api/models/client.py index 2d572bfbeb2..5b0ed44c49c 100644 --- a/samples/client/petstore/python/petstore_api/models/client.py +++ b/samples/client/petstore/python/petstore_api/models/client.py @@ -38,7 +38,13 @@ class Client(object): 'client': 'client' } - self._client = client + self._client = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if client is not None: + self.client = client @property def client(self): diff --git a/samples/client/petstore/python/petstore_api/models/dog.py b/samples/client/petstore/python/petstore_api/models/dog.py index fc1d1fbf30c..f8dfde1c3c4 100644 --- a/samples/client/petstore/python/petstore_api/models/dog.py +++ b/samples/client/petstore/python/petstore_api/models/dog.py @@ -42,9 +42,19 @@ class Dog(object): 'breed': 'breed' } - self._class_name = class_name - self._color = color - self._breed = breed + self._class_name = None + self._color = None + self._breed = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if class_name is not None: + self.class_name = class_name + if color is not None: + self.color = color + if breed is not None: + self.breed = breed @property def class_name(self): diff --git a/samples/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/client/petstore/python/petstore_api/models/enum_arrays.py index 46b34bd41f7..1e8f6d4b8f0 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python/petstore_api/models/enum_arrays.py @@ -40,8 +40,16 @@ class EnumArrays(object): 'array_enum': 'array_enum' } - self._just_symbol = just_symbol - self._array_enum = array_enum + self._just_symbol = None + self._array_enum = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if just_symbol is not None: + self.just_symbol = just_symbol + if array_enum is not None: + self.array_enum = array_enum @property def just_symbol(self): diff --git a/samples/client/petstore/python/petstore_api/models/enum_class.py b/samples/client/petstore/python/petstore_api/models/enum_class.py index 45f6b0b4578..4544ad58528 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python/petstore_api/models/enum_class.py @@ -21,6 +21,11 @@ class EnumClass(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + _ABC = "_abc" + _EFG = "-efg" + _XYZ_ = "(xyz)" + def __init__(self): """ EnumClass - a model defined in Swagger @@ -39,6 +44,10 @@ class EnumClass(object): } + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/petstore_api/models/enum_test.py b/samples/client/petstore/python/petstore_api/models/enum_test.py index e3293425049..de3c8d5a4fe 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python/petstore_api/models/enum_test.py @@ -44,10 +44,22 @@ class EnumTest(object): 'outer_enum': 'outerEnum' } - self._enum_string = enum_string - self._enum_integer = enum_integer - self._enum_number = enum_number - self._outer_enum = outer_enum + self._enum_string = None + self._enum_integer = None + self._enum_number = None + self._outer_enum = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if enum_string is not None: + self.enum_string = enum_string + if enum_integer is not None: + self.enum_integer = enum_integer + if enum_number is not None: + self.enum_number = enum_number + if outer_enum is not None: + self.outer_enum = outer_enum @property def enum_string(self): @@ -94,7 +106,7 @@ class EnumTest(object): :param enum_integer: The enum_integer of this EnumTest. :type: int """ - allowed_values = ["1", "-1"] + allowed_values = [1, -1] if enum_integer not in allowed_values: raise ValueError( "Invalid value for `enum_integer` ({0}), must be one of {1}" @@ -121,7 +133,7 @@ class EnumTest(object): :param enum_number: The enum_number of this EnumTest. :type: float """ - allowed_values = ["1.1", "-1.2"] + allowed_values = [1.1, -1.2] if enum_number not in allowed_values: raise ValueError( "Invalid value for `enum_number` ({0}), must be one of {1}" diff --git a/samples/client/petstore/python/petstore_api/models/format_test.py b/samples/client/petstore/python/petstore_api/models/format_test.py index cde65b89a17..cc5af78fd0c 100644 --- a/samples/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/client/petstore/python/petstore_api/models/format_test.py @@ -62,19 +62,49 @@ class FormatTest(object): 'password': 'password' } - self._integer = integer - self._int32 = int32 - self._int64 = int64 - self._number = number - self._float = float - self._double = double - self._string = string - self._byte = byte - self._binary = binary - self._date = date - self._date_time = date_time - self._uuid = uuid - self._password = password + self._integer = None + self._int32 = None + self._int64 = None + self._number = None + self._float = None + self._double = None + self._string = None + self._byte = None + self._binary = None + self._date = None + self._date_time = None + self._uuid = None + self._password = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if integer is not None: + self.integer = integer + if int32 is not None: + self.int32 = int32 + if int64 is not None: + self.int64 = int64 + if number is not None: + self.number = number + if float is not None: + self.float = float + if double is not None: + self.double = double + if string is not None: + self.string = string + if byte is not None: + self.byte = byte + if binary is not None: + self.binary = binary + if date is not None: + self.date = date + if date_time is not None: + self.date_time = date_time + if uuid is not None: + self.uuid = uuid + if password is not None: + self.password = password @property def integer(self): diff --git a/samples/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python/petstore_api/models/has_only_read_only.py index c374793e617..f528c3e3e88 100644 --- a/samples/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -40,8 +40,16 @@ class HasOnlyReadOnly(object): 'foo': 'foo' } - self._bar = bar - self._foo = foo + self._bar = None + self._foo = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if bar is not None: + self.bar = bar + if foo is not None: + self.foo = foo @property def bar(self): diff --git a/samples/client/petstore/python/petstore_api/models/list.py b/samples/client/petstore/python/petstore_api/models/list.py index f1393a4b6a3..f18bd004dbe 100644 --- a/samples/client/petstore/python/petstore_api/models/list.py +++ b/samples/client/petstore/python/petstore_api/models/list.py @@ -38,7 +38,13 @@ class List(object): '_123_list': '123-list' } - self.__123_list = _123_list + self.__123_list = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if _123_list is not None: + self._123_list = _123_list @property def _123_list(self): diff --git a/samples/client/petstore/python/petstore_api/models/map_test.py b/samples/client/petstore/python/petstore_api/models/map_test.py index e6ece72af81..180c4208d89 100644 --- a/samples/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/client/petstore/python/petstore_api/models/map_test.py @@ -40,8 +40,16 @@ class MapTest(object): 'map_of_enum_string': 'map_of_enum_string' } - self._map_map_of_string = map_map_of_string - self._map_of_enum_string = map_of_enum_string + self._map_map_of_string = None + self._map_of_enum_string = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if map_map_of_string is not None: + self.map_map_of_string = map_map_of_string + if map_of_enum_string is not None: + self.map_of_enum_string = map_of_enum_string @property def map_map_of_string(self): diff --git a/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index ee9b1e641e4..8d0cde871fe 100644 --- a/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -42,9 +42,19 @@ class MixedPropertiesAndAdditionalPropertiesClass(object): 'map': 'map' } - self._uuid = uuid - self._date_time = date_time - self._map = map + self._uuid = None + self._date_time = None + self._map = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if uuid is not None: + self.uuid = uuid + if date_time is not None: + self.date_time = date_time + if map is not None: + self.map = map @property def uuid(self): diff --git a/samples/client/petstore/python/petstore_api/models/model_200_response.py b/samples/client/petstore/python/petstore_api/models/model_200_response.py index 73b6dccc050..bbdbfe00aeb 100644 --- a/samples/client/petstore/python/petstore_api/models/model_200_response.py +++ b/samples/client/petstore/python/petstore_api/models/model_200_response.py @@ -40,8 +40,16 @@ class Model200Response(object): '_class': 'class' } - self._name = name - self.__class = _class + self._name = None + self.__class = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if name is not None: + self.name = name + if _class is not None: + self._class = _class @property def name(self): diff --git a/samples/client/petstore/python/petstore_api/models/model_return.py b/samples/client/petstore/python/petstore_api/models/model_return.py index d99df7402b0..0321a42ff08 100644 --- a/samples/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/client/petstore/python/petstore_api/models/model_return.py @@ -38,7 +38,13 @@ class ModelReturn(object): '_return': 'return' } - self.__return = _return + self.__return = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if _return is not None: + self._return = _return @property def _return(self): diff --git a/samples/client/petstore/python/petstore_api/models/name.py b/samples/client/petstore/python/petstore_api/models/name.py index af281208f7a..b7dc266bc18 100644 --- a/samples/client/petstore/python/petstore_api/models/name.py +++ b/samples/client/petstore/python/petstore_api/models/name.py @@ -44,10 +44,22 @@ class Name(object): '_123_number': '123Number' } - self._name = name - self._snake_case = snake_case - self.__property = _property - self.__123_number = _123_number + self._name = None + self._snake_case = None + self.__property = None + self.__123_number = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if name is not None: + self.name = name + if snake_case is not None: + self.snake_case = snake_case + if _property is not None: + self._property = _property + if _123_number is not None: + self._123_number = _123_number @property def name(self): diff --git a/samples/client/petstore/python/petstore_api/models/number_only.py b/samples/client/petstore/python/petstore_api/models/number_only.py index 48fea068509..9d927edc0b1 100644 --- a/samples/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/client/petstore/python/petstore_api/models/number_only.py @@ -38,7 +38,13 @@ class NumberOnly(object): 'just_number': 'JustNumber' } - self._just_number = just_number + self._just_number = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if just_number is not None: + self.just_number = just_number @property def just_number(self): diff --git a/samples/client/petstore/python/petstore_api/models/order.py b/samples/client/petstore/python/petstore_api/models/order.py index d0ed63cd482..0445e56b4e9 100644 --- a/samples/client/petstore/python/petstore_api/models/order.py +++ b/samples/client/petstore/python/petstore_api/models/order.py @@ -48,12 +48,28 @@ class Order(object): 'complete': 'complete' } - self._id = id - self._pet_id = pet_id - self._quantity = quantity - self._ship_date = ship_date - self._status = status - self._complete = complete + self._id = None + self._pet_id = None + self._quantity = None + self._ship_date = None + self._status = None + self._complete = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if id is not None: + self.id = id + if pet_id is not None: + self.pet_id = pet_id + if quantity is not None: + self.quantity = quantity + if ship_date is not None: + self.ship_date = ship_date + if status is not None: + self.status = status + if complete is not None: + self.complete = complete @property def id(self): diff --git a/samples/client/petstore/python/petstore_api/models/outer_enum.py b/samples/client/petstore/python/petstore_api/models/outer_enum.py index 8c732caee81..3e8cb6f2387 100644 --- a/samples/client/petstore/python/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python/petstore_api/models/outer_enum.py @@ -21,6 +21,11 @@ class OuterEnum(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + PLACED = "placed" + APPROVED = "approved" + DELIVERED = "delivered" + def __init__(self): """ OuterEnum - a model defined in Swagger @@ -39,6 +44,10 @@ class OuterEnum(object): } + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/petstore_api/models/pet.py b/samples/client/petstore/python/petstore_api/models/pet.py index 7dea8afd1b2..e32e779fbd4 100644 --- a/samples/client/petstore/python/petstore_api/models/pet.py +++ b/samples/client/petstore/python/petstore_api/models/pet.py @@ -48,12 +48,28 @@ class Pet(object): 'status': 'status' } - self._id = id - self._category = category - self._name = name - self._photo_urls = photo_urls - self._tags = tags - self._status = status + self._id = None + self._category = None + self._name = None + self._photo_urls = None + self._tags = None + self._status = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if id is not None: + self.id = id + if category is not None: + self.category = category + if name is not None: + self.name = name + if photo_urls is not None: + self.photo_urls = photo_urls + if tags is not None: + self.tags = tags + if status is not None: + self.status = status @property def id(self): diff --git a/samples/client/petstore/python/petstore_api/models/read_only_first.py b/samples/client/petstore/python/petstore_api/models/read_only_first.py index 2b1dfda420c..a3446564d32 100644 --- a/samples/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python/petstore_api/models/read_only_first.py @@ -40,8 +40,16 @@ class ReadOnlyFirst(object): 'baz': 'baz' } - self._bar = bar - self._baz = baz + self._bar = None + self._baz = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if bar is not None: + self.bar = bar + if baz is not None: + self.baz = baz @property def bar(self): diff --git a/samples/client/petstore/python/petstore_api/models/special_model_name.py b/samples/client/petstore/python/petstore_api/models/special_model_name.py index 651c51e8e56..e4893b92d45 100644 --- a/samples/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python/petstore_api/models/special_model_name.py @@ -38,7 +38,13 @@ class SpecialModelName(object): 'special_property_name': '$special[property.name]' } - self._special_property_name = special_property_name + self._special_property_name = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if special_property_name is not None: + self.special_property_name = special_property_name @property def special_property_name(self): diff --git a/samples/client/petstore/python/petstore_api/models/tag.py b/samples/client/petstore/python/petstore_api/models/tag.py index 4bd6bfedfb6..986769a3df3 100644 --- a/samples/client/petstore/python/petstore_api/models/tag.py +++ b/samples/client/petstore/python/petstore_api/models/tag.py @@ -40,8 +40,16 @@ class Tag(object): 'name': 'name' } - self._id = id - self._name = name + self._id = None + self._name = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if id is not None: + self.id = id + if name is not None: + self.name = name @property def id(self): diff --git a/samples/client/petstore/python/petstore_api/models/user.py b/samples/client/petstore/python/petstore_api/models/user.py index ed3af1ce20d..dd360263756 100644 --- a/samples/client/petstore/python/petstore_api/models/user.py +++ b/samples/client/petstore/python/petstore_api/models/user.py @@ -52,14 +52,34 @@ class User(object): 'user_status': 'userStatus' } - self._id = id - self._username = username - self._first_name = first_name - self._last_name = last_name - self._email = email - self._password = password - self._phone = phone - self._user_status = user_status + self._id = None + self._username = None + self._first_name = None + self._last_name = None + self._email = None + self._password = None + self._phone = None + self._user_status = None + + # TODO: let required properties as mandatory parameter in the constructor. + # - to check if required property is not None (e.g. by calling setter) + # - ApiClient.__deserialize_model has to be adapted as well + if id is not None: + self.id = id + if username is not None: + self.username = username + if first_name is not None: + self.first_name = first_name + if last_name is not None: + self.last_name = last_name + if email is not None: + self.email = email + if password is not None: + self.password = password + if phone is not None: + self.phone = phone + if user_status is not None: + self.user_status = user_status @property def id(self): diff --git a/samples/client/petstore/python/tests/test_enum_arrays.py b/samples/client/petstore/python/tests/test_enum_arrays.py index aa373339a60..41e7dcb0a74 100644 --- a/samples/client/petstore/python/tests/test_enum_arrays.py +++ b/samples/client/petstore/python/tests/test_enum_arrays.py @@ -42,22 +42,21 @@ class EnumArraysTests(unittest.TestCase): # try: fish_or_crab = petstore_api.EnumArrays(just_symbol="<=") + self.assertTrue(0) except ValueError: - self.assertEqual(fish_or_crab.just_symbol, None) - self.assertEqual(fish_or_crab.array_enum, None) + self.assertTrue(1) try: fish_or_crab = petstore_api.EnumArrays(just_symbol="$", array_enum=["dog"]) + self.assertTrue(0) except ValueError: - self.assertEqual(fish_or_crab.just_symbol, None) - self.assertEqual(fish_or_crab.array_enum, None) + self.assertTrue(1) - try: fish_or_crab = petstore_api.EnumArrays(just_symbol=["$"], array_enum=["dog"]) + self.assertTrue(0) except ValueError: - self.assertEqual(fish_or_crab.just_symbol, None) - self.assertEqual(fish_or_crab.array_enum, None) + self.assertTrue(1) def test_enumarrays_setter(self): diff --git a/samples/client/petstore/python/tests/test_map_test.py b/samples/client/petstore/python/tests/test_map_test.py index 19903c4e630..012b9254b47 100644 --- a/samples/client/petstore/python/tests/test_map_test.py +++ b/samples/client/petstore/python/tests/test_map_test.py @@ -46,8 +46,9 @@ class MapTestTests(unittest.TestCase): } try: map_enum_test = petstore_api.MapTest(map_of_enum_string=black_or_white_dict) + self.assertTrue(0) except ValueError: - self.assertEqual(map_enum_test, None) + self.assertTrue(1) def test_maptest_setter(self): diff --git a/samples/client/petstore/python/tox.ini b/samples/client/petstore/python/tox.ini index d99517b76b6..1cf0829dc93 100644 --- a/samples/client/petstore/python/tox.ini +++ b/samples/client/petstore/python/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34 +envlist = py27, py3 [testenv] deps=-r{toxinidir}/requirements.txt From f61e0d40242c4b4b9ffb94a2ee76ee993573fc29 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 Apr 2017 16:13:57 +0200 Subject: [PATCH 29/31] Add RuntimeException option (#5405) * add option to change Exception to RuntimeException * rename propertie remove space in template --- .../codegen/languages/JavaClientCodegen.java | 39 ++++++++++++------- .../main/resources/Java/apiException.mustache | 2 +- .../options/JavaClientOptionsProvider.java | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 898474c44af..324f5be2d89 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -27,6 +27,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen public static final String DO_NOT_USE_RX = "doNotUseRx"; public static final String USE_PLAY24_WS = "usePlay24WS"; public static final String PARCELABLE_MODEL = "parcelableModel"; + public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException"; public static final String RETROFIT_1 = "retrofit"; public static final String RETROFIT_2 = "retrofit2"; @@ -40,6 +41,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen protected boolean useBeanValidation = false; protected boolean performBeanValidation = false; protected boolean useGzipFeature = false; + protected boolean useRuntimeException = false; public JavaClientCodegen() { super(); @@ -58,6 +60,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(CliOption.newBoolean(PERFORM_BEANVALIDATION, "Perform BeanValidation")); cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE, "Send gzip-encoded requests")); + cliOptions.add(CliOption.newBoolean(USE_RUNTIME_EXCEPTION, "Use RuntimeException instead of Exception")); supportedLibraries.put("jersey1", "HTTP client: Jersey client 1.19.1. JSON processing: Jackson 2.7.0. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'."); supportedLibraries.put("feign", "HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.7"); @@ -128,6 +131,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen this.setUseGzipFeature(convertPropertyToBooleanAndWriteBack(USE_GZIP_FEATURE)); } + if (additionalProperties.containsKey(USE_RUNTIME_EXCEPTION)) { + this.setUseRuntimeException(convertPropertyToBooleanAndWriteBack(USE_RUNTIME_EXCEPTION)); + } + final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/"); final String authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/"); @@ -289,22 +296,22 @@ public class JavaClientCodegen extends AbstractJavaCodegen } /** - * Prioritizes consumes mime-type list by moving json-vendor and json mime-types up front, but - * otherwise preserves original consumes definition order. - * [application/vnd...+json,... application/json, ..as is..] - * + * Prioritizes consumes mime-type list by moving json-vendor and json mime-types up front, but + * otherwise preserves original consumes definition order. + * [application/vnd...+json,... application/json, ..as is..] + * * @param consumes consumes mime-type list - * @return + * @return */ static List> prioritizeContentTypes(List> consumes) { if ( consumes.size() <= 1 ) return consumes; - + List> prioritizedContentTypes = new ArrayList<>(consumes.size()); - + List> jsonVendorMimeTypes = new ArrayList<>(consumes.size()); List> jsonMimeTypes = new ArrayList<>(consumes.size()); - + for ( Map consume : consumes) { if ( isJsonVendorMimeType(consume.get(MEDIA_TYPE))) { jsonVendorMimeTypes.add(consume); @@ -314,18 +321,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen } else prioritizedContentTypes.add(consume); - + consume.put("hasMore", "true"); } - + prioritizedContentTypes.addAll(0, jsonMimeTypes); prioritizedContentTypes.addAll(0, jsonVendorMimeTypes); - + prioritizedContentTypes.get(prioritizedContentTypes.size()-1).put("hasMore", null); - + return prioritizedContentTypes; } - + private static boolean isMultipartType(List> consumes) { Map firstType = consumes.get(0); if (firstType != null) { @@ -413,8 +420,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen this.useGzipFeature = useGzipFeature; } + public void setUseRuntimeException(boolean useRuntimeException) { + this.useRuntimeException = useRuntimeException; + } + final private static Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)application\\/json(;.*)?"); - final private static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?"); + final private static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?"); /** * Check if the given MIME is a JSON MIME. diff --git a/modules/swagger-codegen/src/main/resources/Java/apiException.mustache b/modules/swagger-codegen/src/main/resources/Java/apiException.mustache index 89ed524d37e..5b450c9ba62 100644 --- a/modules/swagger-codegen/src/main/resources/Java/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/apiException.mustache @@ -6,7 +6,7 @@ import java.util.Map; import java.util.List; {{>generatedAnnotation}} -public class ApiException extends Exception { +public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{ private int code = 0; private Map> responseHeaders = null; private String responseBody = null; diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java index 3a4ddc208f8..2b8426af3c9 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java @@ -24,7 +24,7 @@ public class JavaClientOptionsProvider extends JavaOptionsProvider { options.put(JavaClientCodegen.USE_BEANVALIDATION, "false"); options.put(JavaClientCodegen.PERFORM_BEANVALIDATION, PERFORM_BEANVALIDATION); options.put(JavaClientCodegen.USE_GZIP_FEATURE, "false"); - + options.put(JavaClientCodegen.USE_RUNTIME_EXCEPTION, "false"); return options; } From e9a438b73f245e1295c7bd9e6bd67e327ba4398d Mon Sep 17 00:00:00 2001 From: Ravi Date: Fri, 21 Apr 2017 09:20:46 -0500 Subject: [PATCH 30/31] [CppRest] Overload toJson for bool in Modelbase (#5448) * Add operationId in exception message * add number data type mapping * fix_issue5434 --- .../src/main/resources/cpprest/modelbase-header.mustache | 1 + .../src/main/resources/cpprest/modelbase-source.mustache | 3 +++ samples/client/petstore/cpprest/ModelBase.cpp | 3 +++ samples/client/petstore/cpprest/ModelBase.h | 1 + 4 files changed, 8 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache index 9597c47f8ec..a74dfffbb74 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache @@ -40,6 +40,7 @@ public: static web::json::value toJson( int32_t value ); static web::json::value toJson( int64_t value ); static web::json::value toJson( double value ); + static web::json::value toJson( bool value ); static int64_t int64_tFromJson(web::json::value& val); static int32_t int32_tFromJson(web::json::value& val); diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache index 1ad866893af..65d6d7d12a0 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache @@ -31,6 +31,9 @@ web::json::value ModelBase::toJson( int64_t value ) web::json::value ModelBase::toJson( double value ) { return web::json::value::number(value); +} +web::json::value ModelBase::toJson(bool value) { + return web::json::value::boolean(value); } web::json::value ModelBase::toJson( std::shared_ptr content ) diff --git a/samples/client/petstore/cpprest/ModelBase.cpp b/samples/client/petstore/cpprest/ModelBase.cpp index f97fe013cd5..197741f5379 100644 --- a/samples/client/petstore/cpprest/ModelBase.cpp +++ b/samples/client/petstore/cpprest/ModelBase.cpp @@ -43,6 +43,9 @@ web::json::value ModelBase::toJson( int64_t value ) web::json::value ModelBase::toJson( double value ) { return web::json::value::number(value); +} +web::json::value ModelBase::toJson(bool value) { + return web::json::value::boolean(value); } web::json::value ModelBase::toJson( std::shared_ptr content ) diff --git a/samples/client/petstore/cpprest/ModelBase.h b/samples/client/petstore/cpprest/ModelBase.h index fa65266449f..013c99a5d70 100644 --- a/samples/client/petstore/cpprest/ModelBase.h +++ b/samples/client/petstore/cpprest/ModelBase.h @@ -52,6 +52,7 @@ public: static web::json::value toJson( int32_t value ); static web::json::value toJson( int64_t value ); static web::json::value toJson( double value ); + static web::json::value toJson( bool value ); static int64_t int64_tFromJson(web::json::value& val); static int32_t int32_tFromJson(web::json::value& val); From 6685f18e5f789915459c527a8749f034a0bcbba1 Mon Sep 17 00:00:00 2001 From: Sergey Novikov Date: Fri, 21 Apr 2017 18:30:52 +0200 Subject: [PATCH 31/31] Reuse allowed values (#5435) --- .../codegen/languages/PhpClientCodegen.java | 5 ++ .../main/resources/php/model_generic.mustache | 29 ++++++--- .../lib/Model/EnumArrays.php | 39 ++++++++---- .../SwaggerClient-php/lib/Model/EnumTest.php | 60 +++++++++++++------ .../SwaggerClient-php/lib/Model/MapTest.php | 11 +++- .../php/SwaggerClient-php/lib/Model/Order.php | 20 +++++-- .../php/SwaggerClient-php/lib/Model/Pet.php | 20 +++++-- 7 files changed, 130 insertions(+), 54 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index b67773dcce7..3eb4aa68cdb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -674,6 +674,11 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { return varName; } + // for symbol, e.g. $, # + if (getSymbolName(name) != null) { + return getSymbolName(name).toUpperCase(); + } + // string String enumName = sanitizeName(underscore(name).toUpperCase()); enumName = enumName.replaceFirst("^_", ""); diff --git a/modules/swagger-codegen/src/main/resources/php/model_generic.mustache b/modules/swagger-codegen/src/main/resources/php/model_generic.mustache index ae141ee6cab..83cf38deb46 100644 --- a/modules/swagger-codegen/src/main/resources/php/model_generic.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model_generic.mustache @@ -132,9 +132,12 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple {{/required}} {{#isEnum}} {{^isContainer}} - $allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]; + $allowed_values = $this->{{getter}}AllowableValues(); if (!in_array($this->container['{{name}}'], $allowed_values)) { - $invalid_properties[] = "invalid value for '{{name}}', must be one of {{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}."; + $invalid_properties[] = sprintf( + "invalid value for '{{name}}', must be one of '%s'", + implode("', '", $allowed_values) + ); } {{/isContainer}} @@ -209,7 +212,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple {{/required}} {{#isEnum}} {{^isContainer}} - $allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]; + $allowed_values = $this->{{getter}}AllowableValues(); if (!in_array($this->container['{{name}}'], $allowed_values)) { return false; } @@ -275,15 +278,25 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple public function {{setter}}(${{name}}) { {{#isEnum}} - $allowed_values = array({{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}); + $allowed_values = $this->{{getter}}AllowableValues(); {{^isContainer}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(!in_array(${{{name}}}, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for '{{name}}', must be one of {{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}"); + if ({{^required}}!is_null(${{name}}) && {{/required}}!in_array(${{{name}}}, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for '{{name}}', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } {{/isContainer}} {{#isContainer}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(array_diff(${{{name}}}, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for '{{name}}', must be one of {{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}"); + if ({{^required}}!is_null(${{name}}) && {{/required}}array_diff(${{{name}}}, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for '{{name}}', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } {{/isContainer}} {{/isEnum}} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php index 09d496d1926..34daaaa701e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php @@ -107,8 +107,8 @@ class EnumArrays implements ArrayAccess return self::$getters; } - const JUST_SYMBOL_ = '>='; - const JUST_SYMBOL_ = '$'; + const JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO = '>='; + const JUST_SYMBOL_DOLLAR = '$'; const ARRAY_ENUM_FISH = 'fish'; const ARRAY_ENUM_CRAB = 'crab'; @@ -121,8 +121,8 @@ class EnumArrays implements ArrayAccess public function getJustSymbolAllowableValues() { return [ - self::JUST_SYMBOL_, - self::JUST_SYMBOL_, + self::JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO, + self::JUST_SYMBOL_DOLLAR, ]; } @@ -164,9 +164,12 @@ class EnumArrays implements ArrayAccess { $invalid_properties = []; - $allowed_values = [">=", "$"]; + $allowed_values = $this->getJustSymbolAllowableValues(); if (!in_array($this->container['just_symbol'], $allowed_values)) { - $invalid_properties[] = "invalid value for 'just_symbol', must be one of '>=', '$'."; + $invalid_properties[] = sprintf( + "invalid value for 'just_symbol', must be one of '%s'", + implode("', '", $allowed_values) + ); } return $invalid_properties; @@ -181,7 +184,7 @@ class EnumArrays implements ArrayAccess public function valid() { - $allowed_values = [">=", "$"]; + $allowed_values = $this->getJustSymbolAllowableValues(); if (!in_array($this->container['just_symbol'], $allowed_values)) { return false; } @@ -205,9 +208,14 @@ class EnumArrays implements ArrayAccess */ public function setJustSymbol($just_symbol) { - $allowed_values = array('>=', '$'); - if (!is_null($just_symbol) && (!in_array($just_symbol, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'just_symbol', must be one of '>=', '$'"); + $allowed_values = $this->getJustSymbolAllowableValues(); + if (!is_null($just_symbol) && !in_array($just_symbol, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'just_symbol', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['just_symbol'] = $just_symbol; @@ -230,9 +238,14 @@ class EnumArrays implements ArrayAccess */ public function setArrayEnum($array_enum) { - $allowed_values = array('fish', 'crab'); - if (!is_null($array_enum) && (array_diff($array_enum, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'array_enum', must be one of 'fish', 'crab'"); + $allowed_values = $this->getArrayEnumAllowableValues(); + if (!is_null($array_enum) && array_diff($array_enum, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'array_enum', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['array_enum'] = $array_enum; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php index bb6d88b4b96..b3620adae3f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php @@ -190,19 +190,28 @@ class EnumTest implements ArrayAccess { $invalid_properties = []; - $allowed_values = ["UPPER", "lower", ""]; + $allowed_values = $this->getEnumStringAllowableValues(); if (!in_array($this->container['enum_string'], $allowed_values)) { - $invalid_properties[] = "invalid value for 'enum_string', must be one of 'UPPER', 'lower', ''."; + $invalid_properties[] = sprintf( + "invalid value for 'enum_string', must be one of '%s'", + implode("', '", $allowed_values) + ); } - $allowed_values = ["1", "-1"]; + $allowed_values = $this->getEnumIntegerAllowableValues(); if (!in_array($this->container['enum_integer'], $allowed_values)) { - $invalid_properties[] = "invalid value for 'enum_integer', must be one of '1', '-1'."; + $invalid_properties[] = sprintf( + "invalid value for 'enum_integer', must be one of '%s'", + implode("', '", $allowed_values) + ); } - $allowed_values = ["1.1", "-1.2"]; + $allowed_values = $this->getEnumNumberAllowableValues(); if (!in_array($this->container['enum_number'], $allowed_values)) { - $invalid_properties[] = "invalid value for 'enum_number', must be one of '1.1', '-1.2'."; + $invalid_properties[] = sprintf( + "invalid value for 'enum_number', must be one of '%s'", + implode("', '", $allowed_values) + ); } return $invalid_properties; @@ -217,15 +226,15 @@ class EnumTest implements ArrayAccess public function valid() { - $allowed_values = ["UPPER", "lower", ""]; + $allowed_values = $this->getEnumStringAllowableValues(); if (!in_array($this->container['enum_string'], $allowed_values)) { return false; } - $allowed_values = ["1", "-1"]; + $allowed_values = $this->getEnumIntegerAllowableValues(); if (!in_array($this->container['enum_integer'], $allowed_values)) { return false; } - $allowed_values = ["1.1", "-1.2"]; + $allowed_values = $this->getEnumNumberAllowableValues(); if (!in_array($this->container['enum_number'], $allowed_values)) { return false; } @@ -249,9 +258,14 @@ class EnumTest implements ArrayAccess */ public function setEnumString($enum_string) { - $allowed_values = array('UPPER', 'lower', ''); - if (!is_null($enum_string) && (!in_array($enum_string, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'enum_string', must be one of 'UPPER', 'lower', ''"); + $allowed_values = $this->getEnumStringAllowableValues(); + if (!is_null($enum_string) && !in_array($enum_string, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_string', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['enum_string'] = $enum_string; @@ -274,9 +288,14 @@ class EnumTest implements ArrayAccess */ public function setEnumInteger($enum_integer) { - $allowed_values = array('1', '-1'); - if (!is_null($enum_integer) && (!in_array($enum_integer, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'enum_integer', must be one of '1', '-1'"); + $allowed_values = $this->getEnumIntegerAllowableValues(); + if (!is_null($enum_integer) && !in_array($enum_integer, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_integer', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['enum_integer'] = $enum_integer; @@ -299,9 +318,14 @@ class EnumTest implements ArrayAccess */ public function setEnumNumber($enum_number) { - $allowed_values = array('1.1', '-1.2'); - if (!is_null($enum_number) && (!in_array($enum_number, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'enum_number', must be one of '1.1', '-1.2'"); + $allowed_values = $this->getEnumNumberAllowableValues(); + if (!is_null($enum_number) && !in_array($enum_number, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_number', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['enum_number'] = $enum_number; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php index 024ec0b45ee..4acee7ceeeb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php @@ -203,9 +203,14 @@ class MapTest implements ArrayAccess */ public function setMapOfEnumString($map_of_enum_string) { - $allowed_values = array('UPPER', 'lower'); - if (!is_null($map_of_enum_string) && (array_diff($map_of_enum_string, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'map_of_enum_string', must be one of 'UPPER', 'lower'"); + $allowed_values = $this->getMapOfEnumStringAllowableValues(); + if (!is_null($map_of_enum_string) && array_diff($map_of_enum_string, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'map_of_enum_string', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['map_of_enum_string'] = $map_of_enum_string; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php index 1b70e5914b6..8871ecfbd97 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php @@ -172,9 +172,12 @@ class Order implements ArrayAccess { $invalid_properties = []; - $allowed_values = ["placed", "approved", "delivered"]; + $allowed_values = $this->getStatusAllowableValues(); if (!in_array($this->container['status'], $allowed_values)) { - $invalid_properties[] = "invalid value for 'status', must be one of 'placed', 'approved', 'delivered'."; + $invalid_properties[] = sprintf( + "invalid value for 'status', must be one of '%s'", + implode("', '", $allowed_values) + ); } return $invalid_properties; @@ -189,7 +192,7 @@ class Order implements ArrayAccess public function valid() { - $allowed_values = ["placed", "approved", "delivered"]; + $allowed_values = $this->getStatusAllowableValues(); if (!in_array($this->container['status'], $allowed_values)) { return false; } @@ -297,9 +300,14 @@ class Order implements ArrayAccess */ public function setStatus($status) { - $allowed_values = array('placed', 'approved', 'delivered'); - if (!is_null($status) && (!in_array($status, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'placed', 'approved', 'delivered'"); + $allowed_values = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['status'] = $status; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php index 88ddce6611c..6cc91fe88fe 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php @@ -178,9 +178,12 @@ class Pet implements ArrayAccess if ($this->container['photo_urls'] === null) { $invalid_properties[] = "'photo_urls' can't be null"; } - $allowed_values = ["available", "pending", "sold"]; + $allowed_values = $this->getStatusAllowableValues(); if (!in_array($this->container['status'], $allowed_values)) { - $invalid_properties[] = "invalid value for 'status', must be one of 'available', 'pending', 'sold'."; + $invalid_properties[] = sprintf( + "invalid value for 'status', must be one of '%s'", + implode("', '", $allowed_values) + ); } return $invalid_properties; @@ -201,7 +204,7 @@ class Pet implements ArrayAccess if ($this->container['photo_urls'] === null) { return false; } - $allowed_values = ["available", "pending", "sold"]; + $allowed_values = $this->getStatusAllowableValues(); if (!in_array($this->container['status'], $allowed_values)) { return false; } @@ -330,9 +333,14 @@ class Pet implements ArrayAccess */ public function setStatus($status) { - $allowed_values = array('available', 'pending', 'sold'); - if (!is_null($status) && (!in_array($status, $allowed_values))) { - throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'available', 'pending', 'sold'"); + $allowed_values = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowed_values)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + implode("', '", $allowed_values) + ) + ); } $this->container['status'] = $status;