diff --git a/README.md b/README.md index 31cfbf02651..ced6f545200 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/) @@ -804,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/) 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/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 7a49a59900c..c423e9d2588 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(".", "/"); @@ -295,22 +302,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); @@ -320,18 +327,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) { @@ -419,8 +426,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/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index d71ba11359b..1a6aef262b2 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 @@ -673,6 +673,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/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index bd5dc6a5ca5..3261aa153e1 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/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index c8b41383ada..2f3ef0c0cb7 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"; @@ -170,6 +177,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")); @@ -287,6 +297,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 @@ -470,6 +493,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/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/main/resources/Java/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache index 69282c213eb..3527476e506 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' } } @@ -23,13 +23,13 @@ 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 { {{#java8}} @@ -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 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 a9be9f257ec..cf0580e1d51 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' } } @@ -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_{{^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 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 ee39513e8d4..66fef71a003 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}} 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 289e45fa13e..3ef6d31fa81 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 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 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 a1a1d6de787..569dfbc05aa 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' - } - } + 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 { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index 1371e29c5d9..0e23cd4f59b 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}} @@ -40,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}}){{^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 b952cd6f51e..add32acf40a 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}} @@ -36,21 +38,44 @@ 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}} - public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, - {{/hasMore}}{{/allParams}}) { - // do some magic!{{^isDelegate}}{{^async}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/async}}{{#async}} +{{/isDelegate}} +{{^jdk8-no-delegate}} +{{#operation}} + 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}} + {{#examples}} + {{#-first}} + + ObjectMapper objectMapper = new ObjectMapper(); + + {{/-first}} + if (accept != null && accept.contains("{{{contentType}}}")) { + return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lamdaRemoveLineBreak}}{{#lamdaEscapeDoubleQuote}}{{{example}}}{{/lamdaEscapeDoubleQuote}}{{/lamdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK); + } + + {{/examples}} + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); + {{/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/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 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 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 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")); } } 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/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/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index 7faf9ae5b09..cea2e4aa33a 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/modules/swagger-codegen/src/main/resources/swift3/Models.mustache b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache index b2c472d9015..a970be0714a 100644 --- a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache @@ -253,7 +253,6 @@ class Decoders { {{^isArrayModel}} // Decoder for [{{{classname}}}] - Decoders.addDecoder(clazz: [{{{classname}}}].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[{{{classname}}}]> in return Decoders.decode(clazz: [{{{classname}}}].self, source: source, instance: instance) } // Decoder for {{{classname}}} 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; } diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index ce318284ff0..b13b515e440 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -114,7 +114,7 @@ https://github.com/swagger-api/swagger-ui/archive/master.tar.gz true - true + true ${project.build.directory} diff --git a/pom.xml b/pom.xml index 0ccdb570e65..034cd65c078 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 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/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); 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; 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 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..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 @@ -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; @@ -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 6a733290a0b..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 @@ -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; @@ -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/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/FakeAPI.swift index 5a329e17728..dbe5b5a379e 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: [{example={ + - examples: [{contentType=application/json, example={ "client" : "aeiou" -}, contentType=application/json}] +}}] - parameter body: (body) client model diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift index b1a489cdc53..ba69fb2a513 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift @@ -26,9 +26,9 @@ open class Fake_classname_tags123API: APIBase { /** To test class name in snake case - PATCH /fake_classname_test - - examples: [{example={ + - examples: [{contentType=application/json, 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 a480e7edbc2..091e0d45664 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -131,21 +131,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -154,20 +154,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -218,21 +218,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -241,20 +241,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -305,21 +305,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example={ - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -328,20 +328,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example={ - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] - parameter petId: (path) ID of pet to return @@ -470,11 +470,11 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "message" : "aeiou", + - examples: [{contentType=application/json, example={ "code" : 0, - "type" : "aeiou" -}, contentType=application/json}] + "type" : "aeiou", + "message" : "aeiou" +}}] - 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 010fa3175a5..91734ecbb02 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: [{example={ + - examples: [{contentType=application/json, 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] - - examples: [{example= + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] - - examples: [{example= + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] - 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 7822056b60e..c21366cce7d 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 aeiou aeiou @@ -177,17 +177,17 @@ open class UserAPI: APIBase { aeiou aeiou 123 -, contentType=application/xml}, {example={ - "id" : 0, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 6, +}, {contentType=application/json, example={ "firstName" : "aeiou", - "password" : "aeiou" -}, contentType=application/json}] - - examples: [{example= + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] + - examples: [{contentType=application/xml, example= 123456789 aeiou aeiou @@ -196,16 +196,16 @@ open class UserAPI: APIBase { aeiou aeiou 123 -, contentType=application/xml}, {example={ - "id" : 0, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 6, +}, {contentType=application/json, example={ "firstName" : "aeiou", - "password" : "aeiou" -}, contentType=application/json}] + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] - 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: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] - - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] - 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/Models.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift index 2dd4a72e0c4..a25903a430f 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift @@ -252,7 +252,6 @@ class Decoders { } // Decoder for [AdditionalPropertiesClass] - Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[AdditionalPropertiesClass]> in return Decoders.decode(clazz: [AdditionalPropertiesClass].self, source: source, instance: instance) } // Decoder for AdditionalPropertiesClass @@ -280,7 +279,6 @@ class Decoders { // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Animal]> in return Decoders.decode(clazz: [Animal].self, source: source, instance: instance) } // Decoder for Animal @@ -315,7 +313,6 @@ class Decoders { // Decoder for [ApiResponse] - Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ApiResponse]> in return Decoders.decode(clazz: [ApiResponse].self, source: source, instance: instance) } // Decoder for ApiResponse @@ -349,7 +346,6 @@ class Decoders { // Decoder for [ArrayOfArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayOfArrayOfNumberOnly]> in return Decoders.decode(clazz: [ArrayOfArrayOfNumberOnly].self, source: source, instance: instance) } // Decoder for ArrayOfArrayOfNumberOnly @@ -371,7 +367,6 @@ class Decoders { // Decoder for [ArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayOfNumberOnly]> in return Decoders.decode(clazz: [ArrayOfNumberOnly].self, source: source, instance: instance) } // Decoder for ArrayOfNumberOnly @@ -393,7 +388,6 @@ class Decoders { // Decoder for [ArrayTest] - Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayTest]> in return Decoders.decode(clazz: [ArrayTest].self, source: source, instance: instance) } // Decoder for ArrayTest @@ -427,7 +421,6 @@ class Decoders { // Decoder for [Capitalization] - Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Capitalization]> in return Decoders.decode(clazz: [Capitalization].self, source: source, instance: instance) } // Decoder for Capitalization @@ -479,7 +472,6 @@ class Decoders { // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Cat]> in return Decoders.decode(clazz: [Cat].self, source: source, instance: instance) } // Decoder for Cat @@ -516,7 +508,6 @@ class Decoders { // Decoder for [Category] - Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Category]> in return Decoders.decode(clazz: [Category].self, source: source, instance: instance) } // Decoder for Category @@ -544,7 +535,6 @@ class Decoders { // Decoder for [ClassModel] - Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ClassModel]> in return Decoders.decode(clazz: [ClassModel].self, source: source, instance: instance) } // Decoder for ClassModel @@ -566,7 +556,6 @@ class Decoders { // Decoder for [Client] - Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Client]> in return Decoders.decode(clazz: [Client].self, source: source, instance: instance) } // Decoder for Client @@ -588,7 +577,6 @@ class Decoders { // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Dog]> in return Decoders.decode(clazz: [Dog].self, source: source, instance: instance) } // Decoder for Dog @@ -625,7 +613,6 @@ class Decoders { // Decoder for [EnumArrays] - Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumArrays]> in return Decoders.decode(clazz: [EnumArrays].self, source: source, instance: instance) } // Decoder for EnumArrays @@ -653,7 +640,6 @@ class Decoders { // Decoder for [EnumClass] - Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumClass]> in return Decoders.decode(clazz: [EnumClass].self, source: source, instance: instance) } // Decoder for EnumClass @@ -664,7 +650,6 @@ class Decoders { // Decoder for [EnumTest] - Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumTest]> in return Decoders.decode(clazz: [EnumTest].self, source: source, instance: instance) } // Decoder for EnumTest @@ -704,7 +689,6 @@ class Decoders { // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[FormatTest]> in return Decoders.decode(clazz: [FormatTest].self, source: source, instance: instance) } // Decoder for FormatTest @@ -798,7 +782,6 @@ class Decoders { // Decoder for [HasOnlyReadOnly] - Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[HasOnlyReadOnly]> in return Decoders.decode(clazz: [HasOnlyReadOnly].self, source: source, instance: instance) } // Decoder for HasOnlyReadOnly @@ -826,7 +809,6 @@ class Decoders { // Decoder for [List] - Decoders.addDecoder(clazz: [List].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[List]> in return Decoders.decode(clazz: [List].self, source: source, instance: instance) } // Decoder for List @@ -848,7 +830,6 @@ class Decoders { // Decoder for [MapTest] - Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[MapTest]> in return Decoders.decode(clazz: [MapTest].self, source: source, instance: instance) } // Decoder for MapTest @@ -876,7 +857,6 @@ class Decoders { // Decoder for [MixedPropertiesAndAdditionalPropertiesClass] - Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[MixedPropertiesAndAdditionalPropertiesClass]> in return Decoders.decode(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self, source: source, instance: instance) } // Decoder for MixedPropertiesAndAdditionalPropertiesClass @@ -910,7 +890,6 @@ class Decoders { // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Model200Response]> in return Decoders.decode(clazz: [Model200Response].self, source: source, instance: instance) } // Decoder for Model200Response @@ -938,7 +917,6 @@ class Decoders { // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Name]> in return Decoders.decode(clazz: [Name].self, source: source, instance: instance) } // Decoder for Name @@ -978,7 +956,6 @@ class Decoders { // Decoder for [NumberOnly] - Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[NumberOnly]> in return Decoders.decode(clazz: [NumberOnly].self, source: source, instance: instance) } // Decoder for NumberOnly @@ -1000,7 +977,6 @@ class Decoders { // Decoder for [Order] - Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Order]> in return Decoders.decode(clazz: [Order].self, source: source, instance: instance) } // Decoder for Order @@ -1052,7 +1028,6 @@ class Decoders { // Decoder for [OuterEnum] - Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[OuterEnum]> in return Decoders.decode(clazz: [OuterEnum].self, source: source, instance: instance) } // Decoder for OuterEnum @@ -1063,7 +1038,6 @@ class Decoders { // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Pet]> in return Decoders.decode(clazz: [Pet].self, source: source, instance: instance) } // Decoder for Pet @@ -1115,7 +1089,6 @@ class Decoders { // Decoder for [ReadOnlyFirst] - Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ReadOnlyFirst]> in return Decoders.decode(clazz: [ReadOnlyFirst].self, source: source, instance: instance) } // Decoder for ReadOnlyFirst @@ -1143,7 +1116,6 @@ class Decoders { // Decoder for [Return] - Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Return]> in return Decoders.decode(clazz: [Return].self, source: source, instance: instance) } // Decoder for Return @@ -1165,7 +1137,6 @@ class Decoders { // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[SpecialModelName]> in return Decoders.decode(clazz: [SpecialModelName].self, source: source, instance: instance) } // Decoder for SpecialModelName @@ -1187,7 +1158,6 @@ class Decoders { // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Tag]> in return Decoders.decode(clazz: [Tag].self, source: source, instance: instance) } // Decoder for Tag @@ -1215,7 +1185,6 @@ class Decoders { // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[User]> in return Decoders.decode(clazz: [User].self, source: source, instance: instance) } // Decoder for User 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 44748ca898b..e4243744c6c 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: [{example={ + - examples: [{contentType=application/json, example={ "client" : "aeiou" -}, contentType=application/json}] +}}] - parameter body: (body) client model diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift index 9d6452226ff..e578e04ba23 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift @@ -44,9 +44,9 @@ open class Fake_classname_tags123API: APIBase { /** To test class name in snake case - PATCH /fake_classname_test - - examples: [{example={ + - examples: [{contentType=application/json, 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 46585b5fac1..1b4f331fc1d 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -184,21 +184,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -207,20 +207,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -288,21 +288,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -311,20 +311,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -392,21 +392,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example={ - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -415,20 +415,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example={ - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] - parameter petId: (path) ID of pet to return @@ -612,11 +612,11 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "message" : "aeiou", + - examples: [{contentType=application/json, example={ "code" : 0, - "type" : "aeiou" -}, contentType=application/json}] + "type" : "aeiou", + "message" : "aeiou" +}}] - 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 39d97ab1740..f2bd2f0c387 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: [{example={ + - examples: [{contentType=application/json, 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] - - examples: [{example= + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] - - examples: [{example= + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] - 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 6e061e76765..02bd372ac49 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 aeiou aeiou @@ -263,17 +263,17 @@ open class UserAPI: APIBase { aeiou aeiou 123 -, contentType=application/xml}, {example={ - "id" : 0, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 6, +}, {contentType=application/json, example={ "firstName" : "aeiou", - "password" : "aeiou" -}, contentType=application/json}] - - examples: [{example= + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] + - examples: [{contentType=application/xml, example= 123456789 aeiou aeiou @@ -282,16 +282,16 @@ open class UserAPI: APIBase { aeiou aeiou 123 -, contentType=application/xml}, {example={ - "id" : 0, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 6, +}, {contentType=application/json, example={ "firstName" : "aeiou", - "password" : "aeiou" -}, contentType=application/json}] + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] - 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: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] - - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] - 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/Models.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift index 2dd4a72e0c4..a25903a430f 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift @@ -252,7 +252,6 @@ class Decoders { } // Decoder for [AdditionalPropertiesClass] - Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[AdditionalPropertiesClass]> in return Decoders.decode(clazz: [AdditionalPropertiesClass].self, source: source, instance: instance) } // Decoder for AdditionalPropertiesClass @@ -280,7 +279,6 @@ class Decoders { // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Animal]> in return Decoders.decode(clazz: [Animal].self, source: source, instance: instance) } // Decoder for Animal @@ -315,7 +313,6 @@ class Decoders { // Decoder for [ApiResponse] - Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ApiResponse]> in return Decoders.decode(clazz: [ApiResponse].self, source: source, instance: instance) } // Decoder for ApiResponse @@ -349,7 +346,6 @@ class Decoders { // Decoder for [ArrayOfArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayOfArrayOfNumberOnly]> in return Decoders.decode(clazz: [ArrayOfArrayOfNumberOnly].self, source: source, instance: instance) } // Decoder for ArrayOfArrayOfNumberOnly @@ -371,7 +367,6 @@ class Decoders { // Decoder for [ArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayOfNumberOnly]> in return Decoders.decode(clazz: [ArrayOfNumberOnly].self, source: source, instance: instance) } // Decoder for ArrayOfNumberOnly @@ -393,7 +388,6 @@ class Decoders { // Decoder for [ArrayTest] - Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayTest]> in return Decoders.decode(clazz: [ArrayTest].self, source: source, instance: instance) } // Decoder for ArrayTest @@ -427,7 +421,6 @@ class Decoders { // Decoder for [Capitalization] - Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Capitalization]> in return Decoders.decode(clazz: [Capitalization].self, source: source, instance: instance) } // Decoder for Capitalization @@ -479,7 +472,6 @@ class Decoders { // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Cat]> in return Decoders.decode(clazz: [Cat].self, source: source, instance: instance) } // Decoder for Cat @@ -516,7 +508,6 @@ class Decoders { // Decoder for [Category] - Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Category]> in return Decoders.decode(clazz: [Category].self, source: source, instance: instance) } // Decoder for Category @@ -544,7 +535,6 @@ class Decoders { // Decoder for [ClassModel] - Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ClassModel]> in return Decoders.decode(clazz: [ClassModel].self, source: source, instance: instance) } // Decoder for ClassModel @@ -566,7 +556,6 @@ class Decoders { // Decoder for [Client] - Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Client]> in return Decoders.decode(clazz: [Client].self, source: source, instance: instance) } // Decoder for Client @@ -588,7 +577,6 @@ class Decoders { // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Dog]> in return Decoders.decode(clazz: [Dog].self, source: source, instance: instance) } // Decoder for Dog @@ -625,7 +613,6 @@ class Decoders { // Decoder for [EnumArrays] - Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumArrays]> in return Decoders.decode(clazz: [EnumArrays].self, source: source, instance: instance) } // Decoder for EnumArrays @@ -653,7 +640,6 @@ class Decoders { // Decoder for [EnumClass] - Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumClass]> in return Decoders.decode(clazz: [EnumClass].self, source: source, instance: instance) } // Decoder for EnumClass @@ -664,7 +650,6 @@ class Decoders { // Decoder for [EnumTest] - Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumTest]> in return Decoders.decode(clazz: [EnumTest].self, source: source, instance: instance) } // Decoder for EnumTest @@ -704,7 +689,6 @@ class Decoders { // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[FormatTest]> in return Decoders.decode(clazz: [FormatTest].self, source: source, instance: instance) } // Decoder for FormatTest @@ -798,7 +782,6 @@ class Decoders { // Decoder for [HasOnlyReadOnly] - Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[HasOnlyReadOnly]> in return Decoders.decode(clazz: [HasOnlyReadOnly].self, source: source, instance: instance) } // Decoder for HasOnlyReadOnly @@ -826,7 +809,6 @@ class Decoders { // Decoder for [List] - Decoders.addDecoder(clazz: [List].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[List]> in return Decoders.decode(clazz: [List].self, source: source, instance: instance) } // Decoder for List @@ -848,7 +830,6 @@ class Decoders { // Decoder for [MapTest] - Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[MapTest]> in return Decoders.decode(clazz: [MapTest].self, source: source, instance: instance) } // Decoder for MapTest @@ -876,7 +857,6 @@ class Decoders { // Decoder for [MixedPropertiesAndAdditionalPropertiesClass] - Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[MixedPropertiesAndAdditionalPropertiesClass]> in return Decoders.decode(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self, source: source, instance: instance) } // Decoder for MixedPropertiesAndAdditionalPropertiesClass @@ -910,7 +890,6 @@ class Decoders { // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Model200Response]> in return Decoders.decode(clazz: [Model200Response].self, source: source, instance: instance) } // Decoder for Model200Response @@ -938,7 +917,6 @@ class Decoders { // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Name]> in return Decoders.decode(clazz: [Name].self, source: source, instance: instance) } // Decoder for Name @@ -978,7 +956,6 @@ class Decoders { // Decoder for [NumberOnly] - Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[NumberOnly]> in return Decoders.decode(clazz: [NumberOnly].self, source: source, instance: instance) } // Decoder for NumberOnly @@ -1000,7 +977,6 @@ class Decoders { // Decoder for [Order] - Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Order]> in return Decoders.decode(clazz: [Order].self, source: source, instance: instance) } // Decoder for Order @@ -1052,7 +1028,6 @@ class Decoders { // Decoder for [OuterEnum] - Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[OuterEnum]> in return Decoders.decode(clazz: [OuterEnum].self, source: source, instance: instance) } // Decoder for OuterEnum @@ -1063,7 +1038,6 @@ class Decoders { // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Pet]> in return Decoders.decode(clazz: [Pet].self, source: source, instance: instance) } // Decoder for Pet @@ -1115,7 +1089,6 @@ class Decoders { // Decoder for [ReadOnlyFirst] - Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ReadOnlyFirst]> in return Decoders.decode(clazz: [ReadOnlyFirst].self, source: source, instance: instance) } // Decoder for ReadOnlyFirst @@ -1143,7 +1116,6 @@ class Decoders { // Decoder for [Return] - Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Return]> in return Decoders.decode(clazz: [Return].self, source: source, instance: instance) } // Decoder for Return @@ -1165,7 +1137,6 @@ class Decoders { // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[SpecialModelName]> in return Decoders.decode(clazz: [SpecialModelName].self, source: source, instance: instance) } // Decoder for SpecialModelName @@ -1187,7 +1158,6 @@ class Decoders { // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Tag]> in return Decoders.decode(clazz: [Tag].self, source: source, instance: instance) } // Decoder for Tag @@ -1215,7 +1185,6 @@ class Decoders { // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[User]> in return Decoders.decode(clazz: [User].self, source: source, instance: instance) } // Decoder for User 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 5139fb433a8..58e2f2b7b8b 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: [{example={ + - examples: [{contentType=application/json, example={ "client" : "aeiou" -}, contentType=application/json}] +}}] - parameter body: (body) client model diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift index 5197283948d..dda46ead7f0 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/APIs/Fake_classname_tags123API.swift @@ -46,9 +46,9 @@ open class Fake_classname_tags123API: APIBase { /** To test class name in snake case - PATCH /fake_classname_test - - examples: [{example={ + - examples: [{contentType=application/json, 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 06fdd448f52..5c457e4eb02 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -190,21 +190,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -213,20 +213,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -296,21 +296,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -319,20 +319,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example=[ { - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +} ]}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -402,21 +402,21 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example={ - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}] - - examples: [{example= + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] + - examples: [{contentType=application/xml, example= 123456789 doggie @@ -425,20 +425,20 @@ open class PetAPI: APIBase { aeiou -, contentType=application/xml}, {example={ - "tags" : [ { - "id" : 1, - "name" : "aeiou" - } ], +}, {contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 0, "category" : { - "id" : 6, - "name" : "aeiou" + "name" : "aeiou", + "id" : 6 }, - "status" : "available", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}] + "tags" : [ { + "name" : "aeiou", + "id" : 1 + } ], + "status" : "available" +}}] - parameter petId: (path) ID of pet to return @@ -628,11 +628,11 @@ open class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "message" : "aeiou", + - examples: [{contentType=application/json, example={ "code" : 0, - "type" : "aeiou" -}, contentType=application/json}] + "type" : "aeiou", + "message" : "aeiou" +}}] - 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 5a385423ecc..045661cc371 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: [{example={ + - examples: [{contentType=application/json, 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] - - examples: [{example= + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] - 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] - - examples: [{example= + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] + - examples: [{contentType=application/xml, example= 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true -, contentType=application/xml}, {example={ - "id" : 0, +}, {contentType=application/json, example={ "petId" : 6, - "complete" : false, - "status" : "placed", "quantity" : 1, - "shipDate" : "2000-01-23T04:56:07.000+00:00" -}, contentType=application/json}] + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" +}}] - 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 420bdfb2eca..a2a0cd23970 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: [{example= + - examples: [{contentType=application/xml, example= 123456789 aeiou aeiou @@ -273,17 +273,17 @@ open class UserAPI: APIBase { aeiou aeiou 123 -, contentType=application/xml}, {example={ - "id" : 0, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 6, +}, {contentType=application/json, example={ "firstName" : "aeiou", - "password" : "aeiou" -}, contentType=application/json}] - - examples: [{example= + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] + - examples: [{contentType=application/xml, example= 123456789 aeiou aeiou @@ -292,16 +292,16 @@ open class UserAPI: APIBase { aeiou aeiou 123 -, contentType=application/xml}, {example={ - "id" : 0, - "lastName" : "aeiou", - "phone" : "aeiou", - "username" : "aeiou", - "email" : "aeiou", - "userStatus" : 6, +}, {contentType=application/json, example={ "firstName" : "aeiou", - "password" : "aeiou" -}, contentType=application/json}] + "lastName" : "aeiou", + "password" : "aeiou", + "userStatus" : 6, + "phone" : "aeiou", + "id" : 0, + "email" : "aeiou", + "username" : "aeiou" +}}] - 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: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] - - examples: [{example=aeiou, contentType=application/xml}, {example="aeiou", contentType=application/json}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] + - examples: [{contentType=application/xml, example=aeiou}, {contentType=application/json, example="aeiou"}] - 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/Models.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift index 2dd4a72e0c4..a25903a430f 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift @@ -252,7 +252,6 @@ class Decoders { } // Decoder for [AdditionalPropertiesClass] - Decoders.addDecoder(clazz: [AdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[AdditionalPropertiesClass]> in return Decoders.decode(clazz: [AdditionalPropertiesClass].self, source: source, instance: instance) } // Decoder for AdditionalPropertiesClass @@ -280,7 +279,6 @@ class Decoders { // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Animal]> in return Decoders.decode(clazz: [Animal].self, source: source, instance: instance) } // Decoder for Animal @@ -315,7 +313,6 @@ class Decoders { // Decoder for [ApiResponse] - Decoders.addDecoder(clazz: [ApiResponse].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ApiResponse]> in return Decoders.decode(clazz: [ApiResponse].self, source: source, instance: instance) } // Decoder for ApiResponse @@ -349,7 +346,6 @@ class Decoders { // Decoder for [ArrayOfArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayOfArrayOfNumberOnly]> in return Decoders.decode(clazz: [ArrayOfArrayOfNumberOnly].self, source: source, instance: instance) } // Decoder for ArrayOfArrayOfNumberOnly @@ -371,7 +367,6 @@ class Decoders { // Decoder for [ArrayOfNumberOnly] - Decoders.addDecoder(clazz: [ArrayOfNumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayOfNumberOnly]> in return Decoders.decode(clazz: [ArrayOfNumberOnly].self, source: source, instance: instance) } // Decoder for ArrayOfNumberOnly @@ -393,7 +388,6 @@ class Decoders { // Decoder for [ArrayTest] - Decoders.addDecoder(clazz: [ArrayTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ArrayTest]> in return Decoders.decode(clazz: [ArrayTest].self, source: source, instance: instance) } // Decoder for ArrayTest @@ -427,7 +421,6 @@ class Decoders { // Decoder for [Capitalization] - Decoders.addDecoder(clazz: [Capitalization].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Capitalization]> in return Decoders.decode(clazz: [Capitalization].self, source: source, instance: instance) } // Decoder for Capitalization @@ -479,7 +472,6 @@ class Decoders { // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Cat]> in return Decoders.decode(clazz: [Cat].self, source: source, instance: instance) } // Decoder for Cat @@ -516,7 +508,6 @@ class Decoders { // Decoder for [Category] - Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Category]> in return Decoders.decode(clazz: [Category].self, source: source, instance: instance) } // Decoder for Category @@ -544,7 +535,6 @@ class Decoders { // Decoder for [ClassModel] - Decoders.addDecoder(clazz: [ClassModel].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ClassModel]> in return Decoders.decode(clazz: [ClassModel].self, source: source, instance: instance) } // Decoder for ClassModel @@ -566,7 +556,6 @@ class Decoders { // Decoder for [Client] - Decoders.addDecoder(clazz: [Client].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Client]> in return Decoders.decode(clazz: [Client].self, source: source, instance: instance) } // Decoder for Client @@ -588,7 +577,6 @@ class Decoders { // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Dog]> in return Decoders.decode(clazz: [Dog].self, source: source, instance: instance) } // Decoder for Dog @@ -625,7 +613,6 @@ class Decoders { // Decoder for [EnumArrays] - Decoders.addDecoder(clazz: [EnumArrays].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumArrays]> in return Decoders.decode(clazz: [EnumArrays].self, source: source, instance: instance) } // Decoder for EnumArrays @@ -653,7 +640,6 @@ class Decoders { // Decoder for [EnumClass] - Decoders.addDecoder(clazz: [EnumClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumClass]> in return Decoders.decode(clazz: [EnumClass].self, source: source, instance: instance) } // Decoder for EnumClass @@ -664,7 +650,6 @@ class Decoders { // Decoder for [EnumTest] - Decoders.addDecoder(clazz: [EnumTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[EnumTest]> in return Decoders.decode(clazz: [EnumTest].self, source: source, instance: instance) } // Decoder for EnumTest @@ -704,7 +689,6 @@ class Decoders { // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[FormatTest]> in return Decoders.decode(clazz: [FormatTest].self, source: source, instance: instance) } // Decoder for FormatTest @@ -798,7 +782,6 @@ class Decoders { // Decoder for [HasOnlyReadOnly] - Decoders.addDecoder(clazz: [HasOnlyReadOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[HasOnlyReadOnly]> in return Decoders.decode(clazz: [HasOnlyReadOnly].self, source: source, instance: instance) } // Decoder for HasOnlyReadOnly @@ -826,7 +809,6 @@ class Decoders { // Decoder for [List] - Decoders.addDecoder(clazz: [List].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[List]> in return Decoders.decode(clazz: [List].self, source: source, instance: instance) } // Decoder for List @@ -848,7 +830,6 @@ class Decoders { // Decoder for [MapTest] - Decoders.addDecoder(clazz: [MapTest].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[MapTest]> in return Decoders.decode(clazz: [MapTest].self, source: source, instance: instance) } // Decoder for MapTest @@ -876,7 +857,6 @@ class Decoders { // Decoder for [MixedPropertiesAndAdditionalPropertiesClass] - Decoders.addDecoder(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[MixedPropertiesAndAdditionalPropertiesClass]> in return Decoders.decode(clazz: [MixedPropertiesAndAdditionalPropertiesClass].self, source: source, instance: instance) } // Decoder for MixedPropertiesAndAdditionalPropertiesClass @@ -910,7 +890,6 @@ class Decoders { // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Model200Response]> in return Decoders.decode(clazz: [Model200Response].self, source: source, instance: instance) } // Decoder for Model200Response @@ -938,7 +917,6 @@ class Decoders { // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Name]> in return Decoders.decode(clazz: [Name].self, source: source, instance: instance) } // Decoder for Name @@ -978,7 +956,6 @@ class Decoders { // Decoder for [NumberOnly] - Decoders.addDecoder(clazz: [NumberOnly].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[NumberOnly]> in return Decoders.decode(clazz: [NumberOnly].self, source: source, instance: instance) } // Decoder for NumberOnly @@ -1000,7 +977,6 @@ class Decoders { // Decoder for [Order] - Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Order]> in return Decoders.decode(clazz: [Order].self, source: source, instance: instance) } // Decoder for Order @@ -1052,7 +1028,6 @@ class Decoders { // Decoder for [OuterEnum] - Decoders.addDecoder(clazz: [OuterEnum].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[OuterEnum]> in return Decoders.decode(clazz: [OuterEnum].self, source: source, instance: instance) } // Decoder for OuterEnum @@ -1063,7 +1038,6 @@ class Decoders { // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Pet]> in return Decoders.decode(clazz: [Pet].self, source: source, instance: instance) } // Decoder for Pet @@ -1115,7 +1089,6 @@ class Decoders { // Decoder for [ReadOnlyFirst] - Decoders.addDecoder(clazz: [ReadOnlyFirst].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[ReadOnlyFirst]> in return Decoders.decode(clazz: [ReadOnlyFirst].self, source: source, instance: instance) } // Decoder for ReadOnlyFirst @@ -1143,7 +1116,6 @@ class Decoders { // Decoder for [Return] - Decoders.addDecoder(clazz: [Return].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Return]> in return Decoders.decode(clazz: [Return].self, source: source, instance: instance) } // Decoder for Return @@ -1165,7 +1137,6 @@ class Decoders { // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[SpecialModelName]> in return Decoders.decode(clazz: [SpecialModelName].self, source: source, instance: instance) } // Decoder for SpecialModelName @@ -1187,7 +1158,6 @@ class Decoders { // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[Tag]> in return Decoders.decode(clazz: [Tag].self, source: source, instance: instance) } // Decoder for Tag @@ -1215,7 +1185,6 @@ class Decoders { // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject, instance: AnyObject?) -> Decoded<[User]> in return Decoders.decode(clazz: [User].self, source: source, instance: instance) } // Decoder for 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..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 @@ -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; @@ -28,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) { + 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)); } @@ -45,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)); } @@ -60,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/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 481c651fda1..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 @@ -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; @@ -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; @@ -32,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)); } @@ -51,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)); } @@ -70,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) { + 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)); } @@ -89,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) { + 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)); } @@ -106,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) { + 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)); } @@ -126,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)); } @@ -145,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)); } @@ -164,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) { + 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/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..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 @@ -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; @@ -27,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)); } @@ -42,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() { + default CompletableFuture>> getInventory( @RequestHeader("Accept") String accept) throws IOException { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity>(HttpStatus.OK)); } @@ -57,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) { + 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)); } @@ -71,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) { + 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/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..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 @@ -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; @@ -26,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)); } @@ -39,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)); } @@ -52,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)); } @@ -66,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)); } @@ -81,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) { + 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)); } @@ -95,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) { + 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)); } @@ -108,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)); } @@ -122,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/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 7af53f97653..e889c25637f 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.*; @@ -26,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); + 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 = { @@ -40,23 +40,20 @@ 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) OffsetDateTime 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); + 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 6c3e161c97e..63f3e243be6 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,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) 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 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/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..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 @@ -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; @@ -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.*; @@ -30,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 = { @@ -46,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 = { @@ -62,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); + 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 = { @@ -78,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); + 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 = { @@ -92,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); + 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 = { @@ -109,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 = { @@ -125,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 = { @@ -141,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); + 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 80a62f62c29..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 @@ -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.*; @@ -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/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..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 @@ -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.*; @@ -25,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 = { @@ -37,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(); + 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", }) @@ -49,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); + 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); + 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 472bda2ada0..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 @@ -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/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..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 @@ -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.*; @@ -24,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", }) @@ -67,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); + 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); + 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 00d7e5deba1..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 @@ -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); } 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 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 index b0ed6f9a514..d8b307a1f23 100644 --- 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 @@ -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.*; @@ -26,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); + 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 = { @@ -40,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/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java index 5cf609a4ae0..5bac24daffa 100644 --- 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 @@ -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-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..5816fb5b92e 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; @@ -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.*; @@ -30,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 = { @@ -46,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 = { @@ -62,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); + 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 = { @@ -78,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); + 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 = { @@ -92,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); + 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 = { @@ -109,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 = { @@ -125,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 = { @@ -141,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); + 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 index 80a62f62c29..220aa32691d 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.*; @@ -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-beanvalidation/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java index 8b080a440dd..fb8f3d706f5 100644 --- 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 @@ -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.*; @@ -25,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 = { @@ -37,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(); + 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", }) @@ -49,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); + 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); + 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 index 472bda2ada0..3eb23194cb1 100644 --- 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 @@ -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-beanvalidation/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java index 4993fa21bfd..53899d1eddd 100644 --- 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 @@ -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.*; @@ -24,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", }) @@ -67,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); + 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); + 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/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java index 00d7e5deba1..d8cac8d5eb8 100644 --- 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 @@ -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); } 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 c924d5539d8..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 @@ -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; @@ -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 c498459bfb0..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 @@ -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.*; @@ -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/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-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 7af53f97653..d8e2ad19b3a 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 3c552279654..14f0bee8ceb 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) 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/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java index 911092d3307..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 @@ -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; @@ -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 c498459bfb0..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 @@ -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.*; @@ -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/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-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 7af53f97653..18dbcb234a7 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 = { @@ -47,7 +48,6 @@ public interface FakeApi { 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) OffsetDateTime 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), @@ -57,6 +57,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 6c3e161c97e..4b38f63bf40 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) 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 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 911092d3307..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 @@ -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; @@ -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 80a62f62c29..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 @@ -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.*; @@ -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); }