diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9309b70418ae..7758d8166d11 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,7 +2,7 @@
## Before submitting an issue
- - Before submitting an issue, search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
+ - Search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
- The issue should contain details on how to repeat the issue, e.g.
- the OpenAPI Spec for reproducing the issue (:bulb: use [Gist](https://gist.github.com) to share). If the OpenAPI Spec cannot be shared publicly, it will be hard for the community to help
- version of Swagger Codegen
@@ -31,7 +31,7 @@ For a list of variables available in the template, please refer to this [page](h
Code change should conform to the programming style guide of the respective langauages:
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
- Java: https://google.github.io/styleguide/javaguide.html
-- JavaScript - https://github.com/airbnb/javascript
+- JavaScript - https://github.com/airbnb/javascript/tree/master/es5
- ObjC: https://github.com/NYTimes/objective-c-style-guide
- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
- Python: https://www.python.org/dev/peps/pep-0008/
diff --git a/README.md b/README.md
index 9bd5fdb01fe2..f4dfda85b6bc 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,13 @@
# Swagger Code Generator
-[](https://travis-ci.org/swagger-api/swagger-codegen)
+[](https://travis-ci.org/swagger-api/swagger-codegen)
[](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project)
+[](http://issuestats.com/github/swagger-api/swagger-codegen) [](http://issuestats.com/github/swagger-api/swagger-codegen)
:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star:
## Overview
-This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
+This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project, including additional libraries with support for other languages and more.
@@ -351,7 +352,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-o samples/client/petstore/java \
-c path/to/config.json
```
-Supported config options can be different per language. Running `config-help -l {lang}` will show available options. **These options are applied
+Supported config options can be different per language. Running `config-help -l {lang}` will show available options. **These options are applied
by passing them with `-D{optionName}={optionValue}**.
```
@@ -402,9 +403,9 @@ CONFIG OPTIONS
retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)
```
-Your config file for java can look like
+Your config file for Java can look like
-```
+```json
{
"groupId":"com.my.company",
"artifactId":"MyClent",
@@ -418,15 +419,15 @@ For all the unspecified options default values will be used.
Another way to override default options is to extend the config class for the specific language.
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
-```
+```java
package com.mycompany.swagger.codegen;
import io.swagger.codegen.languages.*;
public class MyObjcCodegen extends ObjcClientCodegen {
- static {
- PREFIX = "HELO";
- }
+ static {
+ PREFIX = "HELO";
+ }
}
```
@@ -512,7 +513,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
- -l flaskConnexion \
+ -l python-flask \
-o samples/server/petstore/flaskConnexion
```
@@ -553,7 +554,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
### To build the codegen library
-This will create the swagger-codegen library from source.
+This will create the swagger-codegen library from source.
```
mvn package
diff --git a/bin/go-petstore.sh b/bin/go-petstore.sh
new file mode 100644
index 000000000000..239f31f0d716
--- /dev/null
+++ b/bin/go-petstore.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+SCRIPT="$0"
+
+while [ -h "$SCRIPT" ] ; do
+ ls=`ls -ld "$SCRIPT"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ SCRIPT="$link"
+ else
+ SCRIPT=`dirname "$SCRIPT"`/"$link"
+ fi
+done
+
+if [ ! -d "${APP_DIR}" ]; then
+ APP_DIR=`dirname "$SCRIPT"`/..
+ APP_DIR=`cd "${APP_DIR}"; pwd`
+fi
+
+executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
+
+if [ ! -f "$executable" ]
+then
+ mvn clean package
+fi
+
+# if you've executed sbt assembly previously it will use that instead.
+export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l go -o samples/client/petstore/go"
+
+java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/windows/go-petstore.bat b/bin/windows/go-petstore.bat
new file mode 100644
index 000000000000..050bfd23cc84
--- /dev/null
+++ b/bin/windows/go-petstore.bat
@@ -0,0 +1,10 @@
+set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
+
+If Not Exist %executable% (
+ mvn clean package
+)
+
+set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
+set ags=generate -t modules\swagger-codegen\src\main\resources\go -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l go -o samples\client\petstore\go
+
+java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml
index 9100143a2365..c118a6325ef2 100644
--- a/modules/swagger-codegen-cli/pom.xml
+++ b/modules/swagger-codegen-cli/pom.xml
@@ -89,13 +89,13 @@
org.testng
testng
- ${testng-version}
+
test
org.jmockit
jmockit
- ${jmockit-version}
+
test
diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java
index 502e4d046bae..98c0b8c05b5e 100644
--- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java
+++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java
@@ -21,6 +21,7 @@ public class SwaggerCodegen {
public static void main(String[] args) {
+ @SuppressWarnings("unchecked")
Cli.CliBuilder builder = Cli.builder("swagger-codegen-cli")
.withDescription("Swagger code generator CLI. More info on swagger.io")
.withDefaultCommand(Langs.class)
diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java
index d72295f4ca97..4fad4308a670 100644
--- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java
+++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java
@@ -230,15 +230,15 @@ public class Generate implements Runnable {
}
}
- private Set createSetFromCsvList(String csvProperty) {
+ private static Set createSetFromCsvList(String csvProperty) {
final List values = OptionUtils.splitCommaSeparatedList(csvProperty);
return new HashSet(values);
}
- private Map createMapFromKeyValuePairs(String commaSeparatedKVPairs) {
+ private static Map createMapFromKeyValuePairs(String commaSeparatedKVPairs) {
final List> pairs = OptionUtils.parseCommaSeparatedTuples(commaSeparatedKVPairs);
- Map result = new HashMap();
+ Map result = new HashMap();
for (Pair pair : pairs) {
result.put(pair.getLeft(), pair.getRight());
diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java
index 9843024b1043..348c94d92b0c 100644
--- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java
+++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java
@@ -93,7 +93,7 @@ public class Meta implements Runnable {
* @param data - map with additional params needed to process templates
* @return converter object to pass to lambdaj
*/
- private Converter processFiles(final File targetDir, final Map data) {
+ private static Converter processFiles(final File targetDir, final Map data) {
return new Converter() {
private DefaultGenerator generator = new DefaultGenerator();
@@ -133,7 +133,7 @@ public class Meta implements Runnable {
* @param generator - class with reader getter
* @return loader for template
*/
- private Mustache.TemplateLoader loader(final DefaultGenerator generator) {
+ private static Mustache.TemplateLoader loader(final DefaultGenerator generator) {
return new Mustache.TemplateLoader() {
@Override
public Reader getTemplate(String name) {
@@ -149,7 +149,7 @@ public class Meta implements Runnable {
* @param packageName - package name to convert
* @return relative path
*/
- private String asPath(String packageName) {
+ private static String asPath(String packageName) {
return packageName.replace(".", File.separator);
}
}
diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java
index e07d0be4610d..36a560b776de 100644
--- a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java
+++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java
@@ -12,6 +12,7 @@ import mockit.Verifications;
import org.apache.commons.lang3.ArrayUtils;
import org.testng.annotations.Test;
+@SuppressWarnings("unused")
public class GenerateTest {
@Mocked
diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java
index a7dc4d7f1cd4..480631c913cd 100644
--- a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java
+++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java
@@ -10,6 +10,7 @@ import java.util.List;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+@SuppressWarnings("static-method")
public class OptionUtilsTest {
@Test
@@ -30,7 +31,7 @@ public class OptionUtilsTest {
doTupleListTest(null, new ArrayList>());
}
- private void doTupleListTest(String input, List> expectedResults) {
+ private static void doTupleListTest(String input, List> expectedResults) {
final List> result = OptionUtils.parseCommaSeparatedTuples(input);
assertNotNull(result);
assertEquals(result.size(), expectedResults.size());
@@ -41,7 +42,7 @@ public class OptionUtilsTest {
}
}
- private void doCommaSeparatedListTest(String csvStr, List expectedResults) {
+ private static void doCommaSeparatedListTest(String csvStr, List expectedResults) {
final List result = OptionUtils.splitCommaSeparatedList(csvStr);
assertNotNull(result);
assertEquals(result.size(), expectedResults.size());
diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml
index 850ac7355347..52cf252d3094 100644
--- a/modules/swagger-codegen-maven-plugin/pom.xml
+++ b/modules/swagger-codegen-maven-plugin/pom.xml
@@ -51,7 +51,7 @@
junit
junit
- 4.12
+
test
diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java
index c56b86588e54..1608329f9532 100644
--- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java
+++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java
@@ -99,7 +99,7 @@ public class CodeGenMojo extends AbstractMojo {
* A map of language-specific parameters as passed with the -c option to the command line
*/
@Parameter(name = "configOptions")
- private Map configOptions;
+ private Map, ?> configOptions;
/**
* Add the output directory to the project as a source root, so that the
diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml
index 29d2dc4e1484..a5c4eedd7406 100644
--- a/modules/swagger-codegen/pom.xml
+++ b/modules/swagger-codegen/pom.xml
@@ -101,7 +101,7 @@
org.apache.maven.plugins
maven-release-plugin
- 2.1
+
org.apache.maven.plugins
@@ -256,7 +256,7 @@
org.testng
testng
- ${testng-version}
+
test
@@ -268,7 +268,7 @@
org.jmockit
jmockit
- ${jmockit-version}
+
test
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java
index d6bbb9fa5261..467d6e40b903 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java
@@ -14,6 +14,7 @@ import java.util.regex.Pattern;
public abstract class AbstractGenerator {
+ @SuppressWarnings("static-method")
public File writeToFile(String filename, String contents) throws IOException {
System.out.println("writing file " + filename);
File output = new File(filename);
@@ -48,10 +49,7 @@ public abstract class AbstractGenerator {
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
if (is == null) {
- is = new FileInputStream(new File(name));
- }
- if (is == null) {
- throw new RuntimeException("no file found");
+ is = new FileInputStream(new File(name)); // May throw but never return a null value
}
return new InputStreamReader(is);
} catch (Exception e) {
@@ -96,6 +94,7 @@ public abstract class AbstractGenerator {
return this.getClass().getClassLoader().getResource(getCPResourcePath(name)) != null;
}
+ @SuppressWarnings("static-method")
public String getCPResourcePath(String name) {
if (!"/".equals(File.separator)) {
return name.replaceAll(Pattern.quote(File.separator), "/");
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java
index 571498c3121f..57918dd9b354 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java
@@ -5,13 +5,8 @@ import io.swagger.codegen.auth.AuthParser;
import io.swagger.models.Swagger;
import io.swagger.models.auth.AuthorizationValue;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
import java.util.List;
-import static org.apache.commons.lang3.StringUtils.isNotEmpty;
-
public class ClientOptInput {
private CodegenConfig config;
private ClientOpts opts;
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java
index ffb4a0112a57..3168808e5b17 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java
@@ -11,7 +11,6 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -32,10 +31,9 @@ public class Codegen extends DefaultGenerator {
"\n -DdebugOperations prints operations passed to the template engine" +
"\n -DdebugSupportingFiles prints additional data passed to the template engine";
+ @SuppressWarnings("deprecation")
public static void main(String[] args) {
- StringBuilder sb = new StringBuilder();
-
Options options = new Options();
options.addOption("h", "help", false, "shows this message");
options.addOption("l", "lang", true, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
@@ -139,7 +137,7 @@ public class Codegen extends DefaultGenerator {
// see if it's a class
try {
System.out.println("loading class " + name);
- Class customClass = Class.forName(name);
+ Class> customClass = Class.forName(name);
System.out.println("loaded");
return (CodegenConfig) customClass.newInstance();
} catch (Exception e) {
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java
index 4a4f9e037ef2..f964ebfd1c41 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java
@@ -62,4 +62,10 @@ public class CodegenConstants {
public static final String OPTIONAL_ASSEMBLY_INFO = "optionalAssemblyInfo";
public static final String OPTIONAL_ASSEMBLY_INFO_DESC = "Generate AssemblyInfo.cs (Default: true).";
+ public static final String OPTIONAL_PROJECT_FILE = "optionalProjectFile";
+ public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate {PackageName}.csproj (Default: false).";
+
+ public static final String OPTIONAL_PROJECT_GUID = "packageGuid";
+ public static final String OPTIONAL_PROJECT_GUID_DESC = "The GUID that will be associated with the C# project";
+
}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java
index c5b9231341e1..956e906b44f9 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java
@@ -38,7 +38,7 @@ public class CodegenOperation {
*
* @return true if parameter exists, false otherwise
*/
- private boolean nonempty(List params) {
+ private static boolean nonempty(List params) {
return params != null && params.size() > 0;
}
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java
index 87352907ad0b..d80bc38a4c75 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java
@@ -40,6 +40,50 @@ public class CodegenProperty {
public CodegenProperty items;
public Map vendorExtensions;
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((_enum == null) ? 0 : _enum.hashCode());
+ result = prime * result + ((allowableValues == null) ? 0 : allowableValues.hashCode());
+ result = prime * result + ((baseName == null) ? 0 : baseName.hashCode());
+ result = prime * result + ((baseType == null) ? 0 : baseType.hashCode());
+ result = prime * result + ((complexType == null) ? 0 : complexType.hashCode());
+ result = prime * result + ((containerType == null) ? 0 : containerType.hashCode());
+ result = prime * result + ((datatype == null) ? 0 : datatype.hashCode());
+ result = prime * result + ((datatypeWithEnum == null) ? 0 : datatypeWithEnum.hashCode());
+ result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+ result = prime * result + ((defaultValueWithParam == null) ? 0 : defaultValueWithParam.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((example == null) ? 0 : example.hashCode());
+ result = prime * result + ((exclusiveMaximum == null) ? 0 : exclusiveMaximum.hashCode());
+ result = prime * result + ((exclusiveMinimum == null) ? 0 : exclusiveMinimum.hashCode());
+ result = prime * result + ((getter == null) ? 0 : getter.hashCode());
+ result = prime * result + ((hasMore == null) ? 0 : hasMore.hashCode());
+ result = prime * result + ((isContainer == null) ? 0 : isContainer.hashCode());
+ result = prime * result + (isEnum ? 1231 : 1237);
+ result = prime * result + ((isNotContainer == null) ? 0 : isNotContainer.hashCode());
+ result = prime * result + ((isPrimitiveType == null) ? 0 : isPrimitiveType.hashCode());
+ result = prime * result + ((isReadOnly == null) ? 0 : isReadOnly.hashCode());
+ result = prime * result + ((items == null) ? 0 : items.hashCode());
+ result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode());
+ result = prime * result + ((max == null) ? 0 : max.hashCode());
+ result = prime * result + ((maxLength == null) ? 0 : maxLength.hashCode());
+ result = prime * result + ((maximum == null) ? 0 : maximum.hashCode());
+ result = prime * result + ((min == null) ? 0 : min.hashCode());
+ result = prime * result + ((minLength == null) ? 0 : minLength.hashCode());
+ result = prime * result + ((minimum == null) ? 0 : minimum.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
+ result = prime * result + ((required == null) ? 0 : required.hashCode());
+ result = prime * result + ((secondaryParam == null) ? 0 : secondaryParam.hashCode());
+ result = prime * result + ((setter == null) ? 0 : setter.hashCode());
+ result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode());
+ result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode());
+ return result;
+ }
+
@Override
public boolean equals(Object obj) {
if (obj == null) {
diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
index f9bd468a25b8..968fbae5381d 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
@@ -109,38 +109,48 @@ public class DefaultCodegen {
}
// override with any special post-processing
+ @SuppressWarnings("static-method")
public Map postProcessModels(Map objs) {
return objs;
}
// override with any special post-processing
+ @SuppressWarnings("static-method")
public Map postProcessOperations(Map objs) {
return objs;
}
// override with any special post-processing
+ @SuppressWarnings("static-method")
public Map postProcessSupportingFileData(Map objs) {
return objs;
}
// override to post-process any model properties
- public void postProcessModelProperty(CodegenModel model, CodegenProperty property){}
+ @SuppressWarnings("unused")
+ public void postProcessModelProperty(CodegenModel model, CodegenProperty property){
+ }
// override to post-process any parameters
- public void postProcessParameter(CodegenParameter parameter){}
+ @SuppressWarnings("unused")
+ public void postProcessParameter(CodegenParameter parameter){
+ }
//override with any special handling of the entire swagger spec
+ @SuppressWarnings("unused")
public void preprocessSwagger(Swagger swagger) {
}
// override with any special handling of the entire swagger spec
+ @SuppressWarnings("unused")
public void processSwagger(Swagger swagger) {
}
// override with any special text escaping logic
+ @SuppressWarnings("static-method")
public String escapeText(String input) {
- if (input != null) {
- input = input.trim();
+ if (input != null) {
+ input = input.trim(); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
String output = input.replaceAll("\n", "\\\\n");
output = output.replace("\r", "\\r");
output = output.replace("\"", "\\\"");
@@ -274,7 +284,7 @@ public class DefaultCodegen {
}
/**
- * Return the file name of the Api
+ * Return the file name of the Api Test
*
* @param name the file name of the Api
* @return the file name of the Api
@@ -304,7 +314,7 @@ public class DefaultCodegen {
}
/**
- * Return the capitalized file name of the model
+ * Return the capitalized file name of the model test
*
* @param name the model name
* @return the file name of the model
@@ -322,13 +332,14 @@ public class DefaultCodegen {
public String toModelTestFilename(String name) {
return initialCaps(name) + "Test";
}
-
+
/**
* Return the operation ID (method name)
*
* @param operationId operation ID
* @return the sanitized method name
*/
+ @SuppressWarnings("static-method")
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
@@ -361,7 +372,7 @@ public class DefaultCodegen {
* @return the sanitized parameter name
*/
public String toParamName(String name) {
- name = removeNonNameElementToCamelCase(name);
+ name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if (reservedWords.contains(name)) {
return escapeReservedWord(name);
}
@@ -374,6 +385,7 @@ public class DefaultCodegen {
* @param property Codegen property object
* @return the Enum name
*/
+ @SuppressWarnings("static-method")
public String toEnumName(CodegenProperty property) {
return StringUtils.capitalize(property.name) + "Enum";
}
@@ -386,6 +398,7 @@ public class DefaultCodegen {
*
* throws Runtime exception as reserved word is not allowed (default behavior)
*/
+ @SuppressWarnings("static-method")
public String escapeReservedWord(String name) {
throw new RuntimeException("reserved word " + name + " not allowed");
}
@@ -495,6 +508,7 @@ public class DefaultCodegen {
* @param operation Swagger operation object
* @return string presentation of the example path
*/
+ @SuppressWarnings("static-method")
public String generateExamplePath(String path, Operation operation) {
StringBuilder sb = new StringBuilder();
sb.append(path);
@@ -577,6 +591,7 @@ public class DefaultCodegen {
* @param p Swagger property object
* @return string presentation of the default value of the property
*/
+ @SuppressWarnings("static-method")
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
return "null";
@@ -623,42 +638,9 @@ public class DefaultCodegen {
* @param p Swagger property object
* @return string presentation of the default value of the property
*/
+ @SuppressWarnings("static-method")
public String toDefaultValueWithParam(String name, Property p) {
- if (p instanceof StringProperty) {
- return " = data." + name + ";";
- } else if (p instanceof BooleanProperty) {
- return " = data." + name + ";";
- } else if (p instanceof DateProperty) {
- return " = data." + name + ";";
- } else if (p instanceof DateTimeProperty) {
- return " = data." + name + ";";
- } else if (p instanceof DoubleProperty) {
- DoubleProperty dp = (DoubleProperty) p;
- if (dp.getDefault() != null) {
- return dp.getDefault().toString();
- }
- return " = data." + name + ";";
- } else if (p instanceof FloatProperty) {
- FloatProperty dp = (FloatProperty) p;
- if (dp.getDefault() != null) {
- return dp.getDefault().toString();
- }
- return " = data." + name + ";";
- } else if (p instanceof IntegerProperty) {
- IntegerProperty dp = (IntegerProperty) p;
- if (dp.getDefault() != null) {
- return dp.getDefault().toString();
- }
- return " = data." + name + ";";
- } else if (p instanceof LongProperty) {
- LongProperty dp = (LongProperty) p;
- if (dp.getDefault() != null) {
- return dp.getDefault().toString();
- }
- return " = data." + name + ";";
- } else {
- return " = data." + name + ";";
- }
+ return " = data." + name + ";";
}
/**
@@ -666,6 +648,7 @@ public class DefaultCodegen {
* @param p Swagger property object
* @return string presentation of the type
**/
+ @SuppressWarnings("static-method")
public String getSwaggerType(Property p) {
String datatype = null;
if (p instanceof StringProperty && "number".equals(p.getFormat())) {
@@ -694,6 +677,8 @@ public class DefaultCodegen {
datatype = "map";
} else if (p instanceof DecimalProperty) {
datatype = "number";
+ } else if ( p instanceof UUIDProperty) {
+ datatype = "UUID";
} else if (p instanceof RefProperty) {
try {
RefProperty r = (RefProperty) p;
@@ -720,6 +705,7 @@ public class DefaultCodegen {
* @param name string to be snake-cased
* @return snake-cased string
*/
+ @SuppressWarnings("static-method")
public String snakeCase(String name) {
return (name.length() > 0) ? (Character.toLowerCase(name.charAt(0)) + name.substring(1)) : "";
}
@@ -730,6 +716,7 @@ public class DefaultCodegen {
* @param name string to be capitalized
* @return capitalized string
*/
+ @SuppressWarnings("static-method")
public String initialCaps(String name) {
return StringUtils.capitalize(name);
}
@@ -740,6 +727,7 @@ public class DefaultCodegen {
* @param name name
* @return a string presentation of the type
*/
+ @SuppressWarnings("static-method")
public String getTypeDeclaration(String name) {
return name;
}
@@ -1145,7 +1133,7 @@ public class DefaultCodegen {
}
}
- private Response findMethodResponse(Map responses) {
+ private static Response findMethodResponse(Map responses) {
String code = null;
for (String responseCode : responses.keySet()) {
@@ -1618,7 +1606,6 @@ public class DefaultCodegen {
// to use the built-in model parsing, we unwrap the ArrayModel
// and get a single property from it
ArrayModel impl = (ArrayModel) model;
- CodegenModel cm = fromModel(bp.getName(), impl);
// get the single property
ArrayProperty ap = new ArrayProperty().items(impl.getItems());
ap.setRequired(param.getRequired());
@@ -1659,6 +1646,7 @@ public class DefaultCodegen {
* @param schemes a map of Swagger SecuritySchemeDefinition object
* @return a list of Codegen Security objects
*/
+ @SuppressWarnings("static-method")
public List fromSecurity(Map schemes) {
if (schemes == null) {
return Collections.emptyList();
@@ -1765,6 +1753,7 @@ public class DefaultCodegen {
&& !languageSpecificPrimitives.contains(type);
}
+ @SuppressWarnings("static-method")
protected List
-
- com.sun.jersey
- jersey-core
- ${jersey-version}
-
-
- com.sun.jersey
- jersey-json
- ${jersey-version}
-
-
- com.sun.jersey
- jersey-servlet
- ${jersey-version}
-
-
- com.sun.jersey.contribs
- jersey-multipart
- ${jersey-version}
-
-
- com.sun.jersey
- jersey-server
- ${jersey-version}
-
@@ -142,22 +117,14 @@
${servlet-api-version}
-
-
- jcenter-snapshots
- jcenter
- http://oss.jfrog.org/artifactory/oss-snapshot-local/
-
-
- 1.5.4
+ 1.5.6
9.2.9.v20150224
1.13
1.6.3
- 1.6.1
4.8.1
2.5
- 2.0.4-SNAPSHOT
- 4.0.9.RELEASE
+ 2.3.1
+ 4.1.8.RELEASE
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig
index 5d8a4f0fc6bf..87d612299368 100644
--- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig
+++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig
@@ -4,6 +4,7 @@ io.swagger.codegen.languages.CSharpClientCodegen
io.swagger.codegen.languages.DartClientCodegen
io.swagger.codegen.languages.FlashClientCodegen
io.swagger.codegen.languages.FlaskConnexionCodegen
+io.swagger.codegen.languages.GoClientCodegen
io.swagger.codegen.languages.JavaClientCodegen
io.swagger.codegen.languages.JavascriptClientCodegen
io.swagger.codegen.languages.JaxRSServerCodegen
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache
index 1d70000c1dc1..d98ef59be18b 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache
@@ -17,9 +17,12 @@ import com.android.volley.VolleyError;
import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
-import java.util.Map;
+import java.util.ArrayList;
import java.util.HashMap;
-import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
{{#operations}}
public class {{classname}} {
@@ -44,11 +47,93 @@ public class {{classname}} {
{{#operation}}
/**
- * {{summary}}
- * {{notes}}
+ * {{summary}}
+ * {{notes}}
{{#allParams}} * @param {{paramName}} {{description}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
- */
+ */
+ public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws TimeoutException, ExecutionException, InterruptedException, ApiException {
+ Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
+ {{#allParams}}{{#required}}
+ // verify the required parameter '{{paramName}}' is set
+ if ({{paramName}} == null) {
+ VolleyError error = new VolleyError("Missing the required parameter '{{paramName}}' when calling {{nickname}}",
+ new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}"));
+ }
+ {{/required}}{{/allParams}}
+
+ // create path and map variables
+ String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
+
+ // query params
+ List queryParams = new ArrayList();
+ // header params
+ Map headerParams = new HashMap();
+ // form params
+ Map formParams = new HashMap();
+
+ {{#queryParams}}
+ queryParams.addAll(ApiInvoker.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
+ {{/queryParams}}
+
+ {{#headerParams}}
+ headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
+ {{/headerParams}}
+
+ String[] contentTypes = {
+ {{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
+ };
+ String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
+
+ if (contentType.startsWith("multipart/form-data")) {
+ // file uploading
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ {{#formParams}}{{#notFile}}
+ if ({{paramName}} != null) {
+ builder.addTextBody("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), ApiInvoker.TEXT_PLAIN_UTF8);
+ }
+ {{/notFile}}{{#isFile}}
+ if ({{paramName}} != null) {
+ builder.addBinaryBody("{{baseName}}", {{paramName}});
+ }
+ {{/isFile}}{{/formParams}}
+
+ HttpEntity httpEntity = builder.build();
+ postBody = httpEntity;
+ } else {
+ // normal form params
+ {{#formParams}}{{#notFile}}formParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));{{/notFile}}
+ {{/formParams}}
+ }
+
+ String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
+
+ try {
+ String response = apiInvoker.invokeAPI (basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, contentType, authNames);
+ if(response != null){
+ return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}};
+ } else {
+ return {{#returnType}}null{{/returnType}};
+ }
+ } catch (ApiException ex) {
+ throw ex;
+ } catch (InterruptedException ex) {
+ throw ex;
+ } catch (ExecutionException ex) {
+ if(ex.getCause() instanceof VolleyError) {
+ throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ }
+ throw ex;
+ } catch (TimeoutException ex) {
+ throw ex;
+ }
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}}
+ */
public void {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}, {{/hasMore}}{{/allParams}}final Response.Listener<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}String{{/returnType}}> responseListener, final Response.ErrorListener errorListener) {
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache
index 04e6fdbc05c0..2a04c1c86b19 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache
@@ -1,10 +1,16 @@
package {{invokerPackage}};
-import android.content.Context;
-
+import com.android.volley.Cache;
+import com.android.volley.Network;
+import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
-import com.android.volley.toolbox.Volley;
+import com.android.volley.ResponseDelivery;
+import com.android.volley.toolbox.BasicNetwork;
+import com.android.volley.toolbox.HttpStack;
+import com.android.volley.toolbox.HurlStack;
+import com.android.volley.toolbox.NoCache;
+import com.android.volley.toolbox.RequestFuture;
import com.google.gson.JsonParseException;
import org.apache.http.Consts;
@@ -22,6 +28,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import {{invokerPackage}}.auth.Authentication;
import {{invokerPackage}}.auth.ApiKeyAuth;
@@ -36,11 +45,12 @@ public class ApiInvoker {
private static ApiInvoker INSTANCE;
private Map defaultHeaderMap = new HashMap();
- private Context context;
private RequestQueue mRequestQueue;
private Map authentications;
+ private int connectionTimeout;
+
/** Content type "text/plain" with UTF-8 encoding. */
public static final ContentType TEXT_PLAIN_UTF8 = ContentType.create("text/plain", Consts.UTF_8);
@@ -165,8 +175,16 @@ public class ApiInvoker {
return params;
}
- public static void initializeInstance(Context context) {
- INSTANCE = new ApiInvoker(context);
+ public static void initializeInstance() {
+ initializeInstance(null);
+ }
+
+ public static void initializeInstance(Cache cache) {
+ initializeInstance(cache, null, 0, null, 30);
+ }
+
+ public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) {
+ INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout);
setUserAgent("Android-Volley-Swagger");
// Setup authentications (key: authentication name, value: authentication).
@@ -178,17 +196,27 @@ public class ApiInvoker {
{{#isBasic}}
INSTANCE.authentications.put("{{name}}", new HttpBasicAuth());
{{/isBasic}}
+ {{#isOAuth}}
+ INSTANCE.authentications.put("{{name}}", new OAuth());
+ {{/isOAuth}}
{{/authMethods}}
// Prevent the authentications from being modified.
INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications);
}
- private ApiInvoker(Context context) {
- this.context = context;
- initConnectionManager();
- }
- public ApiInvoker() {
- initConnectionManager();
+ private ApiInvoker(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) {
+ if(cache == null) cache = new NoCache();
+ if(network == null) {
+ HttpStack stack = new HurlStack();
+ network = new BasicNetwork(stack);
+ }
+
+ if(delivery == null) {
+ initConnectionRequest(cache, network);
+ } else {
+ initConnectionRequest(cache, network, threadPoolSize, delivery);
+ }
+ this.connectionTimeout = connectionTimeout;
}
public static ApiInvoker getInstance() {
@@ -304,6 +332,14 @@ public class ApiInvoker {
throw new RuntimeException("No API key authentication configured!");
}
+ public void setConnectionTimeout(int connectionTimeout){
+ this.connectionTimeout = connectionTimeout;
+ }
+
+ public int getConnectionTimeout() {
+ return connectionTimeout;
+ }
+
/**
* Update query and header parameters based on authentication settings.
*
@@ -317,7 +353,21 @@ public class ApiInvoker {
}
}
+ public String invokeAPI(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames) throws ApiException, InterruptedException, ExecutionException, TimeoutException {
+ RequestFuture future = RequestFuture.newFuture();
+ Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, future, future);
+ if(request != null) {
+ mRequestQueue.add(request);
+ return future.get(connectionTimeout, TimeUnit.SECONDS);
+ } else return "no data";
+ }
+
public void invokeAPI(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames, Response.Listener stringRequest, Response.ErrorListener errorListener) throws ApiException {
+ Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, stringRequest, errorListener);
+ if (request != null) mRequestQueue.add(request);
+ }
+
+ public Request createRequest(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames, Response.Listener stringRequest, Response.ErrorListener errorListener) throws ApiException {
StringBuilder b = new StringBuilder();
b.append("?");
@@ -374,13 +424,13 @@ public class ApiInvoker {
}
formParamStr = formParamBuilder.toString();
}
+ Request request = null;
if ("GET".equals(method)) {
- GetRequest request = new GetRequest(url, headers, null, stringRequest, errorListener);
- mRequestQueue.add(request);
+ request = new GetRequest(url, headers, null, stringRequest, errorListener);
}
else if ("POST".equals(method)) {
- PostRequest request = null;
+ request = null;
if (formParamStr != null) {
request = new PostRequest(url, headers, contentType, new StringEntity(formParamStr, "UTF-8"), stringRequest, errorListener);
} else if (body != null) {
@@ -389,11 +439,12 @@ public class ApiInvoker {
} else {
request = new PostRequest(url, headers, contentType, new StringEntity(serialize(body), "UTF-8"), stringRequest, errorListener);
}
+ } else {
+ request = new PostRequest(url, headers, null, null, stringRequest, errorListener);
}
- if(request != null) mRequestQueue.add(request);
}
else if ("PUT".equals(method)) {
- PutRequest request = null;
+ request = null;
if (formParamStr != null) {
request = new PutRequest(url, headers, contentType, new StringEntity(formParamStr, "UTF-8"), stringRequest, errorListener);
} else if (body != null) {
@@ -402,11 +453,12 @@ public class ApiInvoker {
} else {
request = new PutRequest(url, headers, contentType, new StringEntity(serialize(body), "UTF-8"), stringRequest, errorListener);
}
+ } else {
+ request = new PutRequest(url, headers, null, null, stringRequest, errorListener);
}
- if(request != null) mRequestQueue.add(request);
}
else if ("DELETE".equals(method)) {
- DeleteRequest request = null;
+ request = null;
if (formParamStr != null) {
request = new DeleteRequest(url, headers, contentType, new StringEntity(formParamStr, "UTF-8"), stringRequest, errorListener);
} else if (body != null) {
@@ -415,11 +467,12 @@ public class ApiInvoker {
} else {
request = new DeleteRequest(url, headers, contentType, new StringEntity(serialize(body), "UTF-8"), stringRequest, errorListener);
}
+ } else {
+ request = new DeleteRequest(url, headers, null, null, stringRequest, errorListener);
}
- if(request != null) mRequestQueue.add(request);
}
else if ("PATCH".equals(method)) {
- PatchRequest request = null;
+ request = null;
if (formParamStr != null) {
request = new PatchRequest(url, headers, contentType, new StringEntity(formParamStr, "UTF-8"), stringRequest, errorListener);
} else if (body != null) {
@@ -428,12 +481,24 @@ public class ApiInvoker {
} else {
request = new PatchRequest(url, headers, contentType, new StringEntity(serialize(body), "UTF-8"), stringRequest, errorListener);
}
- }
- if(request != null) mRequestQueue.add(request);
+ } else {
+ request = new PatchRequest(url, headers, null, null, stringRequest, errorListener);
+ }
}
+ return request;
}
- private void initConnectionManager() {
- mRequestQueue = Volley.newRequestQueue(context);
+ private void initConnectionRequest(Cache cache, Network network) {
+ mRequestQueue = new RequestQueue(cache, network);
+ mRequestQueue.start();
+ }
+
+ private void initConnectionRequest(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery) {
+ mRequestQueue = new RequestQueue(cache, network, threadPoolSize, delivery);
+ mRequestQueue.start();
+ }
+
+ public void stopQueue() {
+ mRequestQueue.stop();
}
}
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache
index a1824b551ca9..44c5ed96eca6 100644
--- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache
@@ -44,6 +44,9 @@ public class ApiKeyAuth implements Authentication {
@Override
public void applyToParams(List queryParams, Map headerParams) {
String value;
+ if (apiKey == null) {
+ return;
+ }
if (apiKeyPrefix != null) {
value = apiKeyPrefix + " " + apiKey;
} else {
diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache
new file mode 100644
index 000000000000..7eb4fe4aaba8
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache
@@ -0,0 +1,13 @@
+package {{invokerPackage}}.auth;
+
+import {{invokerPackage}}.Pair;
+
+import java.util.Map;
+import java.util.List;
+
+public class OAuth implements Authentication {
+ @Override
+ public void applyToParams(List queryParams, Map headerParams) {
+ // TODO stub
+ }
+}
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 87d7f4a882cf..f3cf1c21da6b 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
@@ -49,6 +49,10 @@ android {
}
}
}
+
+ testOptions {
+ unitTests.returnDefaultValues = true
+ }
}
@@ -58,6 +62,8 @@ ext {
httpclient_version = "4.3.3"
volley_version = "1.0.19"
junit_version = "4.8.1"
+ robolectric_version = "3.0"
+ concurrent_unit_version = "0.4.2"
}
dependencies {
@@ -67,6 +73,8 @@ dependencies {
compile "org.apache.httpcomponents:httpmime:$httpclient_version"
compile "com.mcxiaoke.volley:library:${volley_version}@aar"
testCompile "junit:junit:$junit_version"
+ testCompile "org.robolectric:robolectric:${robolectric_version}"
+ testCompile "net.jodah:concurrentunit:${concurrentunitVersion}"
}
afterEvaluate {
diff --git a/modules/swagger-codegen/src/main/resources/csharp/Project.mustache b/modules/swagger-codegen/src/main/resources/csharp/Project.mustache
new file mode 100644
index 000000000000..333cb5088ff6
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/csharp/Project.mustache
@@ -0,0 +1,58 @@
+
+
+
+ Debug
+ AnyCPU
+ {{packageGuid}}
+ Library
+ Properties
+ {{packageTitle}}
+ {{packageTitle}}
+ v4.5
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+ {{binRelativePath}}Newtonsoft.Json.dll
+
+
+ {{binRelativePath}}RestSharp.dll
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/README.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/README.mustache
index 7e80a2086ef5..cc7805c9b974 100644
--- a/modules/swagger-codegen/src/main/resources/flaskConnexion/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/README.mustache
@@ -3,25 +3,26 @@
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
-is an example of building a swagger-enabled flask server.
+is an example of building a swagger-enabled Flask server.
-This example uses the [connexion](https://github.com/zalando/connexion) library on top of Flask.
+This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
To run the server, please execute the following:
```
+sudo pip3 install -U connexion # install Connexion from PyPI
python3 app.py
```
and open your browser to here:
```
-http://localhost:{{serverPort}}/ui
+http://localhost:{{serverPort}}{{contextPath}}/ui/
```
-Your swagger definition lives here:
+Your Swagger definition lives here:
```
-http://localhost:{{serverPort}}{{basePathWithoutHost}}/swagger.json
+http://localhost:{{serverPort}}{{contextPath}}/swagger.json
```
diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/app.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/app.mustache
index 14af64be6f9a..ded223fb36de 100644
--- a/modules/swagger-codegen/src/main/resources/flaskConnexion/app.mustache
+++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/app.mustache
@@ -3,7 +3,6 @@
import connexion
if __name__ == '__main__':
- app = connexion.App(__name__, {{serverPort}},
- specification_dir='./swagger/')
+ app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': '{{appDescription}}'})
- app.run()
+ app.run(port={{serverPort}})
diff --git a/modules/swagger-codegen/src/main/resources/go/README.mustache b/modules/swagger-codegen/src/main/resources/go/README.mustache
new file mode 100644
index 000000000000..586b35ed3f5a
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/go/README.mustache
@@ -0,0 +1,12 @@
+# Go API client for {{packageName}}
+
+## Overview
+This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.
+
+
+## Installation
+Put the package under your project folder and add the following in import:
+```
+ "./{{packageName}}"
+```
+
diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache
new file mode 100644
index 000000000000..ae7fb8412b0c
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/go/api.mustache
@@ -0,0 +1,83 @@
+package {{packageName}}
+
+{{#operations}}
+import (
+ "strings"
+ "fmt"
+ "github.com/dghubble/sling"
+{{#imports}} "{{import}}"
+{{/imports}}
+)
+
+type {{classname}} struct {
+ basePath string
+}
+
+func New{{classname}}() *{{classname}}{
+ return &{{classname}} {
+ basePath: "{{basePath}}",
+ }
+}
+
+func New{{classname}}WithBasePath(basePath string) *{{classname}}{
+ return &{{classname}} {
+ basePath: basePath,
+ }
+}
+
+{{#operation}}
+/**
+ * {{summary}}
+ * {{notes}}
+{{#allParams}} * @param {{paramName}} {{description}}
+{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
+ */
+//func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
+func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
+
+ _sling := sling.New().{{httpMethod}}(a.basePath)
+
+ // create path and map variables
+ path := "{{basePathWithoutHost}}{{path}}"
+{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1)
+{{/pathParams}}
+
+ _sling = _sling.Path(path)
+
+{{#hasQueryParams}} type QueryParams struct {
+ {{#queryParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
+ {{/queryParams}}
+}
+ _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{paramName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} })
+{{/hasQueryParams}}
+ // accept header
+ accepts := []string { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
+ _sling = _sling.Set("{{baseName}}", {{paramName}})
+{{/headerParams}}{{/hasHeaderParams}}
+{{#hasFormParams}} type FormParams struct {
+{{#formParams}} {{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
+{{/formParams}}
+ }
+ _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{paramName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} })
+{{/hasFormParams}}
+{{#hasBodyParam}}{{#bodyParams}}// body params
+ _sling = _sling.BodyJSON({{paramName}})
+{{/bodyParams}}{{/hasBodyParam}}
+
+{{#returnType}} response := new({{returnType}})
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("{{operationId}} response: ", response, resp, err)
+ return *response, err
+{{/returnType}}{{^returnType}}
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("{{operationId}} response: void, ", resp, err)
+ return err
+{{/returnType}}
+}
+{{/operation}}
+{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/go/model.mustache b/modules/swagger-codegen/src/main/resources/go/model.mustache
new file mode 100644
index 000000000000..83ba416883d1
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/go/model.mustache
@@ -0,0 +1,15 @@
+package {{packageName}}
+
+{{#models}}
+import (
+{{#imports}} "{{import}}"
+{{/imports}}
+)
+
+{{#model}}
+type {{classname}} struct {
+ {{#vars}}{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
+ {{/vars}}
+}
+{{/model}}
+{{/models}}
diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
index 414e40650f6a..f961f5cd60ce 100644
--- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
@@ -153,7 +153,7 @@ class ObjectSerializer
*/
public function toFormValue($value)
{
- if ($value instanceof SplFileObject) {
+ if ($value instanceof \SplFileObject) {
return $value->getRealPath();
} else {
return $this->toString($value);
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java
index 002e4ba8f299..ede3feb50b48 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java
@@ -22,6 +22,7 @@ public abstract class AbstractOptionsTest {
this.optionsProvider = optionsProvider;
}
+ @SuppressWarnings("unused")
@Test
public void checkOptionsProcessing() {
getCodegenConfig().additionalProperties().putAll(optionsProvider.createOptions());
@@ -49,7 +50,7 @@ public abstract class AbstractOptionsTest {
}
}
- private Function getCliOptionTransformer() {
+ private static Function getCliOptionTransformer() {
return new Function() {
@Override
public String apply(CliOption option) {
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java
index 59552bba1486..490affe0764e 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java
@@ -7,6 +7,7 @@ import org.testng.annotations.Test;
import java.util.List;
+@SuppressWarnings("static-method")
public class ClientAuthInputTest {
@Test(description = "read a file upload param from a 2.0 spec")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java
index b91e506a4f96..cf4e4a201fb5 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java
@@ -11,6 +11,7 @@ import java.util.Set;
import static org.testng.Assert.assertEquals;
+@SuppressWarnings("static-method")
public class CodegenConfigLoaderTest {
@DataProvider(name = "codegenConfig")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java
index 68c2b4b170bf..91a1240ced8e 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java
@@ -189,7 +189,7 @@ public class CodegenTest {
}
- private Swagger parseAndPrepareSwagger(String path) {
+ private static Swagger parseAndPrepareSwagger(String path) {
Swagger swagger = new SwaggerParser().read(path);
// resolve inline models
new InlineModelResolver().flatten(swagger);
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java
index ed83c89c8f04..8cd04c932f96 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java
@@ -200,13 +200,13 @@ public class DefaultGeneratorTest {
}
}
- private void changeContent(File file) throws IOException {
+ private static void changeContent(File file) throws IOException {
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), UTF_8));
out.write(TEST_SKIP_OVERWRITE);
out.close();
}
- private CodegenOperation findCodegenOperationByOperationId(Map> paths, String operationId) {
+ private static CodegenOperation findCodegenOperationByOperationId(Map> paths, String operationId) {
for (List ops : paths.values()) {
for (CodegenOperation co : ops) {
if (operationId.equals(co.operationId)) {
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java
index 339b77badbd4..d4c22b88aade 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+@SuppressWarnings("static-method")
public class ExampleGeneratorTest {
@Test(description = "check handling of recursive models")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java
index f972711138b6..9102f06908f1 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java
@@ -12,6 +12,7 @@ import java.util.Map;
import static org.testng.AssertJUnit.*;
+@SuppressWarnings("static-method")
public class InlineModelResolverTest {
@Test
public void resolveInlineModelTest() throws Exception {
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java
index 2a7e9ec532a5..cf19c2058c47 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java
@@ -5,6 +5,7 @@ import io.swagger.parser.SwaggerParser;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class SwaggerMigratorTest {
@Test(description = "read a 1.2 spec")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/akkascala/AkkaScalaClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/akkascala/AkkaScalaClientOptionsTest.java
index 1b6f878b512a..7ad1ff07e2b0 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/akkascala/AkkaScalaClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/akkascala/AkkaScalaClientOptionsTest.java
@@ -22,6 +22,7 @@ public class AkkaScalaClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java
index 26d55d7e9b2f..538614436f42 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java
@@ -22,6 +22,7 @@ public class AndroidClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/asyncscala/AsyncScalaClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/asyncscala/AsyncScalaClientOptionsTest.java
index b6b90ae7a7c3..8ea0280434a0 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/asyncscala/AsyncScalaClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/asyncscala/AsyncScalaClientOptionsTest.java
@@ -22,6 +22,7 @@ public class AsyncScalaClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java
index 2245f2f58771..6f39eb1af99b 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java
@@ -25,6 +25,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+@SuppressWarnings("static-method")
public class CodegenConfiguratorTest {
@Mocked
@@ -45,6 +46,7 @@ public class CodegenConfiguratorTest {
@Tested
CodegenConfigurator configurator;
+ @SuppressWarnings("unused")
@Test
public void testVerbose() throws Exception {
@@ -75,6 +77,7 @@ public class CodegenConfiguratorTest {
assertValueInMap(clientOptInput.getConfig().additionalProperties(), CodegenConstants.TEMPLATE_DIR, toAbsolutePathDir(templateDir));
}
+ @SuppressWarnings("unused")
@Test
public void testSystemProperties() throws Exception {
@@ -286,6 +289,7 @@ public class CodegenConfiguratorTest {
assertValueInMap(configurator.getDynamicProperties(), CodegenConstants.LOCAL_VARIABLE_PREFIX, "_");
}
+ @SuppressWarnings("unused")
private ClientOptInput setupAndRunGenericTest(CodegenConfigurator configurator) {
final String spec = "swagger.yaml";
@@ -315,10 +319,11 @@ public class CodegenConfiguratorTest {
return result;
}
- private String toAbsolutePathDir(String outputDir) {
+ private static String toAbsolutePathDir(String outputDir) {
return Paths.get(outputDir).toAbsolutePath().toAbsolutePath().toString();
}
+ @SuppressWarnings("unused")
private void setupStandardExpectations(final String spec, final String languageName, final String auth, final CodegenConfig config) {
new StrictExpectations() {{
@@ -339,7 +344,7 @@ public class CodegenConfiguratorTest {
}};
}
- private void assertValueInMap(Map map, String propertyKey, String expectedPropertyValue) {
+ private static void assertValueInMap(Map, ?> map, String propertyKey, String expectedPropertyValue) {
assertTrue(map.containsKey(propertyKey));
assertEquals(map.get(propertyKey), expectedPropertyValue);
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java
index 367977e2b052..ab8f28065129 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java
@@ -22,6 +22,7 @@ public class CSharpClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
@@ -37,6 +38,10 @@ public class CSharpClientOptionsTest extends AbstractOptionsTest {
times = 1;
clientCodegen.useDateTimeOffset(true);
times = 1;
+ clientCodegen.setOptionalProjectFileFlag(true);
+ times = 1;
+ clientCodegen.setPackageGuid(CSharpClientOptionsProvider.PACKAGE_GUID_VALUE);
+ times = 1;
}};
}
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java
index 7e30e2b1cd0d..cb3854e2bd8f 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java
@@ -22,6 +22,7 @@ public class CsharpDotNet2ClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java
index b002fd999782..519ac4943ccb 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java
@@ -22,6 +22,7 @@ public class DartClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java
index 21a9cb5e03b2..d3debf295792 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java
@@ -8,8 +8,6 @@ import io.swagger.codegen.options.FlashClienOptionsProvider;
import mockit.Expectations;
import mockit.Tested;
-import java.util.Map;
-
public class FlashClienOptionsTest extends AbstractOptionsTest {
@Tested
@@ -24,6 +22,7 @@ public class FlashClienOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java
index 8c54a382993b..49399b3beef8 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java
@@ -21,6 +21,7 @@ public class JavaInflectorServerOptionsTest extends JavaClientOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java
index 29166bc87500..2a4d582f7764 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java
@@ -27,6 +27,7 @@ public class JavaClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaInheritanceTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaInheritanceTest.java
index 66b48cd6b89f..dcd87b4d7008 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaInheritanceTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaInheritanceTest.java
@@ -15,6 +15,7 @@ import org.testng.annotations.Test;
public class JavaInheritanceTest {
+ @SuppressWarnings("static-method")
@Test(description = "convert a composed model")
public void javaInheritanceTest() {
final Model model = new ComposedModel().parent(new RefModel("Base"))
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelEnumTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelEnumTest.java
index 2babdc189e1a..5ac5f7885909 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelEnumTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelEnumTest.java
@@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+@SuppressWarnings("static-method")
public class JavaModelEnumTest {
@Test(description = "convert a java model with an enum")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelTest.java
index dc815e351aa9..f8c8bae61289 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaModelTest.java
@@ -24,6 +24,7 @@ import org.testng.annotations.Test;
import java.util.List;
+@SuppressWarnings("static-method")
public class JavaModelTest {
@Test(description = "convert a simple java model")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java
index 9ae5e6dc3e4b..4a4e6ff91802 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java
@@ -31,7 +31,7 @@ public class AllowableValuesTest {
}
@DataProvider(name = PROVIDER_NAME)
- private Object[][] resource() {
+ private static Object[][] resource() {
final CodegenParameter param1 = new CodegenParameter();
final CodegenParameter param2 = new CodegenParameter() {{
allowableValues = ImmutableMap.of("values", ImmutableList.of("item1", "item2", "item3"));
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java
index 055bb721ad81..a441a7984d28 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java
@@ -22,6 +22,7 @@ public class JaxRSServerOptionsTest extends JavaClientOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java
index 55219787f89d..b1ee5b0040a7 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java
@@ -1,6 +1,7 @@
package io.swagger.codegen.jaxrs;
import io.swagger.codegen.CodegenModel;
+
import io.swagger.codegen.languages.JaxRSServerCodegen;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
@@ -12,7 +13,9 @@ import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
+@SuppressWarnings("static-method")
public class JaxrsJava8ModelTest {
+
@Test(description = "convert a simple java model with java8 types")
public void simpleModelTest() {
final Model model = new ModelImpl()
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java
index 3f2ac1a9ec1b..c2cb65c78ca1 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJodaModelTest.java
@@ -12,7 +12,9 @@ import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
+@SuppressWarnings("static-method")
public class JaxrsJodaModelTest {
+
@Test(description = "convert a simple java model with Joda types")
public void simpleModelTest() {
final Model model = new ModelImpl()
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/BooleanOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/BooleanOptionsTest.java
index da2d5e35e2ae..3566f2e98e29 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/BooleanOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/BooleanOptionsTest.java
@@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+@SuppressWarnings("static-method")
public class BooleanOptionsTest {
private static final String OPTIONS_PROVIDER = "Codegen";
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java
index ce905315ae3b..c1cfa43b08bf 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java
@@ -22,6 +22,7 @@ public class NodeJSServerOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientOptionsTest.java
index 33f20625e16e..795c6ee2d9cf 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientOptionsTest.java
@@ -22,6 +22,7 @@ public class ObjcClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java
index f48f20ce1191..7d3eeaa41087 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java
@@ -24,6 +24,7 @@ import org.testng.annotations.Test;
import java.util.Map;
+@SuppressWarnings("static-method")
public class ObjcModelTest {
@Test(description = "convert a simple java model")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java
index 0c2da1f3fa2a..eb187848aa61 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java
@@ -10,6 +10,7 @@ public class CSharpClientOptionsProvider implements OptionsProvider {
public static final String PACKAGE_NAME_VALUE = "swagger_client_csharp";
public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String SOURCE_FOLDER_VALUE = "src_csharp";
+ public static final String PACKAGE_GUID_VALUE = "{894EAEBB-649A-498C-A735-10D0BD7B73E0}";
@Override
public String getLanguage() {
@@ -26,6 +27,8 @@ public class CSharpClientOptionsProvider implements OptionsProvider {
.put(CodegenConstants.OPTIONAL_ASSEMBLY_INFO, "true")
.put(CodegenConstants.USE_DATETIME_OFFSET, "true")
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
+ .put(CodegenConstants.OPTIONAL_PROJECT_FILE, "true")
+ .put(CodegenConstants.OPTIONAL_PROJECT_GUID, PACKAGE_GUID_VALUE)
.build();
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java
index e52373c3c081..a9d77c403938 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringMVCServerOptionsProvider.java
@@ -8,7 +8,7 @@ import java.util.Map;
public class SpringMVCServerOptionsProvider extends JavaOptionsProvider {
public static final String CONFIG_PACKAGE_VALUE = "configPackage";
- public static final String LIBRARY_VALUE = "j8-async";
+ public static final String LIBRARY_VALUE = "j8-async"; //FIXME hidding value from super class
@Override
public String getLanguage() {
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientOptionsTest.java
index d85b0c9dbc18..b277acbbe5c8 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientOptionsTest.java
@@ -22,6 +22,7 @@ public class PerlClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
index e50185a3e8db..fb5e21d1cce1 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
@@ -22,6 +22,7 @@ public class PhpClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpModelTest.java
index 79da2d2ccda4..3cad349a882e 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpModelTest.java
@@ -18,6 +18,7 @@ import com.google.common.collect.Sets;
import org.testng.Assert;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class PhpModelTest {
@Test(description = "convert a simple php model")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java
index fc68a9e92e19..2682200e60ae 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java
@@ -22,6 +22,7 @@ public class PythonClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonTest.java
index 07c4bc76b030..d57b445b9c2b 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonTest.java
@@ -11,6 +11,7 @@ import io.swagger.parser.SwaggerParser;
import org.testng.Assert;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class PythonTest {
@Test(description = "convert a python model with dots")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/qtfivecpp/Qt5CPPOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/qtfivecpp/Qt5CPPOptionsTest.java
index 389721d3841e..1bc1147cd00c 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/qtfivecpp/Qt5CPPOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/qtfivecpp/Qt5CPPOptionsTest.java
@@ -22,6 +22,7 @@ public class Qt5CPPOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java
index 404941619730..f61367e8220e 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java
@@ -22,6 +22,7 @@ public class RubyClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaClientOptionsTest.java
index 0e916aebd76b..fe0b3b3b5443 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaClientOptionsTest.java
@@ -22,6 +22,7 @@ public class ScalaClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaModelTest.java
index 81290c473872..e3c12d028fba 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/scala/ScalaModelTest.java
@@ -18,6 +18,7 @@ import com.google.common.collect.Sets;
import org.testng.Assert;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class ScalaModelTest {
@Test(description = "convert a simple scala model")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/scalatra/ScalatraServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/scalatra/ScalatraServerOptionsTest.java
index 49bbe4373b6e..70c3dd30987f 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/scalatra/ScalatraServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/scalatra/ScalatraServerOptionsTest.java
@@ -22,6 +22,7 @@ public class ScalatraServerOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/silex/SilexServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/silex/SilexServerOptionsTest.java
index 11681230289a..c32ef13fd82e 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/silex/SilexServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/silex/SilexServerOptionsTest.java
@@ -22,6 +22,7 @@ public class SilexServerOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/sinatra/SinatraServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/sinatra/SinatraServerOptionsTest.java
index 6691cf27f860..56e81aba251a 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/sinatra/SinatraServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/sinatra/SinatraServerOptionsTest.java
@@ -22,6 +22,7 @@ public class SinatraServerOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/slim/SlimFrameworkServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/slim/SlimFrameworkServerOptionsTest.java
index 51c668bd931a..554f4ca0db54 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/slim/SlimFrameworkServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/slim/SlimFrameworkServerOptionsTest.java
@@ -22,6 +22,7 @@ public class SlimFrameworkServerOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java
index d4b984ffcd27..c24162c1a3c9 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springmvc/SpringMVCServerOptionsTest.java
@@ -22,6 +22,7 @@ public class SpringMVCServerOptionsTest extends JavaClientOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticDocOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticDocOptionsTest.java
index bc2da143efbc..9f9f6da27a1c 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticDocOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticDocOptionsTest.java
@@ -22,6 +22,7 @@ public class StaticDocOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticOperationTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticOperationTest.java
index f3e08e805417..6b16b3b7f5b8 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticOperationTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/staticDocs/StaticOperationTest.java
@@ -10,6 +10,7 @@ import io.swagger.models.properties.StringProperty;
import org.testng.Assert;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class StaticOperationTest {
@Test(description = "convert a string parameter")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/statichtml/StaticHtmlOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/statichtml/StaticHtmlOptionsTest.java
index befe62e32c42..91ba418fb916 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/statichtml/StaticHtmlOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/statichtml/StaticHtmlOptionsTest.java
@@ -22,6 +22,7 @@ public class StaticHtmlOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swagger/SwaggerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swagger/SwaggerOptionsTest.java
index f2f461f2b703..ba142d314e97 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swagger/SwaggerOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swagger/SwaggerOptionsTest.java
@@ -22,6 +22,7 @@ public class SwaggerOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swaggeryaml/SwaggerYamlOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swaggeryaml/SwaggerYamlOptionsTest.java
index a1478a8ba058..0ed24654f0ac 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swaggeryaml/SwaggerYamlOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swaggeryaml/SwaggerYamlOptionsTest.java
@@ -22,6 +22,7 @@ public class SwaggerYamlOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftOptionsTest.java
index 7d3504f67de4..7b8ccb616320 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftOptionsTest.java
@@ -22,6 +22,7 @@ public class SwiftOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/tizen/TizenClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/tizen/TizenClientOptionsTest.java
index 83ebb8be15ef..35262568fa59 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/tizen/TizenClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/tizen/TizenClientOptionsTest.java
@@ -22,6 +22,7 @@ public class TizenClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java
index 3fdf817dc58e..df57cec4b705 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularClientOptionsTest.java
@@ -22,6 +22,7 @@ public class TypeScriptAngularClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java
index 55bbbeffdba4..78b14f50e876 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular/TypeScriptAngularModelTest.java
@@ -17,6 +17,7 @@ import com.google.common.collect.Sets;
import org.testng.Assert;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class TypeScriptAngularModelTest {
@Test(description = "convert a simple TypeScript Angular model")
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java
index 2374011b1b9d..51fa87c35d21 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeClientOptionsTest.java
@@ -22,6 +22,7 @@ public class TypeScriptNodeClientOptionsTest extends AbstractOptionsTest {
return clientCodegen;
}
+ @SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(clientCodegen) {{
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java
index a932ac2b5aea..95398b155cf2 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java
@@ -17,6 +17,7 @@ import com.google.common.collect.Sets;
import org.testng.Assert;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class TypeScriptNodeModelTest {
@Test(description = "convert a simple TypeScript Node model")
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java b/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java
index 995fc8c80e7d..c0af8dc56c92 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java
@@ -19,7 +19,6 @@ package io.swagger.generator;
import org.apache.commons.io.IOUtils;
import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
@@ -30,8 +29,6 @@ public class Bootstrap extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
- ServletContext context = config.getServletContext();
-
DynamicSwaggerConfig bc = new DynamicSwaggerConfig();
bc.setBasePath("/api");
bc.setTitle("Swagger Generator");
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java
index 4ffc2348c27a..11932b262953 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java
@@ -24,4 +24,9 @@ public class ApiException extends Exception {
super(msg);
this.code = code;
}
+
+ public int getCode()
+ {
+ return code;
+ }
}
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java
index 14093f536d2e..2adf97b8bf46 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java
@@ -16,12 +16,12 @@
package io.swagger.generator.exception;
+import org.apache.http.HttpStatus;
+
public class BadRequestException extends ApiException {
private static final long serialVersionUID = -5540416398447252055L;
- private int code;
- public BadRequestException(int code, String msg) {
- super(code, msg);
- this.code = code;
+ public BadRequestException(String msg) {
+ super(HttpStatus.SC_BAD_REQUEST, msg);
}
}
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java
index cdae50ce9b65..d3747be7d9a8 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java
@@ -16,12 +16,12 @@
package io.swagger.generator.exception;
+import org.apache.http.HttpStatus;
+
public class NotFoundException extends ApiException {
private static final long serialVersionUID = -1223255119112336573L;
- private int code;
- public NotFoundException(int code, String msg) {
- super(code, msg);
- this.code = code;
+ public NotFoundException(String msg) {
+ super(HttpStatus.SC_NOT_FOUND, msg);
}
}
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
index 9946831640d4..c04ea9200890 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
@@ -34,7 +34,7 @@ public class Generator {
try {
config = CodegenConfigLoader.forName(language);
} catch (Exception e) {
- throw new BadRequestException(400, String.format("Unsupported target %s supplied. %s", language, e));
+ throw new BadRequestException(String.format("Unsupported target %s supplied. %s", language, e));
}
Map map = new LinkedHashMap();
for (CliOption option : config.cliOptions()) {
@@ -69,7 +69,7 @@ public class Generator {
private static String generate(String language, GeneratorInput opts, Type type) throws ApiException {
LOGGER.debug(String.format("generate %s for %s", type.getTypeName(), language));
if (opts == null) {
- throw new BadRequestException(400, "No options were supplied");
+ throw new BadRequestException("No options were supplied");
}
JsonNode node = opts.getSpec();
if(node != null && "{}".equals(node.toString())) {
@@ -81,13 +81,13 @@ public class Generator {
if (opts.getSwaggerUrl() != null) {
swagger = new SwaggerParser().read(opts.getSwaggerUrl());
} else {
- throw new BadRequestException(400, "No swagger specification was supplied");
+ throw new BadRequestException("No swagger specification was supplied");
}
} else {
swagger = new SwaggerParser().read(node, true);
}
if (swagger == null) {
- throw new BadRequestException(400, "The swagger specification supplied was not valid");
+ throw new BadRequestException("The swagger specification supplied was not valid");
}
ClientOptInput clientOptInput = new ClientOptInput();
@@ -104,7 +104,7 @@ public class Generator {
try {
codegenConfig = CodegenConfigLoader.forName(language);
} catch(RuntimeException e) {
- throw new BadRequestException(400, "Unsupported target " + language + " supplied");
+ throw new BadRequestException("Unsupported target " + language + " supplied");
}
if (opts.getOptions() != null) {
@@ -127,7 +127,7 @@ public class Generator {
ZipUtil zip = new ZipUtil();
zip.compressFiles(filesToAdd, outputFilename);
} else {
- throw new BadRequestException(400, "A target generation was attempted, but no files were created!");
+ throw new BadRequestException("A target generation was attempted, but no files were created!");
}
for(File file: files) {
try {
@@ -144,16 +144,16 @@ public class Generator {
LOGGER.error("unable to delete output folder " + outputFolder);
}
} catch (Exception e) {
- throw new BadRequestException(500, "Unable to build target: " + e.getMessage());
+ throw new BadRequestException("Unable to build target: " + e.getMessage());
}
return outputFilename;
}
- public static InputOption clientOptions(String language) {
+ public static InputOption clientOptions(@SuppressWarnings("unused") String language) {
return null;
}
- public static InputOption serverOptions(String language) {
+ public static InputOption serverOptions(@SuppressWarnings("unused") String language) {
return null;
}
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java b/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
index 343692f8385e..53d5d8a72a6d 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
@@ -24,6 +24,7 @@ import java.util.*;
@Path("/gen")
@Api(value = "/gen", description = "Resource for generating swagger components")
+@SuppressWarnings("static-method")
public class SwaggerResource {
static List clients = new ArrayList();
static List servers = new ArrayList();
@@ -110,7 +111,7 @@ public class SwaggerResource {
responseContainer = "map",
tags = "clients")
public Response getClientOptions(
- @Context HttpServletRequest request,
+ @SuppressWarnings("unused") @Context HttpServletRequest request,
@ApiParam(value = "The target language for the client library", required = true)
@PathParam("language") String language) throws Exception {
@@ -132,7 +133,7 @@ public class SwaggerResource {
responseContainer = "map",
tags = "servers")
public Response getServerOptions(
- @Context HttpServletRequest request,
+ @SuppressWarnings("unused") @Context HttpServletRequest request,
@ApiParam(value = "The target language for the server framework", required = true)
@PathParam("framework") String framework) throws Exception {
@@ -181,7 +182,7 @@ public class SwaggerResource {
@ApiParam(value = "parameters", required = true) GeneratorInput opts)
throws Exception {
if (framework == null) {
- throw new BadRequestException(400, "Framework is required");
+ throw new BadRequestException("Framework is required");
}
String filename = Generator.generateServer(framework, opts);
System.out.println("generated name: " + filename);
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ValidationException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ValidationException.java
index 22ed4ada8785..631541f6c012 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ValidationException.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ValidationException.java
@@ -1,12 +1,9 @@
package io.swagger.generator.util;
-import java.util.List;
-
public class ValidationException extends Exception {
private static final long serialVersionUID = 6861195361018260380L;
private int code;
private String msg;
- private List errors;
public ValidationException(String msg) {
super(msg);
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java
index c63f161b7020..3295be5d8980 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java
@@ -103,20 +103,18 @@ public class ZipUtil {
* @throws FileNotFoundException
* @throws IOException
*/
- private void addFileToZip(File file, ZipOutputStream zos)
+ private static void addFileToZip(File file, ZipOutputStream zos)
throws FileNotFoundException, IOException {
zos.putNextEntry(new ZipEntry(file.getName()));
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
file));
- long bytesRead = 0;
byte[] bytesIn = new byte[BUFFER_SIZE];
int read = 0;
while ((read = bis.read(bytesIn)) != -1) {
zos.write(bytesIn, 0, read);
- bytesRead += read;
}
zos.closeEntry();
diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/GeneratorInputTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/GeneratorInputTest.java
index c5cc99461f30..6b6b22fd6756 100644
--- a/modules/swagger-generator/src/test/java/io/swagger/generator/GeneratorInputTest.java
+++ b/modules/swagger-generator/src/test/java/io/swagger/generator/GeneratorInputTest.java
@@ -4,6 +4,7 @@ import io.swagger.generator.model.GeneratorInput;
import org.testng.annotations.Test;
+@SuppressWarnings("static-method")
public class GeneratorInputTest {
@Test(description = "write an object")
diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java
index 55161327b1ce..626255519bf7 100644
--- a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java
+++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java
@@ -2,8 +2,6 @@ package io.swagger.generator.online;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfigLoader;
import io.swagger.codegen.options.AkkaScalaClientOptionsProvider;
@@ -43,7 +41,6 @@ import io.swagger.generator.model.GeneratorInput;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Function;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
@@ -67,7 +64,7 @@ public class OnlineGeneratorOptionsTest {
private static final String OPTIONS_PROVIDER = "optionsProvider";
@DataProvider(name = OPTIONS_PROVIDER)
- private Object[][] listOptions() {
+ private static Object[][] listOptions() {
return new Object[][]{{new AkkaScalaClientOptionsProvider()}, {new AndroidClientOptionsProvider()},
{new AsyncScalaClientOptionsProvider()}, {new CSharpClientOptionsProvider()},
{new CsharpDotNet2ClientOptionsProvider()}, {new DartClientOptionsProvider()},
@@ -122,7 +119,7 @@ public class OnlineGeneratorOptionsTest {
}
}
- private HashMap convertOptions(OptionsProvider provider) {
+ private static HashMap convertOptions(OptionsProvider provider) {
HashMap options = new HashMap();
for (Map.Entry entry : provider.createOptions().entrySet()) {
options.put(entry.getKey(), new InvocationCounter(entry.getValue()));
@@ -159,10 +156,10 @@ public class OnlineGeneratorOptionsTest {
}
@Test(dataProvider = OPTIONS_PROVIDER)
- public void getOptionsTest(OptionsProvider provider) throws ApiException {
+ public static void getOptionsTest(OptionsProvider provider) throws ApiException {
final Map opts = Generator.getOptions(provider.getLanguage());
- final Function cliOptionWrapper = new Function() {
+ final Function cliOptionWrapper = new Function() {
@Nullable
@Override
public CliOptionProxy apply(@Nullable CliOption option) {
@@ -170,13 +167,13 @@ public class OnlineGeneratorOptionsTest {
}
};
- final List actual = Lists.transform(new ArrayList(opts.values()), cliOptionWrapper);
+ final List actual = Lists.transform(new ArrayList(opts.values()), cliOptionWrapper);
final List expected = Lists.transform(
CodegenConfigLoader.forName(provider.getLanguage()).cliOptions(), cliOptionWrapper);
assertEquals(actual, expected);
}
- private static class CliOptionProxy {
+ protected static class CliOptionProxy {
private final CliOption wrapped;
public CliOptionProxy(CliOption wrapped){
diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java
index 93277a6a2f97..bca63e37eedf 100644
--- a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java
+++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java
@@ -13,6 +13,7 @@ import org.testng.annotations.Test;
import java.util.Map;
+@SuppressWarnings("static-method")
public class OnlineJavaClientOptionsTest {
@Test
diff --git a/samples/client/petstore/android/volley/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/android/volley/src/test/java/io/swagger/petstore/test/PetApiTest.java
new file mode 100644
index 000000000000..92812f805064
--- /dev/null
+++ b/samples/client/petstore/android/volley/src/test/java/io/swagger/petstore/test/PetApiTest.java
@@ -0,0 +1,394 @@
+package es.shyri.swagger.android.volley.petstore.full;
+
+import com.android.volley.ExecutorDelivery;
+import com.android.volley.Network;
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+import com.android.volley.toolbox.BasicNetwork;
+import com.android.volley.toolbox.HttpStack;
+import com.android.volley.toolbox.HurlStack;
+import com.android.volley.toolbox.NoCache;
+
+import net.jodah.concurrentunit.Waiter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.Executors;
+
+import io.swagger.client.ApiException;
+import io.swagger.client.ApiInvoker;
+import io.swagger.client.api.PetApi;
+import io.swagger.client.model.Category;
+import io.swagger.client.model.Pet;
+
+import static com.ibm.icu.impl.Assert.fail;
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+
+@RunWith(RobolectricTestRunner.class)
+public class PetApiTest {
+ PetApi api = null;
+
+ @Before
+ public void setup() {
+ HttpStack stack = new HurlStack();
+ Network network = new BasicNetwork(stack);
+ ApiInvoker.initializeInstance(new NoCache(), network, 4, new ExecutorDelivery(Executors.newSingleThreadExecutor()), 30);
+ api = new PetApi();
+ }
+
+ @Test
+ public void testCreateAndGetPet() throws Exception {
+ final Waiter waiter = new Waiter();
+ final Pet pet = createRandomPet();
+ api.addPet(pet, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ api.getPetById(pet.getId(), new Response.Listener() {
+ @Override
+ public void onResponse(Pet response) {
+ Pet fetched = response;
+ waiter.assertNotNull(fetched);
+ waiter.assertEquals(pet.getId(), fetched.getId());
+ waiter.assertNotNull(fetched.getCategory());
+ waiter.assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+ }
+
+ @Test
+ public void testUpdatePet() throws Exception {
+ final Waiter waiter = new Waiter();
+
+ final Pet pet = createRandomPet();
+ pet.setName("programmer");
+
+ api.updatePet(pet, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ api.getPetById(pet.getId(), new Response.Listener() {
+ @Override
+ public void onResponse(Pet fetched) {
+ waiter.assertNotNull(fetched);
+ waiter.assertEquals(pet.getId(), fetched.getId());
+ waiter.assertNotNull(fetched.getCategory());
+ waiter.assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+ }
+
+ @Test
+ public void testFindPetsByStatus() throws Exception {
+ final Waiter waiter = new Waiter();
+ final Pet pet = createRandomPet();
+ pet.setName("programmer");
+ pet.setStatus(Pet.StatusEnum.available);
+
+ api.updatePet(pet, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ api.findPetsByStatus(Arrays.asList(new String[]{"available"}), new Response.Listener>() {
+ @Override
+ public void onResponse(List pets) {
+ waiter.assertNotNull(pets);
+
+ boolean found = false;
+ for (Pet fetched : pets) {
+ if (fetched.getId().equals(pet.getId())) {
+ found = true;
+ break;
+ }
+ }
+
+ waiter.assertTrue(found);
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+ }
+
+ @Test
+ public void testUpdatePetWithForm() throws Exception {
+ final Waiter waiter = new Waiter();
+ final Pet pet = createRandomPet();
+ pet.setName("frank");
+
+ api.addPet(pet, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ final Pet[] fetched = new Pet[1];
+
+ api.getPetById(pet.getId(), new Response.Listener() {
+ @Override
+ public void onResponse(Pet petResponse) {
+ fetched[0] = petResponse;
+ waiter.assertEquals("frank", fetched[0].getName());
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ api.updatePetWithForm(String.valueOf(fetched[0].getId()), "furt", null, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ api.getPetById(fetched[0].getId(), new Response.Listener() {
+ @Override
+ public void onResponse(Pet updated) {
+ waiter.assertEquals("furt", updated.getName());
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ }
+
+ @Test
+ public void testDeletePet() throws Exception {
+ final Waiter waiter = new Waiter();
+
+ Pet pet = createRandomPet();
+ api.addPet(pet, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ final Pet[] fetched = new Pet[1];
+
+ api.getPetById(pet.getId(), new Response.Listener() {
+ @Override
+ public void onResponse(Pet response) {
+ fetched[0] = response;
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ api.deletePet(fetched[0].getId(), "special-key", new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+
+ api.getPetById(fetched[0].getId(), new Response.Listener() {
+ @Override
+ public void onResponse(Pet response) {
+ waiter.fail("expected an error");
+ waiter.resume();
+ }
+ }, new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ waiter.assertEquals(404, error.networkResponse.statusCode);
+ waiter.resume();
+ }
+ });
+ waiter.await();
+ }
+
+
+
+ @Test
+ public void testUploadFile() throws Exception {
+ final Waiter waiter = new Waiter();
+
+ Pet pet = createRandomPet();
+ api.addPet(pet, new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+
+ File file = new File("hello.txt");
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+ writer.write("Hello world!");
+ writer.close();
+
+ api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()), new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ waiter.resume();
+ }
+ }, createErrorListener(waiter));
+
+ waiter.await();
+ }
+
+ @Test
+ public void testCreateAndGetPetSync() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ }
+
+ @Test
+ public void testUpdatePetSync() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("programmer");
+
+ api.updatePet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ }
+
+ @Test
+ public void testFindPetsByStatusSync() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("programmer");
+ pet.setStatus(Pet.StatusEnum.available);
+
+ api.updatePet(pet);
+
+ List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
+ assertNotNull(pets);
+
+ boolean found = false;
+ for (Pet fetched : pets) {
+ if (fetched.getId().equals(pet.getId())) {
+ found = true;
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+
+ @Test
+ public void testUpdatePetWithFormSync() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("frank");
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+ assertEquals("frank", fetched.getName());
+
+ api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null);
+ Pet updated = api.getPetById(fetched.getId());
+ assertEquals("furt", updated.getName());
+ }
+
+ @Test
+ public void testDeletePetSync() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+ api.deletePet(fetched.getId(), null);
+
+ try {
+ fetched = api.getPetById(fetched.getId());
+ fail("expected an error");
+ } catch (ApiException e) {
+ assertEquals(404, e.getCode());
+ }
+ }
+
+ @Test
+ public void testUploadFileSync() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ File file = new File("hello.txt");
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+ writer.write("Hello world!");
+ writer.close();
+
+ api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
+ }
+
+ private Pet createRandomPet() {
+ Pet pet = new Pet();
+ pet.setId(System.currentTimeMillis());
+ pet.setName("gorilla");
+
+ Category category = new Category();
+ category.setName("really-happy");
+
+ pet.setCategory(category);
+ pet.setStatus(Pet.StatusEnum.available);
+ List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
+ pet.setPhotoUrls(photos);
+
+ return pet;
+ }
+
+ private Response.ErrorListener createErrorListener(final Waiter waiter) {
+ return new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ error.printStackTrace();
+ waiter.fail(error.getMessage());
+ waiter.resume();
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/samples/client/petstore/go/README.md b/samples/client/petstore/go/README.md
new file mode 100644
index 000000000000..7ce753fba9fa
--- /dev/null
+++ b/samples/client/petstore/go/README.md
@@ -0,0 +1,12 @@
+# Go API client for swagger
+
+## Overview
+This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.
+
+
+## Installation
+Put the package under your project folder and add the following in import:
+```
+ "./swagger"
+```
+
diff --git a/samples/client/petstore/go/swagger/Category.go b/samples/client/petstore/go/swagger/Category.go
new file mode 100644
index 000000000000..0268f62488af
--- /dev/null
+++ b/samples/client/petstore/go/swagger/Category.go
@@ -0,0 +1,10 @@
+package swagger
+
+import (
+)
+
+type Category struct {
+ Id int64 `json:"id,omitempty"`
+ Name string `json:"name,omitempty"`
+
+}
diff --git a/samples/client/petstore/go/swagger/Order.go b/samples/client/petstore/go/swagger/Order.go
new file mode 100644
index 000000000000..9db0f945110b
--- /dev/null
+++ b/samples/client/petstore/go/swagger/Order.go
@@ -0,0 +1,15 @@
+package swagger
+
+import (
+ "time"
+)
+
+type Order struct {
+ Id int64 `json:"id,omitempty"`
+ PetId int64 `json:"petId,omitempty"`
+ Quantity int32 `json:"quantity,omitempty"`
+ ShipDate time.Time `json:"shipDate,omitempty"`
+ Status string `json:"status,omitempty"`
+ Complete bool `json:"complete,omitempty"`
+
+}
diff --git a/samples/client/petstore/go/swagger/Pet.go b/samples/client/petstore/go/swagger/Pet.go
new file mode 100644
index 000000000000..7544eed63847
--- /dev/null
+++ b/samples/client/petstore/go/swagger/Pet.go
@@ -0,0 +1,14 @@
+package swagger
+
+import (
+)
+
+type Pet struct {
+ Id int64 `json:"id,omitempty"`
+ Category Category `json:"category,omitempty"`
+ Name string `json:"name,omitempty"`
+ PhotoUrls []string `json:"photoUrls,omitempty"`
+ Tags []Tag `json:"tags,omitempty"`
+ Status string `json:"status,omitempty"`
+
+}
diff --git a/samples/client/petstore/go/swagger/PetApi.go b/samples/client/petstore/go/swagger/PetApi.go
new file mode 100644
index 000000000000..51b32061e0fe
--- /dev/null
+++ b/samples/client/petstore/go/swagger/PetApi.go
@@ -0,0 +1,329 @@
+package swagger
+
+import (
+ "strings"
+ "fmt"
+ "github.com/dghubble/sling"
+ "os"
+)
+
+type PetApi struct {
+ basePath string
+}
+
+func NewPetApi() *PetApi{
+ return &PetApi {
+ basePath: "http://petstore.swagger.io/v2",
+ }
+}
+
+func NewPetApiWithBasePath(basePath string) *PetApi{
+ return &PetApi {
+ basePath: basePath,
+ }
+}
+
+/**
+ * Update an existing pet
+ *
+ * @param Body Pet object that needs to be added to the store
+ * @return void
+ */
+//func (a PetApi) UpdatePet (Body Pet) (error) {
+func (a PetApi) UpdatePet (Body Pet) (error) {
+
+ _sling := sling.New().Put(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("UpdatePet response: void, ", resp, err)
+ return err
+}
+/**
+ * Add a new pet to the store
+ *
+ * @param Body Pet object that needs to be added to the store
+ * @return void
+ */
+//func (a PetApi) AddPet (Body Pet) (error) {
+func (a PetApi) AddPet (Body Pet) (error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("AddPet response: void, ", resp, err)
+ return err
+}
+/**
+ * Finds Pets by status
+ * Multiple status values can be provided with comma seperated strings
+ * @param Status Status values that need to be considered for filter
+ * @return []Pet
+ */
+//func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) {
+func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/findByStatus"
+
+ _sling = _sling.Path(path)
+
+ type QueryParams struct {
+ Status []string `url:"status,omitempty"`
+
+}
+ _sling = _sling.QueryStruct(&QueryParams{ Status: Status })
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new([]Pet)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("FindPetsByStatus response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Finds Pets by tags
+ * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
+ * @param Tags Tags to filter by
+ * @return []Pet
+ */
+//func (a PetApi) FindPetsByTags (Tags []string) ([]Pet, error) {
+func (a PetApi) FindPetsByTags (Tags []string) ([]Pet, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/findByTags"
+
+ _sling = _sling.Path(path)
+
+ type QueryParams struct {
+ Tags []string `url:"tags,omitempty"`
+
+}
+ _sling = _sling.QueryStruct(&QueryParams{ Tags: Tags })
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new([]Pet)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("FindPetsByTags response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Find pet by ID
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param PetId ID of pet that needs to be fetched
+ * @return Pet
+ */
+//func (a PetApi) GetPetById (PetId int64) (Pet, error) {
+func (a PetApi) GetPetById (PetId int64) (Pet, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/{petId}"
+ path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new(Pet)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("GetPetById response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Updates a pet in the store with form data
+ *
+ * @param PetId ID of pet that needs to be updated
+ * @param Name Updated name of the pet
+ * @param Status Updated status of the pet
+ * @return void
+ */
+//func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) {
+func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/{petId}"
+ path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+ type FormParams struct {
+ Name string `url:"name,omitempty"`
+ Status string `url:"status,omitempty"`
+ }
+ _sling = _sling.BodyForm(&FormParams{ Name: Name,Status: Status })
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("UpdatePetWithForm response: void, ", resp, err)
+ return err
+}
+/**
+ * Deletes a pet
+ *
+ * @param PetId Pet id to delete
+ * @param ApiKey
+ * @return void
+ */
+//func (a PetApi) DeletePet (PetId int64, ApiKey string) (error) {
+func (a PetApi) DeletePet (PetId int64, ApiKey string) (error) {
+
+ _sling := sling.New().Delete(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/{petId}"
+ path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+ // header params "api_key"
+ _sling = _sling.Set("api_key", ApiKey)
+
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("DeletePet response: void, ", resp, err)
+ return err
+}
+/**
+ * downloads an image
+ *
+ * @return *os.File
+ */
+//func (a PetApi) DownloadFile () (*os.File, error) {
+func (a PetApi) DownloadFile () (*os.File, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/{petId}/downloadImage"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/octet-stream" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new(*os.File)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("DownloadFile response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * uploads an image
+ *
+ * @param PetId ID of pet to update
+ * @param AdditionalMetadata Additional data to pass to server
+ * @param File file to upload
+ * @return void
+ */
+//func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) {
+func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/pet/{petId}/uploadImage"
+ path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+ type FormParams struct {
+ AdditionalMetadata string `url:"additionalMetadata,omitempty"`
+ File *os.File `url:"file,omitempty"`
+ }
+ _sling = _sling.BodyForm(&FormParams{ AdditionalMetadata: AdditionalMetadata,File: File })
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("UploadFile response: void, ", resp, err)
+ return err
+}
diff --git a/samples/client/petstore/go/swagger/StoreApi.go b/samples/client/petstore/go/swagger/StoreApi.go
new file mode 100644
index 000000000000..c43d320077c9
--- /dev/null
+++ b/samples/client/petstore/go/swagger/StoreApi.go
@@ -0,0 +1,147 @@
+package swagger
+
+import (
+ "strings"
+ "fmt"
+ "github.com/dghubble/sling"
+)
+
+type StoreApi struct {
+ basePath string
+}
+
+func NewStoreApi() *StoreApi{
+ return &StoreApi {
+ basePath: "http://petstore.swagger.io/v2",
+ }
+}
+
+func NewStoreApiWithBasePath(basePath string) *StoreApi{
+ return &StoreApi {
+ basePath: basePath,
+ }
+}
+
+/**
+ * Returns pet inventories by status
+ * Returns a map of status codes to quantities
+ * @return map[string]int32
+ */
+//func (a StoreApi) GetInventory () (map[string]int32, error) {
+func (a StoreApi) GetInventory () (map[string]int32, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/store/inventory"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new(map[string]int32)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("GetInventory response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Place an order for a pet
+ *
+ * @param Body order placed for purchasing the pet
+ * @return Order
+ */
+//func (a StoreApi) PlaceOrder (Body Order) (Order, error) {
+func (a StoreApi) PlaceOrder (Body Order) (Order, error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/store/order"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+ response := new(Order)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("PlaceOrder response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Find purchase order by ID
+ * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ * @param OrderId ID of pet that needs to be fetched
+ * @return Order
+ */
+//func (a StoreApi) GetOrderById (OrderId string) (Order, error) {
+func (a StoreApi) GetOrderById (OrderId string) (Order, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/store/order/{orderId}"
+ path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", OrderId), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new(Order)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("GetOrderById response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Delete purchase order by ID
+ * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ * @param OrderId ID of the order that needs to be deleted
+ * @return void
+ */
+//func (a StoreApi) DeleteOrder (OrderId string) (error) {
+func (a StoreApi) DeleteOrder (OrderId string) (error) {
+
+ _sling := sling.New().Delete(a.basePath)
+
+ // create path and map variables
+ path := "/v2/store/order/{orderId}"
+ path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", OrderId), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("DeleteOrder response: void, ", resp, err)
+ return err
+}
diff --git a/samples/client/petstore/go/swagger/Tag.go b/samples/client/petstore/go/swagger/Tag.go
new file mode 100644
index 000000000000..6b505272a15d
--- /dev/null
+++ b/samples/client/petstore/go/swagger/Tag.go
@@ -0,0 +1,10 @@
+package swagger
+
+import (
+)
+
+type Tag struct {
+ Id int64 `json:"id,omitempty"`
+ Name string `json:"name,omitempty"`
+
+}
diff --git a/samples/client/petstore/go/swagger/User.go b/samples/client/petstore/go/swagger/User.go
new file mode 100644
index 000000000000..e7f26d1d10c2
--- /dev/null
+++ b/samples/client/petstore/go/swagger/User.go
@@ -0,0 +1,16 @@
+package swagger
+
+import (
+)
+
+type User struct {
+ Id int64 `json:"id,omitempty"`
+ Username string `json:"username,omitempty"`
+ FirstName string `json:"firstName,omitempty"`
+ LastName string `json:"lastName,omitempty"`
+ Email string `json:"email,omitempty"`
+ Password string `json:"password,omitempty"`
+ Phone string `json:"phone,omitempty"`
+ UserStatus int32 `json:"userStatus,omitempty"`
+
+}
diff --git a/samples/client/petstore/go/swagger/UserApi.go b/samples/client/petstore/go/swagger/UserApi.go
new file mode 100644
index 000000000000..9907453bd392
--- /dev/null
+++ b/samples/client/petstore/go/swagger/UserApi.go
@@ -0,0 +1,282 @@
+package swagger
+
+import (
+ "strings"
+ "fmt"
+ "github.com/dghubble/sling"
+)
+
+type UserApi struct {
+ basePath string
+}
+
+func NewUserApi() *UserApi{
+ return &UserApi {
+ basePath: "http://petstore.swagger.io/v2",
+ }
+}
+
+func NewUserApiWithBasePath(basePath string) *UserApi{
+ return &UserApi {
+ basePath: basePath,
+ }
+}
+
+/**
+ * Create user
+ * This can only be done by the logged in user.
+ * @param Body Created user object
+ * @return void
+ */
+//func (a UserApi) CreateUser (Body User) (error) {
+func (a UserApi) CreateUser (Body User) (error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("CreateUser response: void, ", resp, err)
+ return err
+}
+/**
+ * Creates list of users with given input array
+ *
+ * @param Body List of user object
+ * @return void
+ */
+//func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) {
+func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/createWithArray"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("CreateUsersWithArrayInput response: void, ", resp, err)
+ return err
+}
+/**
+ * Creates list of users with given input array
+ *
+ * @param Body List of user object
+ * @return void
+ */
+//func (a UserApi) CreateUsersWithListInput (Body []User) (error) {
+func (a UserApi) CreateUsersWithListInput (Body []User) (error) {
+
+ _sling := sling.New().Post(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/createWithList"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("CreateUsersWithListInput response: void, ", resp, err)
+ return err
+}
+/**
+ * Logs user into the system
+ *
+ * @param Username The user name for login
+ * @param Password The password for login in clear text
+ * @return string
+ */
+//func (a UserApi) LoginUser (Username string, Password string) (string, error) {
+func (a UserApi) LoginUser (Username string, Password string) (string, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/login"
+
+ _sling = _sling.Path(path)
+
+ type QueryParams struct {
+ Username string `url:"username,omitempty"`
+ Password string `url:"password,omitempty"`
+
+}
+ _sling = _sling.QueryStruct(&QueryParams{ Username: Username,Password: Password })
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new(string)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("LoginUser response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Logs out current logged in user session
+ *
+ * @return void
+ */
+//func (a UserApi) LogoutUser () (error) {
+func (a UserApi) LogoutUser () (error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/logout"
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("LogoutUser response: void, ", resp, err)
+ return err
+}
+/**
+ * Get user by user name
+ *
+ * @param Username The name that needs to be fetched. Use user1 for testing.
+ * @return User
+ */
+//func (a UserApi) GetUserByName (Username string) (User, error) {
+func (a UserApi) GetUserByName (Username string) (User, error) {
+
+ _sling := sling.New().Get(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/{username}"
+ path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+ response := new(User)
+ _, err := _sling.ReceiveSuccess(response)
+ //fmt.Println("GetUserByName response: ", response, resp, err)
+ return *response, err
+}
+/**
+ * Updated user
+ * This can only be done by the logged in user.
+ * @param Username name that need to be deleted
+ * @param Body Updated user object
+ * @return void
+ */
+//func (a UserApi) UpdateUser (Username string, Body User) (error) {
+func (a UserApi) UpdateUser (Username string, Body User) (error) {
+
+ _sling := sling.New().Put(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/{username}"
+ path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+// body params
+ _sling = _sling.BodyJSON(Body)
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("UpdateUser response: void, ", resp, err)
+ return err
+}
+/**
+ * Delete user
+ * This can only be done by the logged in user.
+ * @param Username The name that needs to be deleted
+ * @return void
+ */
+//func (a UserApi) DeleteUser (Username string) (error) {
+func (a UserApi) DeleteUser (Username string) (error) {
+
+ _sling := sling.New().Delete(a.basePath)
+
+ // create path and map variables
+ path := "/v2/user/{username}"
+ path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1)
+
+ _sling = _sling.Path(path)
+
+ // accept header
+ accepts := []string { "application/json", "application/xml" }
+ for key := range accepts {
+ _sling = _sling.Set("Accept", accepts[key])
+ break // only use the first Accept
+ }
+
+
+
+
+ _, err := _sling.ReceiveSuccess(nil)
+ //fmt.Println("DeleteUser response: void, ", resp, err)
+ return err
+}
diff --git a/samples/client/petstore/go/test.go b/samples/client/petstore/go/test.go
new file mode 100644
index 000000000000..d65e70575fca
--- /dev/null
+++ b/samples/client/petstore/go/test.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ sw "./swagger"
+ "encoding/json"
+ "fmt"
+)
+
+func main() {
+
+ s := sw.NewPetApi()
+
+ // test POST(body)
+ newPet := (sw.Pet{Id: 12830, Name: "gopher",
+ PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"})
+
+ jsonNewPet, _ := json.Marshal(newPet)
+ fmt.Println("newPet:", string(jsonNewPet))
+ s.AddPet(newPet)
+
+ // test POST(form)
+ s.UpdatePetWithForm("12830", "golang", "available")
+
+ // test GET
+ resp, err := s.GetPetById(12830)
+ fmt.Println("GetPetById: ", resp, err)
+
+}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java
index 581eafa51ca4..da80705902c5 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java
@@ -41,7 +41,7 @@ import io.swagger.client.auth.HttpBasicAuth;
import io.swagger.client.auth.ApiKeyAuth;
import io.swagger.client.auth.OAuth;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-08T18:50:38.131+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class ApiClient {
private Map defaultHeaderMap = new HashMap();
private String basePath = "http://petstore.swagger.io/v2";
@@ -451,34 +451,51 @@ public class ApiClient {
}
}
- private ClientResponse getAPIResponse(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException {
+ /**
+ * Build full URL by concatenating base path, the given sub path and query parameters.
+ *
+ * @param path The sub path
+ * @param queryParams The query parameters
+ * @return The full URL
+ */
+ private String buildUrl(String path, List queryParams) {
+ final StringBuilder url = new StringBuilder();
+ url.append(basePath).append(path);
- if (body != null && !formParams.isEmpty()){
+ if (queryParams != null && !queryParams.isEmpty()) {
+ // support (constant) query string in `path`, e.g. "/posts?draft=1"
+ String prefix = path.contains("?") ? "&" : "?";
+ for (Pair param : queryParams) {
+ if (param.getValue() != null) {
+ if (prefix != null) {
+ url.append(prefix);
+ prefix = null;
+ } else {
+ url.append("&");
+ }
+ String value = parameterToString(param.getValue());
+ url.append(escapeString(param.getName())).append("=").append(escapeString(value));
+ }
+ }
+ }
+
+ return url.toString();
+ }
+
+ private ClientResponse getAPIResponse(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException {
+ if (body != null && !formParams.isEmpty()) {
throw new ApiException(500, "Cannot have body and form params");
}
updateParamsForAuth(authNames, queryParams, headerParams);
- StringBuilder b = new StringBuilder();
- b.append("?");
- if (queryParams != null){
- for (Pair queryParam : queryParams){
- if (!queryParam.getName().isEmpty()) {
- b.append(escapeString(queryParam.getName()));
- b.append("=");
- b.append(escapeString(queryParam.getValue()));
- b.append("&");
- }
- }
- }
-
- String querystring = b.substring(0, b.length() - 1);
-
+ final String url = buildUrl(path, queryParams);
Builder builder;
- if (accept == null)
- builder = httpClient.resource(basePath + path + querystring).getRequestBuilder();
- else
- builder = httpClient.resource(basePath + path + querystring).accept(accept);
+ if (accept == null) {
+ builder = httpClient.resource(url).getRequestBuilder();
+ } else {
+ builder = httpClient.resource(url).accept(accept);
+ }
for (String key : headerParams.keySet()) {
builder = builder.header(key, headerParams.get(key));
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java
index 1ae3b1dc44dd..bbbc5503c92f 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java
@@ -12,7 +12,7 @@ import java.io.File;
import java.util.*;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:16.440+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class PetApi {
private ApiClient apiClient;
@@ -395,6 +395,93 @@ public class PetApi {
String[] authNames = new String[] { "petstore_auth" };
+ apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
+
+ }
+
+ /**
+ * Fake endpoint to test byte array return by 'Find pet by ID'
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param petId ID of pet that needs to be fetched
+ * @return byte[]
+ */
+ public byte[] getPetByIdWithByteArray(Long petId) throws ApiException {
+ Object postBody = null;
+
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdWithByteArray");
+ }
+
+ // create path and map variables
+ String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json")
+ .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
+
+ // query params
+ List queryParams = new ArrayList();
+ Map headerParams = new HashMap();
+ Map formParams = new HashMap();
+
+
+
+
+
+
+
+ final String[] accepts = {
+ "application/json", "application/xml"
+ };
+ final String accept = apiClient.selectHeaderAccept(accepts);
+
+ final String[] contentTypes = {
+
+ };
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
+
+ String[] authNames = new String[] { "api_key" };
+
+
+ GenericType returnType = new GenericType() {};
+ return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
+
+ }
+
+ /**
+ * Fake endpoint to test byte array in body parameter for adding a new pet to the store
+ *
+ * @param body Pet object in the form of byte array
+ * @return void
+ */
+ public void addPetUsingByteArray(byte[] body) throws ApiException {
+ Object postBody = body;
+
+ // create path and map variables
+ String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
+
+ // query params
+ List queryParams = new ArrayList();
+ Map headerParams = new HashMap();
+ Map formParams = new HashMap();
+
+
+
+
+
+
+
+ final String[] accepts = {
+ "application/json", "application/xml"
+ };
+ final String accept = apiClient.selectHeaderAccept(accepts);
+
+ final String[] contentTypes = {
+ "application/json", "application/xml"
+ };
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
+
+ String[] authNames = new String[] { "petstore_auth" };
+
+
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java
index 1faa3f275892..4dcaa928c9a3 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:16.440+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class Category {
private Long id = null;
@@ -45,7 +45,7 @@ public class Category {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -53,8 +53,10 @@ public class Category {
return false;
}
Category category = (Category) o;
- return Objects.equals(id, category.id) &&
- Objects.equals(name, category.name);
+
+ return true && Objects.equals(id, category.id) &&
+ Objects.equals(name, category.name)
+ ;
}
@Override
@@ -77,7 +79,7 @@ public class Category {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java
index ec66ccbd7772..67543c5a227e 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java
@@ -11,7 +11,7 @@ import java.util.Date;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:16.440+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class Order {
private Long id = null;
@@ -123,7 +123,7 @@ public class Order {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -131,12 +131,14 @@ public class Order {
return false;
}
Order order = (Order) o;
- return Objects.equals(id, order.id) &&
+
+ return true && Objects.equals(id, order.id) &&
Objects.equals(petId, order.petId) &&
Objects.equals(quantity, order.quantity) &&
Objects.equals(shipDate, order.shipDate) &&
Objects.equals(status, order.status) &&
- Objects.equals(complete, order.complete);
+ Objects.equals(complete, order.complete)
+ ;
}
@Override
@@ -163,7 +165,7 @@ public class Order {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java
index 2d773d9f5bdd..12d3e5a441f4 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java
@@ -13,7 +13,7 @@ import java.util.*;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:16.440+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class Pet {
private Long id = null;
@@ -125,7 +125,7 @@ public class Pet {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -133,12 +133,14 @@ public class Pet {
return false;
}
Pet pet = (Pet) o;
- return Objects.equals(id, pet.id) &&
+
+ return true && Objects.equals(id, pet.id) &&
Objects.equals(category, pet.category) &&
Objects.equals(name, pet.name) &&
Objects.equals(photoUrls, pet.photoUrls) &&
Objects.equals(tags, pet.tags) &&
- Objects.equals(status, pet.status);
+ Objects.equals(status, pet.status)
+ ;
}
@Override
@@ -165,7 +167,7 @@ public class Pet {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java
index c1156c9f4c0b..7f65d9c963a2 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:16.440+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class Tag {
private Long id = null;
@@ -45,7 +45,7 @@ public class Tag {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -53,8 +53,10 @@ public class Tag {
return false;
}
Tag tag = (Tag) o;
- return Objects.equals(id, tag.id) &&
- Objects.equals(name, tag.name);
+
+ return true && Objects.equals(id, tag.id) &&
+ Objects.equals(name, tag.name)
+ ;
}
@Override
@@ -77,7 +79,7 @@ public class Tag {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java
index 7c07662debe4..df6bc1e543f1 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:16.440+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:19:23.415+08:00")
public class User {
private Long id = null;
@@ -130,7 +130,7 @@ public class User {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -138,14 +138,16 @@ public class User {
return false;
}
User user = (User) o;
- return Objects.equals(id, user.id) &&
+
+ return true && Objects.equals(id, user.id) &&
Objects.equals(username, user.username) &&
Objects.equals(firstName, user.firstName) &&
Objects.equals(lastName, user.lastName) &&
Objects.equals(email, user.email) &&
Objects.equals(password, user.password) &&
Objects.equals(phone, user.phone) &&
- Objects.equals(userStatus, user.userStatus);
+ Objects.equals(userStatus, user.userStatus)
+ ;
}
@Override
@@ -174,7 +176,7 @@ public class User {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java
index c67892318682..dece3403fd8c 100644
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java
+++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java
@@ -1,5 +1,9 @@
package io.swagger.petstore.test;
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.datatype.joda.*;
+
import io.swagger.TestUtils;
import io.swagger.client.*;
@@ -18,7 +22,8 @@ import org.junit.*;
import static org.junit.Assert.*;
public class PetApiTest {
- PetApi api = null;
+ private PetApi api;
+ private ObjectMapper mapper;
@Before
public void setup() {
@@ -67,6 +72,20 @@ public class PetApiTest {
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
+ @Test
+ public void testCreateAndGetPetWithByteArray() throws Exception {
+ Pet pet = createRandomPet();
+ byte[] bytes = serializeJson(pet).getBytes();
+ api.addPetUsingByteArray(bytes);
+
+ byte[] fetchedBytes = api.getPetByIdWithByteArray(pet.getId());
+ Pet fetched = deserializeJson(new String(fetchedBytes), Pet.class);
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ }
+
@Test
public void testUpdatePet() throws Exception {
Pet pet = createRandomPet();
@@ -215,4 +234,37 @@ public class PetApiTest {
return pet;
}
+
+ private String serializeJson(Object o) {
+ if (mapper == null) {
+ mapper = createObjectMapper();
+ }
+ try {
+ return mapper.writeValueAsString(o);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private T deserializeJson(String json, Class klass) {
+ if (mapper == null) {
+ mapper = createObjectMapper();
+ }
+ try {
+ return mapper.readValue(json, klass);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ObjectMapper createObjectMapper() {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+ mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ mapper.registerModule(new JodaModule());
+ return mapper;
+ }
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
index 7f06e36633f1..c5b3f24e0a1c 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
@@ -43,7 +43,7 @@ import io.swagger.client.auth.HttpBasicAuth;
import io.swagger.client.auth.ApiKeyAuth;
import io.swagger.client.auth.OAuth;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-08T18:51:26.068+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class ApiClient {
private Map defaultHeaderMap = new HashMap();
private String basePath = "http://petstore.swagger.io/v2";
@@ -494,7 +494,9 @@ public class ApiClient {
public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);
- WebTarget target = httpClient.target(this.basePath).path(path);
+ // Not using `.target(this.basePath).path(path)` below,
+ // to support (constant) query string in `path`, e.g. "/posts?draft=1"
+ WebTarget target = httpClient.target(this.basePath + path);
if (queryParams != null) {
for (Pair queryParam : queryParams) {
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java
index 09b7bdba247b..9155782024a6 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java
@@ -12,7 +12,7 @@ import java.io.File;
import java.util.*;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:17.660+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class PetApi {
private ApiClient apiClient;
@@ -395,6 +395,93 @@ public class PetApi {
String[] authNames = new String[] { "petstore_auth" };
+ apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
+
+ }
+
+ /**
+ * Fake endpoint to test byte array return by 'Find pet by ID'
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param petId ID of pet that needs to be fetched
+ * @return byte[]
+ */
+ public byte[] getPetByIdWithByteArray(Long petId) throws ApiException {
+ Object postBody = null;
+
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdWithByteArray");
+ }
+
+ // create path and map variables
+ String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json")
+ .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
+
+ // query params
+ List queryParams = new ArrayList();
+ Map headerParams = new HashMap();
+ Map formParams = new HashMap();
+
+
+
+
+
+
+
+ final String[] accepts = {
+ "application/json", "application/xml"
+ };
+ final String accept = apiClient.selectHeaderAccept(accepts);
+
+ final String[] contentTypes = {
+
+ };
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
+
+ String[] authNames = new String[] { "api_key" };
+
+
+ GenericType returnType = new GenericType() {};
+ return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
+
+ }
+
+ /**
+ * Fake endpoint to test byte array in body parameter for adding a new pet to the store
+ *
+ * @param body Pet object in the form of byte array
+ * @return void
+ */
+ public void addPetUsingByteArray(byte[] body) throws ApiException {
+ Object postBody = body;
+
+ // create path and map variables
+ String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
+
+ // query params
+ List queryParams = new ArrayList();
+ Map headerParams = new HashMap();
+ Map formParams = new HashMap();
+
+
+
+
+
+
+
+ final String[] accepts = {
+ "application/json", "application/xml"
+ };
+ final String accept = apiClient.selectHeaderAccept(accepts);
+
+ final String[] contentTypes = {
+ "application/json", "application/xml"
+ };
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
+
+ String[] authNames = new String[] { "petstore_auth" };
+
+
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java
index 4a66bec68d3c..2235895ee8af 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:17.660+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class Category {
private Long id = null;
@@ -45,7 +45,7 @@ public class Category {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -53,8 +53,10 @@ public class Category {
return false;
}
Category category = (Category) o;
- return Objects.equals(id, category.id) &&
- Objects.equals(name, category.name);
+
+ return true && Objects.equals(id, category.id) &&
+ Objects.equals(name, category.name)
+ ;
}
@Override
@@ -77,7 +79,7 @@ public class Category {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java
index 29d0a70616d6..0d9b89eb58fa 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java
@@ -11,7 +11,7 @@ import java.util.Date;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:17.660+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class Order {
private Long id = null;
@@ -123,7 +123,7 @@ public class Order {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -131,12 +131,14 @@ public class Order {
return false;
}
Order order = (Order) o;
- return Objects.equals(id, order.id) &&
+
+ return true && Objects.equals(id, order.id) &&
Objects.equals(petId, order.petId) &&
Objects.equals(quantity, order.quantity) &&
Objects.equals(shipDate, order.shipDate) &&
Objects.equals(status, order.status) &&
- Objects.equals(complete, order.complete);
+ Objects.equals(complete, order.complete)
+ ;
}
@Override
@@ -163,7 +165,7 @@ public class Order {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java
index 8ded8bc4cb2e..9e5a2d97fb21 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java
@@ -13,7 +13,7 @@ import java.util.*;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:17.660+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class Pet {
private Long id = null;
@@ -125,7 +125,7 @@ public class Pet {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -133,12 +133,14 @@ public class Pet {
return false;
}
Pet pet = (Pet) o;
- return Objects.equals(id, pet.id) &&
+
+ return true && Objects.equals(id, pet.id) &&
Objects.equals(category, pet.category) &&
Objects.equals(name, pet.name) &&
Objects.equals(photoUrls, pet.photoUrls) &&
Objects.equals(tags, pet.tags) &&
- Objects.equals(status, pet.status);
+ Objects.equals(status, pet.status)
+ ;
}
@Override
@@ -165,7 +167,7 @@ public class Pet {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java
index cbdca57888f0..4b2cc23bc230 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:17.660+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class Tag {
private Long id = null;
@@ -45,7 +45,7 @@ public class Tag {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -53,8 +53,10 @@ public class Tag {
return false;
}
Tag tag = (Tag) o;
- return Objects.equals(id, tag.id) &&
- Objects.equals(name, tag.name);
+
+ return true && Objects.equals(id, tag.id) &&
+ Objects.equals(name, tag.name)
+ ;
}
@Override
@@ -77,7 +79,7 @@ public class Tag {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java
index ae1dff618fc7..4f859759ce85 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-05T14:39:17.660+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-15T19:00:52.199+08:00")
public class User {
private Long id = null;
@@ -130,7 +130,7 @@ public class User {
@Override
- public boolean equals(Object o) {
+ public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
@@ -138,14 +138,16 @@ public class User {
return false;
}
User user = (User) o;
- return Objects.equals(id, user.id) &&
+
+ return true && Objects.equals(id, user.id) &&
Objects.equals(username, user.username) &&
Objects.equals(firstName, user.firstName) &&
Objects.equals(lastName, user.lastName) &&
Objects.equals(email, user.email) &&
Objects.equals(password, user.password) &&
Objects.equals(phone, user.phone) &&
- Objects.equals(userStatus, user.userStatus);
+ Objects.equals(userStatus, user.userStatus)
+ ;
}
@Override
@@ -174,7 +176,7 @@ public class User {
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
- private String toIndentedString(Object o) {
+ private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java
index c67892318682..a135b3c352f1 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java
@@ -1,5 +1,7 @@
package io.swagger.petstore.test;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import io.swagger.TestUtils;
import io.swagger.client.*;
@@ -67,6 +69,20 @@ public class PetApiTest {
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
+ @Test
+ public void testCreateAndGetPetWithByteArray() throws Exception {
+ Pet pet = createRandomPet();
+ byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes();
+ api.addPetUsingByteArray(bytes);
+
+ byte[] fetchedBytes = api.getPetByIdWithByteArray(pet.getId());
+ Pet fetched = deserializeJson(new String(fetchedBytes), Pet.class, api.getApiClient());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ }
+
@Test
public void testUpdatePet() throws Exception {
Pet pet = createRandomPet();
@@ -215,4 +231,22 @@ public class PetApiTest {
return pet;
}
+
+ private String serializeJson(Object o, ApiClient apiClient) {
+ ObjectMapper mapper = apiClient.getJSON().getContext(null);
+ try {
+ return mapper.writeValueAsString(o);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private T deserializeJson(String json, Class klass, ApiClient apiClient) {
+ ObjectMapper mapper = apiClient.getJSON().getContext(null);
+ try {
+ return mapper.readValue(json, klass);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
}
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
index e8933b9373af..810922b90a27 100644
--- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java
@@ -656,8 +656,8 @@ public class ApiClient {
}
/**
- * Deserialize response body to Java object, according to the Content-Type
- * response header.
+ * Deserialize response body to Java object, according to the return type and
+ * the Content-Type response header.
*
* @param response HTTP response
* @param returnType The type of the Java object
@@ -666,12 +666,21 @@ public class ApiClient {
* or the Content-Type of the response is not supported.
*/
public T deserialize(Response response, Type returnType) throws ApiException {
- if (response == null || returnType == null)
+ if (response == null || returnType == null) {
return null;
+ }
- // Handle file downloading.
- if (returnType.equals(File.class))
+ if ("byte[]".equals(returnType.toString())) {
+ // Handle binary response (byte array).
+ try {
+ return (T) response.body().bytes();
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ } else if (returnType.equals(File.class)) {
+ // Handle file downloading.
return (T) downloadFileFromResponse(response);
+ }
String respBody;
try {
@@ -683,8 +692,9 @@ public class ApiClient {
throw new ApiException(e);
}
- if (respBody == null || "".equals(respBody))
+ if (respBody == null || "".equals(respBody)) {
return null;
+ }
String contentType = response.headers().get("Content-Type");
if (contentType == null) {
@@ -706,20 +716,29 @@ public class ApiClient {
}
/**
- * Serialize the given Java object into request body string, according to the
- * request Content-Type.
+ * Serialize the given Java object into request body according to the object's
+ * class and the request Content-Type.
*
* @param obj The Java object
* @param contentType The request Content-Type
- * @return The serialized string
+ * @return The serialized request body
* @throws ApiException If fail to serialize the given object
*/
- public String serialize(Object obj, String contentType) throws ApiException {
- if (isJsonMime(contentType)) {
- if (obj != null)
- return json.serialize(obj);
- else
- return null;
+ public RequestBody serialize(Object obj, String contentType) throws ApiException {
+ if (obj instanceof byte[]) {
+ // Binary (byte array) body parameter support.
+ return RequestBody.create(MediaType.parse(contentType), (byte[]) obj);
+ } else if (obj instanceof File) {
+ // File body parameter support.
+ return RequestBody.create(MediaType.parse(contentType), (File) obj);
+ } else if (isJsonMime(contentType)) {
+ String content;
+ if (obj != null) {
+ content = json.serialize(obj);
+ } else {
+ content = null;
+ }
+ return RequestBody.create(MediaType.parse(contentType), content);
} else {
throw new ApiException("Content type \"" + contentType + "\" is not supported");
}
@@ -908,7 +927,7 @@ public class ApiClient {
reqBody = RequestBody.create(MediaType.parse(contentType), "");
}
} else {
- reqBody = RequestBody.create(MediaType.parse(contentType), serialize(body, contentType));
+ reqBody = serialize(body, contentType);
}
Request request = null;
@@ -931,20 +950,27 @@ public class ApiClient {
* @return The full URL
*/
public String buildUrl(String path, List queryParams) {
- StringBuilder query = new StringBuilder();
- if (queryParams != null) {
+ final StringBuilder url = new StringBuilder();
+ url.append(basePath).append(path);
+
+ if (queryParams != null && !queryParams.isEmpty()) {
+ // support (constant) query string in `path`, e.g. "/posts?draft=1"
+ String prefix = path.contains("?") ? "&" : "?";
for (Pair param : queryParams) {
if (param.getValue() != null) {
- if (query.toString().length() == 0)
- query.append("?");
- else
- query.append("&");
+ if (prefix != null) {
+ url.append(prefix);
+ prefix = null;
+ } else {
+ url.append("&");
+ }
String value = parameterToString(param.getValue());
- query.append(escapeString(param.getName())).append("=").append(escapeString(value));
+ url.append(escapeString(param.getName())).append("=").append(escapeString(value));
}
}
}
- return basePath + path + query.toString();
+
+ return url.toString();
}
/**
diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java
index 460cd0f4c4d6..497e3ade6a85 100644
--- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java
+++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java
@@ -892,4 +892,210 @@ public class PetApi {
return call;
}
+ /* Build call for getPetByIdWithByteArray */
+ private Call getPetByIdWithByteArrayCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
+ Object postBody = null;
+
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException("Missing the required parameter 'petId' when calling getPetByIdWithByteArray(Async)");
+ }
+
+
+ // create path and map variables
+ String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json")
+ .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
+
+ List queryParams = new ArrayList();
+
+ Map headerParams = new HashMap();
+
+ Map formParams = new HashMap();
+
+ final String[] accepts = {
+ "application/json", "application/xml"
+ };
+ final String accept = apiClient.selectHeaderAccept(accepts);
+ if (accept != null) headerParams.put("Accept", accept);
+
+ final String[] contentTypes = {
+
+ };
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
+ headerParams.put("Content-Type", contentType);
+
+ if(progressListener != null) {
+ apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
+ @Override
+ public Response intercept(Interceptor.Chain chain) throws IOException {
+ Response originalResponse = chain.proceed(chain.request());
+ return originalResponse.newBuilder()
+ .body(new ProgressResponseBody(originalResponse.body(), progressListener))
+ .build();
+ }
+ });
+ }
+
+ String[] authNames = new String[] { "api_key" };
+ return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
+ }
+
+ /**
+ * Fake endpoint to test byte array return by 'Find pet by ID'
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param petId ID of pet that needs to be fetched
+ * @return byte[]
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ */
+ public byte[] getPetByIdWithByteArray(Long petId) throws ApiException {
+ ApiResponse resp = getPetByIdWithByteArrayWithHttpInfo(petId);
+ return resp.getData();
+ }
+
+ /**
+ * Fake endpoint to test byte array return by 'Find pet by ID'
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param petId ID of pet that needs to be fetched
+ * @return ApiResponse
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ */
+ public ApiResponse getPetByIdWithByteArrayWithHttpInfo(Long petId) throws ApiException {
+ Call call = getPetByIdWithByteArrayCall(petId, null, null);
+ Type returnType = new TypeToken(){}.getType();
+ return apiClient.execute(call, returnType);
+ }
+
+ /**
+ * Fake endpoint to test byte array return by 'Find pet by ID' (asynchronously)
+ * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ * @param petId ID of pet that needs to be fetched
+ * @param callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body object
+ */
+ public Call getPetByIdWithByteArrayAsync(Long petId, final ApiCallback callback) throws ApiException {
+
+ ProgressResponseBody.ProgressListener progressListener = null;
+ ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
+
+ if (callback != null) {
+ progressListener = new ProgressResponseBody.ProgressListener() {
+ @Override
+ public void update(long bytesRead, long contentLength, boolean done) {
+ callback.onDownloadProgress(bytesRead, contentLength, done);
+ }
+ };
+
+ progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
+ @Override
+ public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
+ callback.onUploadProgress(bytesWritten, contentLength, done);
+ }
+ };
+ }
+
+ Call call = getPetByIdWithByteArrayCall(petId, progressListener, progressRequestListener);
+ Type returnType = new TypeToken(){}.getType();
+ apiClient.executeAsync(call, returnType, callback);
+ return call;
+ }
+
+ /* Build call for addPetUsingByteArray */
+ private Call addPetUsingByteArrayCall(byte[] body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
+ Object postBody = body;
+
+
+ // create path and map variables
+ String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
+
+ List queryParams = new ArrayList();
+
+ Map headerParams = new HashMap();
+
+ Map formParams = new HashMap();
+
+ final String[] accepts = {
+ "application/json", "application/xml"
+ };
+ final String accept = apiClient.selectHeaderAccept(accepts);
+ if (accept != null) headerParams.put("Accept", accept);
+
+ final String[] contentTypes = {
+ "application/json", "application/xml"
+ };
+ final String contentType = apiClient.selectHeaderContentType(contentTypes);
+ headerParams.put("Content-Type", contentType);
+
+ if(progressListener != null) {
+ apiClient.getHttpClient().networkInterceptors().add(new Interceptor() {
+ @Override
+ public Response intercept(Interceptor.Chain chain) throws IOException {
+ Response originalResponse = chain.proceed(chain.request());
+ return originalResponse.newBuilder()
+ .body(new ProgressResponseBody(originalResponse.body(), progressListener))
+ .build();
+ }
+ });
+ }
+
+ String[] authNames = new String[] { "petstore_auth" };
+ return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener);
+ }
+
+ /**
+ * Fake endpoint to test byte array in body parameter for adding a new pet to the store
+ *
+ * @param body Pet object in the form of byte array
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ */
+ public void addPetUsingByteArray(byte[] body) throws ApiException {
+ addPetUsingByteArrayWithHttpInfo(body);
+ }
+
+ /**
+ * Fake endpoint to test byte array in body parameter for adding a new pet to the store
+ *
+ * @param body Pet object in the form of byte array
+ * @return ApiResponse
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ */
+ public ApiResponse addPetUsingByteArrayWithHttpInfo(byte[] body) throws ApiException {
+ Call call = addPetUsingByteArrayCall(body, null, null);
+ return apiClient.execute(call);
+ }
+
+ /**
+ * Fake endpoint to test byte array in body parameter for adding a new pet to the store (asynchronously)
+ *
+ * @param body Pet object in the form of byte array
+ * @param callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body object
+ */
+ public Call addPetUsingByteArrayAsync(byte[] body, final ApiCallback callback) throws ApiException {
+
+ ProgressResponseBody.ProgressListener progressListener = null;
+ ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
+
+ if (callback != null) {
+ progressListener = new ProgressResponseBody.ProgressListener() {
+ @Override
+ public void update(long bytesRead, long contentLength, boolean done) {
+ callback.onDownloadProgress(bytesRead, contentLength, done);
+ }
+ };
+
+ progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
+ @Override
+ public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
+ callback.onUploadProgress(bytesWritten, contentLength, done);
+ }
+ };
+ }
+
+ Call call = addPetUsingByteArrayCall(body, progressListener, progressRequestListener);
+ apiClient.executeAsync(call, callback);
+ return call;
+ }
+
}
diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java
index e65de7791a85..b6f9c3837218 100644
--- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java
+++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java
@@ -1,5 +1,7 @@
package io.swagger.petstore.test;
+import com.google.gson.reflect.TypeToken;
+
import io.swagger.TestUtils;
import io.swagger.client.*;
@@ -10,6 +12,7 @@ import io.swagger.client.model.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -69,6 +72,23 @@ public class PetApiTest {
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
+ @Test
+ public void testCreateAndGetPetWithByteArray() throws Exception {
+ Pet pet = createRandomPet();
+ System.out.println(serializeJson(pet, api.getApiClient()));
+ byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes();
+ api.addPetUsingByteArray(bytes);
+
+ byte[] fetchedBytes = api.getPetByIdWithByteArray(pet.getId());
+ System.out.println(new String(fetchedBytes));
+ Type type = new TypeToken(){}.getType();
+ Pet fetched = deserializeJson(new String(fetchedBytes), type, api.getApiClient());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
+ }
+
@Test
public void testCreateAndGetPetWithHttpInfo() throws Exception {
Pet pet = createRandomPet();
@@ -327,4 +347,12 @@ public class PetApiTest {
return pet;
}
+
+ private String serializeJson(Object o, ApiClient apiClient) {
+ return apiClient.getJSON().serialize(o);
+ }
+
+ private T deserializeJson(String json, Type type, ApiClient apiClient) {
+ return (T) apiClient.getJSON().deserialize(json, type);
+ }
}
diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js
index 88674c64bc96..392007d6a54b 100644
--- a/samples/client/petstore/javascript/src/model/Pet.js
+++ b/samples/client/petstore/javascript/src/model/Pet.js
@@ -95,9 +95,9 @@ var StatusEnum = function StatusEnum() {
self.name = data.name;
- self.photoUrls = new Array();
+ self.photoUrls = data.photoUrls;
- self.tags = new Array();
+ self.tags = data.tags;
self.status = data.status;
diff --git a/samples/client/petstore/javascript/test/api/PetApiTest.js b/samples/client/petstore/javascript/test/api/PetApiTest.js
index f2c72bb80110..9385cf2701be 100644
--- a/samples/client/petstore/javascript/test/api/PetApiTest.js
+++ b/samples/client/petstore/javascript/test/api/PetApiTest.js
@@ -40,6 +40,7 @@ describe('PetApi', function() {
expect(fetched).to.be.ok();
expect(fetched.id).to.be(pet.id);
+ expect(fetched.getPhotoUrls()).to.eql(pet.getPhotoUrls());
expect(fetched.getCategory()).to.be.ok();
expect(fetched.getCategory().getName()).to.be(pet.getCategory().getName());
diff --git a/samples/client/petstore/javascript/test/api/StoreApiTest.java b/samples/client/petstore/javascript/test/api/StoreApiTest.java
deleted file mode 100644
index 6094f2242e11..000000000000
--- a/samples/client/petstore/javascript/test/api/StoreApiTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package io.swagger.petstore.test;
-
-import io.swagger.client.ApiException;
-
-import io.swagger.client.*;
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.util.Map;
-import java.text.SimpleDateFormat;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class StoreApiTest {
- StoreApi api = null;
-
- @Before
- public void setup() {
- api = new StoreApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- // set custom date format that is used by the petstore server
- api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
- }
-
- @Test
- public void testGetInventory() throws Exception {
- Map inventory = api.getInventory();
- assertTrue(inventory.keySet().size() > 0);
- }
-
- @Test
- public void testPlaceOrder() throws Exception {
- Order order = createOrder();
- api.placeOrder(order);
-
- Order fetched = api.getOrderById(String.valueOf(order.getId()));
- assertEquals(order.getId(), fetched.getId());
- assertEquals(order.getPetId(), fetched.getPetId());
- assertEquals(order.getQuantity(), fetched.getQuantity());
- }
-
- @Test
- public void testDeleteOrder() throws Exception {
- Order order = createOrder();
- api.placeOrder(order);
-
- Order fetched = api.getOrderById(String.valueOf(order.getId()));
- assertEquals(fetched.getId(), order.getId());
-
- api.deleteOrder(String.valueOf(order.getId()));
-
- try {
- api.getOrderById(String.valueOf(order.getId()));
- // fail("expected an error");
- } catch (ApiException e) {
- // ok
- }
- }
-
- private Order createOrder() {
- Order order = new Order();
- order.setId(new Long(System.currentTimeMillis()));
- order.setPetId(new Long(200));
- order.setQuantity(new Integer(13));
- order.setShipDate(new java.util.Date());
- order.setStatus(Order.StatusEnum.PLACED);
- order.setComplete(true);
-
- return order;
- }
-}
diff --git a/samples/client/petstore/javascript/test/api/UserApiTest.java b/samples/client/petstore/javascript/test/api/UserApiTest.java
deleted file mode 100644
index a3f257f568bf..000000000000
--- a/samples/client/petstore/javascript/test/api/UserApiTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package io.swagger.petstore.test;
-
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.util.Arrays;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class UserApiTest {
- UserApi api = null;
-
- @Before
- public void setup() {
- api = new UserApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- }
-
- @Test
- public void testCreateUser() throws Exception {
- User user = createUser();
-
- api.createUser(user);
-
- User fetched = api.getUserByName(user.getUsername());
- assertEquals(user.getId(), fetched.getId());
- }
-
- @Test
- public void testCreateUsersWithArray() throws Exception {
- User user1 = createUser();
- user1.setUsername("abc123");
- User user2 = createUser();
- user2.setUsername("123abc");
-
- api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
-
- User fetched = api.getUserByName(user1.getUsername());
- assertEquals(user1.getId(), fetched.getId());
- }
-
- @Test
- public void testCreateUsersWithList() throws Exception {
- User user1 = createUser();
- user1.setUsername("abc123");
- User user2 = createUser();
- user2.setUsername("123abc");
-
- api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
-
- User fetched = api.getUserByName(user1.getUsername());
- assertEquals(user1.getId(), fetched.getId());
- }
-
- @Test
- public void testLoginUser() throws Exception {
- User user = createUser();
- api.createUser(user);
-
- String token = api.loginUser(user.getUsername(), user.getPassword());
- assertTrue(token.startsWith("logged in user session:"));
- }
-
- @Test
- public void logoutUser() throws Exception {
- api.logoutUser();
- }
-
- private User createUser() {
- User user = new User();
- user.setId(System.currentTimeMillis());
- user.setUsername("fred" + user.getId());
- user.setFirstName("Fred");
- user.setLastName("Meyer");
- user.setEmail("fred@fredmeyer.com");
- user.setPassword("xxXXxx");
- user.setPhone("408-867-5309");
- user.setUserStatus(123);
-
- return user;
- }
-}
diff --git a/samples/server/petstore/flaskConnexion/README.md b/samples/server/petstore/flaskConnexion/README.md
index 2b8c96e6170e..933d4ec27232 100644
--- a/samples/server/petstore/flaskConnexion/README.md
+++ b/samples/server/petstore/flaskConnexion/README.md
@@ -2,26 +2,27 @@
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
-[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
-is an example of building a swagger-enabled flask server.
+[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
+is an example of building a swagger-enabled Flask server.
-This example uses the [connexion](https://github.com/zalando/connexion) library on top of Flask.
+This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
To run the server, please execute the following:
```
+sudo pip3 install -U connexion # install Connexion from PyPI
python3 app.py
```
and open your browser to here:
```
-http://localhost:8080/ui
+http://localhost:8080/v2/ui/
```
-Your swagger definition lives here:
+Your Swagger definition lives here:
```
-http://localhost:8080/swagger.json
+http://localhost:8080/v2/swagger.json
```
diff --git a/samples/server/petstore/flaskConnexion/app.py b/samples/server/petstore/flaskConnexion/app.py
index ae021b58df96..1e2fed4d9ea9 100644
--- a/samples/server/petstore/flaskConnexion/app.py
+++ b/samples/server/petstore/flaskConnexion/app.py
@@ -3,7 +3,6 @@
import connexion
if __name__ == '__main__':
- app = connexion.App(__name__, 8080,
- specification_dir='./swagger/')
- app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters'})
- app.run()
+ app = connexion.App(__name__, specification_dir='./swagger/')
+ app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.'})
+ app.run(port=8080)
diff --git a/samples/server/petstore/flaskConnexion/swagger/swagger.yaml b/samples/server/petstore/flaskConnexion/swagger/swagger.yaml
index 1a4ff85e60ab..d086d6ff49dc 100644
--- a/samples/server/petstore/flaskConnexion/swagger/swagger.yaml
+++ b/samples/server/petstore/flaskConnexion/swagger/swagger.yaml
@@ -2,9 +2,9 @@
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about\
- \ Swagger at http://swagger.io or on irc.freenode.net,\
- \ #swagger. For this sample, you can use the api key \"special-key\" to test\
- \ the authorization filters"
+ \ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\
+ \ For this sample, you can use the api key `special-key` to test the authorization\
+ \ filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
@@ -15,6 +15,19 @@ info:
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
+tags:
+- name: "pet"
+ description: "Everything about your Pets"
+ externalDocs:
+ description: "Find out more"
+ url: "http://swagger.io"
+- name: "store"
+ description: "Access to Petstore orders"
+- name: "user"
+ description: "Operations about user"
+ externalDocs:
+ description: "Find out more about our store"
+ url: "http://swagger.io"
schemes:
- "http"
paths:
@@ -29,22 +42,18 @@ paths:
- "application/json"
- "application/xml"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
- required: false
+ required: true
schema:
$ref: "#/definitions/Pet"
responses:
405:
description: "Invalid input"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
x-tags:
- tag: "pet"
put:
@@ -57,13 +66,13 @@ paths:
- "application/json"
- "application/xml"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
- required: false
+ required: true
schema:
$ref: "#/definitions/Pet"
responses:
@@ -73,10 +82,6 @@ paths:
description: "Pet not found"
405:
description: "Validation exception"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
x-tags:
- tag: "pet"
/pet/findByStatus:
@@ -84,21 +89,25 @@ paths:
tags:
- "pet"
summary: "Finds Pets by status"
- description: "Multiple status values can be provided with comma seperated strings"
+ description: "Multiple status values can be provided with comma separated strings"
operationId: "controllers.default_controller.find_pets_by_status"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "status"
in: "query"
description: "Status values that need to be considered for filter"
- required: false
+ required: true
type: "array"
items:
type: "string"
+ enum:
+ - "available"
+ - "pending"
+ - "sold"
+ default: "available"
collectionFormat: "multi"
- default: "available"
responses:
200:
description: "successful operation"
@@ -108,10 +117,6 @@ paths:
$ref: "#/definitions/Pet"
400:
description: "Invalid status value"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
x-tags:
- tag: "pet"
/pet/findByTags:
@@ -119,17 +124,17 @@ paths:
tags:
- "pet"
summary: "Finds Pets by tags"
- description: "Muliple tags can be provided with comma seperated strings. Use\
+ description: "Muliple tags can be provided with comma separated strings. Use\
\ tag1, tag2, tag3 for testing."
operationId: "controllers.default_controller.find_pets_by_tags"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "tags"
in: "query"
description: "Tags to filter by"
- required: false
+ required: true
type: "array"
items:
type: "string"
@@ -143,10 +148,7 @@ paths:
$ref: "#/definitions/Pet"
400:
description: "Invalid tag value"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
+ deprecated: true
x-tags:
- tag: "pet"
/pet/{petId}:
@@ -154,16 +156,15 @@ paths:
tags:
- "pet"
summary: "Find pet by ID"
- description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
- \ API error conditions"
+ description: "Returns a single pet"
operationId: "controllers.default_controller.get_pet_by_id"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "petId"
in: "path"
- description: "ID of pet that needs to be fetched"
+ description: "ID of pet to return"
required: true
type: "integer"
format: "int64"
@@ -178,9 +179,6 @@ paths:
description: "Pet not found"
security:
- api_key: []
- - petstore_auth:
- - "write:pets"
- - "read:pets"
x-tags:
- tag: "pet"
post:
@@ -192,14 +190,15 @@ paths:
consumes:
- "application/x-www-form-urlencoded"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be updated"
required: true
- type: "string"
+ type: "integer"
+ format: "int64"
- name: "name"
in: "formData"
description: "Updated name of the pet"
@@ -213,10 +212,6 @@ paths:
responses:
405:
description: "Invalid input"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
x-tags:
- tag: "pet"
delete:
@@ -226,12 +221,11 @@ paths:
description: ""
operationId: "controllers.default_controller.delete_pet"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "api_key"
in: "header"
- description: ""
required: false
type: "string"
- name: "petId"
@@ -242,11 +236,9 @@ paths:
format: "int64"
responses:
400:
- description: "Invalid pet value"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
+ description: "Invalid ID supplied"
+ 404:
+ description: "Pet not found"
x-tags:
- tag: "pet"
/pet/{petId}/uploadImage:
@@ -260,7 +252,6 @@ paths:
- "multipart/form-data"
produces:
- "application/json"
- - "application/xml"
parameters:
- name: "petId"
in: "path"
@@ -279,12 +270,10 @@ paths:
required: false
type: "file"
responses:
- default:
+ 200:
description: "successful operation"
- security:
- - petstore_auth:
- - "write:pets"
- - "read:pets"
+ schema:
+ $ref: "#/definitions/ApiResponse"
x-tags:
- tag: "pet"
/store/inventory:
@@ -296,7 +285,6 @@ paths:
operationId: "controllers.default_controller.get_inventory"
produces:
- "application/json"
- - "application/xml"
parameters: []
responses:
200:
@@ -318,13 +306,13 @@ paths:
description: ""
operationId: "controllers.default_controller.place_order"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- in: "body"
name: "body"
description: "order placed for purchasing the pet"
- required: false
+ required: true
schema:
$ref: "#/definitions/Order"
responses:
@@ -341,18 +329,21 @@ paths:
tags:
- "store"
summary: "Find purchase order by ID"
- description: "For valid response try integer IDs with value <= 5 or > 10. Other\
- \ values will generated exceptions"
+ description: "For valid response try integer IDs with value >= 1 and <= 10.\
+ \ Other values will generated exceptions"
operationId: "controllers.default_controller.get_order_by_id"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
- type: "string"
+ type: "integer"
+ maximum: 10.0
+ minimum: 1.0
+ format: "int64"
responses:
200:
description: "successful operation"
@@ -368,18 +359,20 @@ paths:
tags:
- "store"
summary: "Delete purchase order by ID"
- description: "For valid response try integer IDs with value < 1000. Anything\
- \ above 1000 or nonintegers will generate API errors"
+ description: "For valid response try integer IDs with positive integer value.\
+ \ Negative or non-integer values will generate API errors"
operationId: "controllers.default_controller.delete_order"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "orderId"
in: "path"
description: "ID of the order that needs to be deleted"
required: true
- type: "string"
+ type: "integer"
+ minimum: 1.0
+ format: "int64"
responses:
400:
description: "Invalid ID supplied"
@@ -395,13 +388,13 @@ paths:
description: "This can only be done by the logged in user."
operationId: "controllers.default_controller.create_user"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- in: "body"
name: "body"
description: "Created user object"
- required: false
+ required: true
schema:
$ref: "#/definitions/User"
responses:
@@ -417,13 +410,13 @@ paths:
description: ""
operationId: "controllers.default_controller.create_users_with_array_input"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
- required: false
+ required: true
schema:
type: "array"
items:
@@ -441,13 +434,13 @@ paths:
description: ""
operationId: "controllers.default_controller.create_users_with_list_input"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- in: "body"
name: "body"
description: "List of user object"
- required: false
+ required: true
schema:
type: "array"
items:
@@ -465,24 +458,33 @@ paths:
description: ""
operationId: "controllers.default_controller.login_user"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "username"
in: "query"
description: "The user name for login"
- required: false
+ required: true
type: "string"
- name: "password"
in: "query"
description: "The password for login in clear text"
- required: false
+ required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "string"
+ headers:
+ X-Rate-Limit:
+ type: "integer"
+ format: "int32"
+ description: "calls per hour allowed by the user"
+ X-Expires-After:
+ type: "string"
+ format: "date-time"
+ description: "date in UTC when token expires"
400:
description: "Invalid username/password supplied"
x-tags:
@@ -495,8 +497,8 @@ paths:
description: ""
operationId: "controllers.default_controller.logout_user"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters: []
responses:
default:
@@ -511,8 +513,8 @@ paths:
description: ""
operationId: "controllers.default_controller.get_user_by_name"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "username"
in: "path"
@@ -524,16 +526,6 @@ paths:
description: "successful operation"
schema:
$ref: "#/definitions/User"
- examples:
- application/json:
- id: 1
- username: "johnp"
- firstName: "John"
- lastName: "Public"
- email: "johnp@swagger.io"
- password: "-secret-"
- phone: "0123456789"
- userStatus: 0
400:
description: "Invalid username supplied"
404:
@@ -547,18 +539,18 @@ paths:
description: "This can only be done by the logged in user."
operationId: "controllers.default_controller.update_user"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "username"
in: "path"
- description: "name that need to be deleted"
+ description: "name that need to be updated"
required: true
type: "string"
- in: "body"
name: "body"
description: "Updated user object"
- required: false
+ required: true
schema:
$ref: "#/definitions/User"
responses:
@@ -575,8 +567,8 @@ paths:
description: "This can only be done by the logged in user."
operationId: "controllers.default_controller.delete_user"
produces:
- - "application/json"
- "application/xml"
+ - "application/json"
parameters:
- name: "username"
in: "path"
@@ -591,19 +583,40 @@ paths:
x-tags:
- tag: "user"
securityDefinitions:
- petstore_auth:
- type: "oauth2"
- authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
- flow: "implicit"
- scopes:
- write:pets: "modify pets in your account"
- read:pets: "read your pets"
api_key:
type: "apiKey"
name: "api_key"
in: "header"
definitions:
+ Order:
+ type: "object"
+ properties:
+ id:
+ type: "integer"
+ format: "int64"
+ petId:
+ type: "integer"
+ format: "int64"
+ quantity:
+ type: "integer"
+ format: "int32"
+ shipDate:
+ type: "string"
+ format: "date-time"
+ status:
+ type: "string"
+ description: "Order Status"
+ enum:
+ - "placed"
+ - "approved"
+ - "delivered"
+ complete:
+ type: "boolean"
+ default: false
+ xml:
+ name: "Order"
User:
+ type: "object"
properties:
id:
type: "integer"
@@ -627,6 +640,7 @@ definitions:
xml:
name: "User"
Category:
+ type: "object"
properties:
id:
type: "integer"
@@ -635,7 +649,28 @@ definitions:
type: "string"
xml:
name: "Category"
+ Tag:
+ type: "object"
+ properties:
+ id:
+ type: "integer"
+ format: "int64"
+ name:
+ type: "string"
+ xml:
+ name: "Tag"
+ ApiResponse:
+ type: "object"
+ properties:
+ code:
+ type: "integer"
+ format: "int32"
+ type:
+ type: "string"
+ message:
+ type: "string"
Pet:
+ type: "object"
required:
- "name"
- "photoUrls"
@@ -671,37 +706,6 @@ definitions:
- "sold"
xml:
name: "Pet"
- Tag:
- properties:
- id:
- type: "integer"
- format: "int64"
- name:
- type: "string"
- xml:
- name: "Tag"
- Order:
- properties:
- id:
- type: "integer"
- format: "int64"
- petId:
- type: "integer"
- format: "int64"
- quantity:
- type: "integer"
- format: "int32"
- shipDate:
- type: "string"
- format: "date-time"
- status:
- type: "string"
- description: "Order Status"
- enum:
- - "placed"
- - "approved"
- - "delivered"
- complete:
- type: "boolean"
- xml:
- name: "Order"
+externalDocs:
+ description: "Find out more about Swagger"
+ url: "http://swagger.io"
diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml
index 994b717dcfb5..9d4cd5dba171 100644
--- a/samples/server/petstore/spring-mvc/pom.xml
+++ b/samples/server/petstore/spring-mvc/pom.xml
@@ -75,31 +75,6 @@
slf4j-log4j12
${slf4j-version}
-
- com.sun.jersey
- jersey-core
- ${jersey-version}
-
-
- com.sun.jersey
- jersey-json
- ${jersey-version}
-
-
- com.sun.jersey
- jersey-servlet
- ${jersey-version}
-
-
- com.sun.jersey.contribs
- jersey-multipart
- ${jersey-version}
-
-
- com.sun.jersey
- jersey-server
- ${jersey-version}
-
@@ -142,22 +117,14 @@
${servlet-api-version}
-
-
- jcenter-snapshots
- jcenter
- http://oss.jfrog.org/artifactory/oss-snapshot-local/
-
-
- 1.5.4
+ 1.5.6
9.2.9.v20150224
1.13
1.6.3
- 1.6.1
4.8.1
2.5
- 2.0.4-SNAPSHOT
- 4.0.9.RELEASE
+ 2.3.1
+ 4.1.8.RELEASE
\ No newline at end of file
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java
index a6d35c09ac2b..7bb9e646046e 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java
@@ -1,6 +1,6 @@
package io.swagger.api;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java
index f76631e5b3e0..91a4f0c80def 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java
@@ -5,7 +5,7 @@ import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class ApiOriginFilter implements javax.servlet.Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java
index d3b5544f70ef..3a9edde1c870 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java
@@ -3,7 +3,7 @@ package io.swagger.api;
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java
index dfd7b6bd2d5c..0737abe7fb57 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java
@@ -1,6 +1,6 @@
package io.swagger.api;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {
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 38cc7aa30a61..20c6cface21d 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
@@ -4,11 +4,11 @@ import io.swagger.model.*;
import io.swagger.model.Pet;
import java.io.File;
+import io.swagger.model.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
@@ -32,27 +32,22 @@ import static org.springframework.http.MediaType.*;
@Controller
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/pet", description = "the pet API")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class PetApi {
- @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 400, message = "Invalid ID supplied"),
- @ApiResponse(code = 404, message = "Pet not found"),
- @ApiResponse(code = 405, message = "Validation exception") })
+ @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
+ @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception") })
@RequestMapping(value = "",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.PUT)
public ResponseEntity updatePet(
-@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body
+@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body
)
throws NotFoundException {
// do some magic!
@@ -61,21 +56,16 @@ public class PetApi {
- @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 405, message = "Invalid input") })
+ @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.POST)
public ResponseEntity addPet(
-@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body
+@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body
)
throws NotFoundException {
// do some magic!
@@ -84,20 +74,15 @@ public class PetApi {
- @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List", authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid status value") })
+ @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List")
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
@RequestMapping(value = "/findByStatus",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
- public ResponseEntity> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List status
+ public ResponseEntity> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List status
)
@@ -108,20 +93,15 @@ public class PetApi {
- @ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid tag value") })
+ @ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") })
@RequestMapping(value = "/findByTags",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
- public ResponseEntity> findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags
+ public ResponseEntity> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags
)
@@ -132,19 +112,19 @@ public class PetApi {
- @ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class, authorizations = {
+ @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
@Authorization(value = "api_key")
})
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid ID supplied"),
- @ApiResponse(code = 404, message = "Pet not found") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found") })
@RequestMapping(value = "/{petId}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity getPetById(
-@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId
+@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId
)
throws NotFoundException {
@@ -154,20 +134,15 @@ public class PetApi {
- @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 405, message = "Invalid input") })
+ @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/{petId}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
consumes = { "application/x-www-form-urlencoded" },
method = RequestMethod.POST)
public ResponseEntity updatePetWithForm(
-@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId
+@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId
,
@@ -187,16 +162,12 @@ public class PetApi {
- @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 400, message = "Invalid pet value") })
+ @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found") })
@RequestMapping(value = "/{petId}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
public ResponseEntity deletePet(
@@ -214,19 +185,14 @@ public class PetApi {
- @ApiOperation(value = "uploads an image", notes = "", response = Void.class, authorizations = {
- @Authorization(value = "petstore_auth", scopes = {
- @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
- @AuthorizationScope(scope = "read:pets", description = "read your pets")
- })
- })
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation") })
+ @ApiOperation(value = "uploads an image", notes = "", response = ApiResponse.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/{petId}/uploadImage",
- produces = { "application/json", "application/xml" },
+ produces = { "application/json" },
consumes = { "multipart/form-data" },
method = RequestMethod.POST)
- public ResponseEntity uploadFile(
+ public ResponseEntity uploadFile(
@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId
,
@@ -241,29 +207,7 @@ public class PetApi {
)
throws NotFoundException {
// do some magic!
- return new ResponseEntity(HttpStatus.OK);
- }
-
-
-
- @ApiOperation(value = "Fake endpoint to test byte array return by 'Find pet by ID'", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = byte[].class, authorizations = {
- @Authorization(value = "api_key")
- })
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid ID supplied"),
- @ApiResponse(code = 404, message = "Pet not found") })
- @RequestMapping(value = "/{petId}?testing_byte_array=true",
- produces = { "application/json", "application/xml" },
-
- method = RequestMethod.GET)
- public ResponseEntity getPetByIdWithByteArray(
-@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId
-
-)
- throws NotFoundException {
- // do some magic!
- return new ResponseEntity(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 75a13dd0aafa..1cf980306f67 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
@@ -8,7 +8,6 @@ import io.swagger.model.Order;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
@@ -32,17 +31,17 @@ import static org.springframework.http.MediaType.*;
@Controller
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/store", description = "the store API")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class StoreApi {
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
@Authorization(value = "api_key")
})
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/inventory",
- produces = { "application/json", "application/xml" },
+ produces = { "application/json" },
method = RequestMethod.GET)
public ResponseEntity> getInventory()
@@ -54,16 +53,16 @@ public class StoreApi {
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid Order") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") })
@RequestMapping(value = "/order",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity placeOrder(
-@ApiParam(value = "order placed for purchasing the pet" ) @RequestBody Order body
+@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body
)
throws NotFoundException {
// do some magic!
@@ -72,17 +71,17 @@ public class StoreApi {
- @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)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid ID supplied"),
- @ApiResponse(code = 404, message = "Order not found") })
+ @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions", response = Order.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found") })
@RequestMapping(value = "/order/{orderId}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity getOrderById(
-@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId
+@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId
)
throws NotFoundException {
@@ -92,16 +91,16 @@ public class StoreApi {
- @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 400, message = "Invalid ID supplied"),
- @ApiResponse(code = 404, message = "Order not found") })
+ @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors", response = Void.class)
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found") })
@RequestMapping(value = "/order/{orderId}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
public ResponseEntity deleteOrder(
-@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId
+@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") Long orderId
)
throws NotFoundException {
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 1266348cf118..3020c28afd7e 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
@@ -8,7 +8,6 @@ import java.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
@@ -32,20 +31,20 @@ import static org.springframework.http.MediaType.*;
@Controller
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/user", description = "the user API")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity createUser(
-@ApiParam(value = "Created user object" ) @RequestBody User body
+@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body
)
throws NotFoundException {
// do some magic!
@@ -55,15 +54,15 @@ public class UserApi {
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/createWithArray",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity createUsersWithArrayInput(
-@ApiParam(value = "List of user object" ) @RequestBody List body
+@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body
)
throws NotFoundException {
// do some magic!
@@ -73,15 +72,15 @@ public class UserApi {
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/createWithList",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity createUsersWithListInput(
-@ApiParam(value = "List of user object" ) @RequestBody List body
+@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body
)
throws NotFoundException {
// do some magic!
@@ -91,18 +90,18 @@ public class UserApi {
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid username/password supplied") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") })
@RequestMapping(value = "/login",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
- public ResponseEntity loginUser(@ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username
+ public ResponseEntity loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username
,
- @ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password
+ @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password
)
@@ -114,10 +113,10 @@ public class UserApi {
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/logout",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity logoutUser()
@@ -129,12 +128,12 @@ public class UserApi {
@ApiOperation(value = "Get user by user name", notes = "", response = User.class)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation"),
- @ApiResponse(code = 400, message = "Invalid username supplied"),
- @ApiResponse(code = 404, message = "User not found") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/{username}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity getUserByName(
@@ -149,20 +148,20 @@ public class UserApi {
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 400, message = "Invalid user supplied"),
- @ApiResponse(code = 404, message = "User not found") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/{username}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.PUT)
public ResponseEntity updateUser(
-@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username
+@ApiParam(value = "name that need to be updated",required=true ) @PathVariable("username") String username
,
-@ApiParam(value = "Updated user object" ) @RequestBody User body
+@ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body
)
throws NotFoundException {
// do some magic!
@@ -172,11 +171,11 @@ public class UserApi {
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
- @ApiResponses(value = {
- @ApiResponse(code = 400, message = "Invalid username supplied"),
- @ApiResponse(code = 404, message = "User not found") })
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/{username}",
- produces = { "application/json", "application/xml" },
+ produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
public ResponseEntity deleteUser(
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java
index 19a5638cb2aa..cff46e1da127 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java
@@ -18,13 +18,13 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2 //Loads the spring beans required by the framework
@PropertySource("classpath:swagger.properties")
@Import(SwaggerUiConfiguration.class)
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class SwaggerConfig {
@Bean
ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo(
"Swagger Petstore",
- "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
+ "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"1.0.0",
"",
"apiteam@swagger.io",
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java
index 27f222f151d3..ce587a0fe8a9 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java
@@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Configuration
@EnableWebMvc
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java
index fa2b92037093..ab01fffd026b 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java
@@ -2,7 +2,7 @@ package io.swagger.configuration;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java
index a82b4ba16815..6656ca9ecc83 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java
@@ -3,7 +3,7 @@ package io.swagger.configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java
new file mode 100644
index 000000000000..89364524a61c
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java
@@ -0,0 +1,90 @@
+package io.swagger.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonValue;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import io.swagger.annotations.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Objects;
+
+
+@ApiModel(description = "")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
+public class ApiResponse {
+
+ private Integer code = null;
+ private String type = null;
+ private String message = null;
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ @JsonProperty("code")
+ public Integer getCode() {
+ return code;
+ }
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ @JsonProperty("type")
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ @JsonProperty("message")
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ApiResponse apiResponse = (ApiResponse) o;
+ return Objects.equals(code, apiResponse.code) &&
+ Objects.equals(type, apiResponse.type) &&
+ Objects.equals(message, apiResponse.message);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(code, type, message);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ApiResponse {\n");
+
+ sb.append(" code: ").append(code).append("\n");
+ sb.append(" type: ").append(type).append("\n");
+ sb.append(" message: ").append(message).append("\n");
+ sb.append("}\n");
+ return sb.toString();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java
index 56502c5c5a7b..43439ffb4298 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java
@@ -12,7 +12,7 @@ import java.util.Objects;
@ApiModel(description = "")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class Category {
private Long id = null;
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java
index 7cbe08372814..84ca5e8cd8d7 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java
@@ -13,7 +13,7 @@ import java.util.Objects;
@ApiModel(description = "")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class Order {
private Long id = null;
@@ -24,7 +24,7 @@ public class Order {
placed, approved, delivered,
};
private StatusEnum status = null;
- private Boolean complete = null;
+ private Boolean complete = false;
/**
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java
index 87700ddce565..911c24cd4be3 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java
@@ -15,7 +15,7 @@ import java.util.Objects;
@ApiModel(description = "")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class Pet {
private Long id = null;
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java
index 5772279cc5e7..305c074c4202 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java
@@ -12,7 +12,7 @@ import java.util.Objects;
@ApiModel(description = "")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class Tag {
private Long id = null;
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java
index 82266688a2fb..9d4c0474b22a 100644
--- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java
@@ -12,7 +12,7 @@ import java.util.Objects;
@ApiModel(description = "")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-19T23:33:00.911+08:00")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-22T15:27:38.634-06:00")
public class User {
private Long id = null;