Merge remote-tracking branch 'origin/master' into 2.4.0

This commit is contained in:
wing328 2018-01-13 15:54:41 +08:00
commit 73c338be58
189 changed files with 1837 additions and 1265 deletions

View File

@ -86,11 +86,11 @@ script:
#- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
#after_success:
# push a snapshot version to maven repo
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_BRANCH" = "master" ]; then
mvn clean deploy --settings .travis/settings.xml;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
fi;
# # push a snapshot version to maven repo
# - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_BRANCH" = "master" ]; then
# mvn clean deploy --settings .travis/settings.xml;
# echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
# fi;
env:
- DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli

View File

@ -929,6 +929,7 @@ Presentations/Videos/Tutorials/Books
- 2017/12/07 - [API-driven development with OpenAPI and Swagger, Part 2](https://www.itworld.com/article/3199190/apis/api-driven-development-with-openapi-and-swagger-part-2.html) by Matthew Tyson
- 2017/12/29 - [REST APIs代码生成指南](https://gumroad.com/l/swagger_codegen_beginner_zh)(eBook) by [William Cheng](https://github.com/wing328), [Xin Meng](https://github.com/xmeng1)
- 2017/12/21 - [Using Protocol Buffer to Generate SDK at Hootsuite](http://code.hootsuite.com/using-protocol-buffer-to-generate-sdk-at-hoosuite/?lipi=urn%3Ali%3Apage%3Ad_flagship3_messaging%3By4ATz3SDRXyvXJJ14LQysQ%3D%3D) by [Joy Zhang](https://www.linkedin.com/in/joy8zhang/)
- 2018/01/11 - [Swagger 工具箱介绍及代码自动生成示例](https://github.com/qct/swagger-example) by [qct](https://github.com/qct)
# Swagger Codegen Core Team

View File

@ -26,6 +26,6 @@ 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 -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-vertx -o samples/server/petstore/java-vertx/rx -DvertxSwaggerRouterVersion=1.2.0,rxInterface=true"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l java-vertx --artifact-id swagger-java-vertx-rx-server -o samples/server/petstore/java-vertx/rx -DvertxSwaggerRouterVersion=1.2.0,rxInterface=true"
java $JAVA_OPTS -jar $executable $ags

View File

@ -1269,13 +1269,13 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
/**
* Output the Getter name for boolean property, e.g. isActive
* Output the partial Getter name for boolean property, e.g. Active
*
* @param name the name of the property
* @return getter name based on naming convention
* @return partial getter name based on naming convention
*/
public String toBooleanGetter(String name) {
return "is" + getterAndSetterCapitalize(name);
return getterAndSetterCapitalize(name);
}
@Override

View File

@ -6,6 +6,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.samskivert.mustache.Escapers;
import com.samskivert.mustache.Mustache;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.DefaultCodegen;
@ -44,7 +46,50 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
"Any",
"List",
"Seq",
"Map"));
"Map",
"Array"));
reservedWords.addAll(Arrays.asList(
"abstract",
"case",
"catch",
"class",
"def",
"do",
"else",
"extends",
"false",
"final",
"finally",
"for",
"forSome",
"if",
"implicit",
"import",
"lazy",
"match",
"new",
"null",
"object",
"override",
"package",
"private",
"protected",
"return",
"sealed",
"super",
"this",
"throw",
"trait",
"try",
"true",
"type",
"val",
"var",
"while",
"with",
"yield"
));
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
@ -80,7 +125,30 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "_" + name;
// Reserved words will be further escaped at the mustache compiler level.
// Scala escaping done here (via `, without compiler escaping) would otherwise be HTML encoded.
return "`" + name + "`";
}
@Override
public Mustache.Compiler processCompiler(Mustache.Compiler compiler) {
Mustache.Escaper SCALA = new Mustache.Escaper() {
@Override public String escape (String text) {
// Fix included as suggested by akkie in #6393
// The given text is a reserved word which is escaped by enclosing it with grave accents. If we would
// escape that with the default Mustache `HTML` escaper, then the escaper would also escape our grave
// accents. So we remove the grave accents before the escaping and add it back after the escaping.
if (text.startsWith("`") && text.endsWith("`")) {
String unescaped = text.substring(1, text.length() - 1);
return "`" + Escapers.HTML.escape(unescaped) + "`";
}
// All none reserved words will be escaped with the default Mustache `HTML` escaper
return Escapers.HTML.escape(text);
}
};
return compiler.withEscaper(SCALA);
}
@Override

View File

@ -5,7 +5,6 @@ import io.swagger.codegen.*;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
@ -97,6 +96,7 @@ public class ScalaClientCodegen extends AbstractScalaCodegen implements CodegenC
typeMapping.put("file", "File");
typeMapping.put("binary", "Array[Byte]");
typeMapping.put("ByteArray", "Array[Byte]");
typeMapping.put("ArrayByte", "Array[Byte]");
typeMapping.put("date-time", "Date");
typeMapping.put("DateTime", "Date");

View File

@ -15,7 +15,6 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.MultiPart;
@ -27,9 +26,11 @@ import java.io.InputStream;
{{^supportJava6}}
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import org.glassfish.jersey.logging.LoggingFeature;
{{/supportJava6}}
{{#supportJava6}}
import org.apache.commons.io.FileUtils;
import org.glassfish.jersey.filter.LoggingFilter;
{{/supportJava6}}
import java.util.Collection;
import java.util.Collections;
@ -771,10 +772,15 @@ public class ApiClient {
clientConfig.register(JacksonFeature.class);
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
if (debugging) {
{{^supportJava6}}
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
// Set logger to ALL
java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL);
{{/supportJava6}}
{{#supportJava6}}
clientConfig.register(new LoggingFilter(java.util.logging.Logger.getLogger(LoggingFilter.class.getName()), true));
{{/supportJava6}}
}
performAdditionalClientConfiguration(clientConfig);
return ClientBuilder.newClient(clientConfig);

View File

@ -107,11 +107,14 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.15"
jackson_version = "2.8.9"
jersey_version = "2.25.1"
{{#supportJava6}}
jersey_version = "2.6"
commons_io_version=2.5
commons_lang3_version=3.6
{{/supportJava6}}
{{^supportJava6}}
jersey_version = "2.25.1"
{{/supportJava6}}
junit_version = "4.12"
}

View File

@ -10,9 +10,9 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.15",
"org.glassfish.jersey.core" % "jersey-client" % "2.25.1",
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.25.1",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.25.1",
"org.glassfish.jersey.core" % "jersey-client" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"org.glassfish.jersey.media" % "jersey-media-multipart" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}},
"com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",

View File

@ -125,7 +125,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
public {{{datatypeWithEnum}}} {{getter}}() {
public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
{{^isReadOnly}}

View File

@ -42,7 +42,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -33,7 +33,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -64,16 +64,16 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isListContainer}}{{^isMapContainer}}public {{datatype}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isListContainer}}{{^isMapContainer}}public {{datatype}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
if ({{name}} == null) {
return null;
}
return {{name}}.value();
}{{/isMapContainer}}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isListContainer}}public {{{datatypeWithEnum}}} {{getter}}() {
}{{/isMapContainer}}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isListContainer}}public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isMapContainer}}public {{{datatypeWithEnum}}} {{getter}}() {
}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isMapContainer}}public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}{{/isMapContainer}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{getter}}() {
}{{/isMapContainer}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}{{/isEnum}}

View File

@ -85,7 +85,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
@JsonProperty("{{baseName}}")
{{/jackson}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
{{^isReadOnly}}

View File

@ -28,7 +28,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -28,7 +28,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -31,7 +31,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -83,7 +83,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}

View File

@ -87,7 +87,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}

View File

@ -19,8 +19,17 @@ public class {{classname}}Verticle extends AbstractVerticle {
{{#operations}}{{#operation}}{{#vendorExtensions}}final static String {{x-serviceid-varname}} = "{{x-serviceid}}";
{{/vendorExtensions}}{{/operation}}{{/operations}}
//TODO : create Implementation
{{classname}} service = new {{classname}}Impl();
final {{classname}} service;
public {{classname}}Verticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("{{package}}.{{classname}}Impl");
service = ({{classname}})serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("{{classname}}Verticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

View File

@ -20,7 +20,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vars}}
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -78,11 +78,11 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{/maximum}}
* @return {{name}}
**/
{{#vendorExtensions.extraAnnotation}}
{{#vendorExtensions.extraAnnotation}}
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
public {{{datatypeWithEnum}}} {{getter}}() {
public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
{{^isReadOnly}}

View File

@ -87,7 +87,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{{vendorExtensions.extraAnnotation}}}
{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}

View File

@ -22,7 +22,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {

View File

@ -715,7 +715,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.baseType, "Boolean");
Assert.assertTrue(cp.isNotContainer);
Assert.assertTrue(cp.isBoolean);
Assert.assertEquals(cp.getter, "isProperty");
Assert.assertEquals(cp.getter, "Property");
}
}
}

View File

@ -37,7 +37,8 @@ public class AbstractScalaCodegenTest {
String result = abstractScalaCodegen.formatIdentifier(className, true);
Assert.assertTrue("_ReservedWord".equals(result));
// NOTE: reserved words are further escaped at the compiler level.
Assert.assertTrue("`ReservedWord`".equals(result));
}
@Test

View File

@ -86,6 +86,7 @@ class HobbiesApi(
* Query hobbies with some additional optional meaningless parameters
*
* @param s a string (optional, default to some string)
* @param `class` a string, testing keyword escaping (optional, default to some string)
* @param i an integer (optional, default to 1)
* @param l a long (optional, default to 2)
* @param bool a bool (optional, default to true)
@ -97,8 +98,8 @@ class HobbiesApi(
* @param bin an octet string (optional, default to DEADBEEF)
* @return Hobby
*/
def getHobbies(s: Option[String] = Option("some string"), i: Option[Integer] = Option(1), l: Option[Long] = Option(2), bool: Option[Boolean] = Option(true), f: Option[Float] = Option(0.1), d: Option[Double] = Option(10.005), datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), b: Option[ArrayByte] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), bin: Option[ArrayByte] = Option("DEADBEEF".getBytes)): Option[Hobby] = {
val await = Try(Await.result(getHobbiesAsync(s, i, l, bool, f, d, datetime, date, b, bin), Duration.Inf))
def getHobbies(s: Option[String] = Option("some string"), `class`: Option[String] = Option("some string"), i: Option[Integer] = Option(1), l: Option[Long] = Option(2), bool: Option[Boolean] = Option(true), f: Option[Float] = Option(0.1), d: Option[Double] = Option(10.005), datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), b: Option[Array[Byte]] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), bin: Option[Array[Byte]] = Option("DEADBEEF".getBytes)): Option[Hobby] = {
val await = Try(Await.result(getHobbiesAsync(s, `class`, i, l, bool, f, d, datetime, date, b, bin), Duration.Inf))
await match {
case Success(i) => Some(await.get)
case Failure(t) => None
@ -110,6 +111,7 @@ class HobbiesApi(
* Query hobbies with some additional optional meaningless parameters
*
* @param s a string (optional, default to some string)
* @param `class` a string, testing keyword escaping (optional, default to some string)
* @param i an integer (optional, default to 1)
* @param l a long (optional, default to 2)
* @param bool a bool (optional, default to true)
@ -121,8 +123,8 @@ class HobbiesApi(
* @param bin an octet string (optional, default to DEADBEEF)
* @return Future(Hobby)
*/
def getHobbiesAsync(s: Option[String] = Option("some string"), i: Option[Integer] = Option(1), l: Option[Long] = Option(2), bool: Option[Boolean] = Option(true), f: Option[Float] = Option(0.1), d: Option[Double] = Option(10.005), datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), b: Option[ArrayByte] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), bin: Option[ArrayByte] = Option("DEADBEEF".getBytes)): Future[Hobby] = {
helper.getHobbies(s, i, l, bool, f, d, datetime, date, b, bin)
def getHobbiesAsync(s: Option[String] = Option("some string"), `class`: Option[String] = Option("some string"), i: Option[Integer] = Option(1), l: Option[Long] = Option(2), bool: Option[Boolean] = Option(true), f: Option[Float] = Option(0.1), d: Option[Double] = Option(10.005), datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), b: Option[Array[Byte]] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), bin: Option[Array[Byte]] = Option("DEADBEEF".getBytes)): Future[Hobby] = {
helper.getHobbies(s, `class`, i, l, bool, f, d, datetime, date, b, bin)
}
}
@ -130,6 +132,7 @@ class HobbiesApi(
class HobbiesApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
def getHobbies(s: Option[String] = Option("some string"),
`class`: Option[String] = Option("some string"),
i: Option[Integer] = Option(1),
l: Option[Long] = Option(2),
bool: Option[Boolean] = Option(true),
@ -137,8 +140,8 @@ class HobbiesApiAsyncHelper(client: TransportClient, config: SwaggerConfig) exte
d: Option[Double] = Option(10.005),
datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")),
date: Option[Date] = Option(dateFormatter.parse("2018-01-01")),
b: Option[ArrayByte] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes),
bin: Option[ArrayByte] = Option("DEADBEEF".getBytes)
b: Option[Array[Byte]] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes),
bin: Option[Array[Byte]] = Option("DEADBEEF".getBytes)
)(implicit reader: ClientResponseReader[Hobby]): Future[Hobby] = {
// create path and map variables
val path = (addFmt("/hobbies"))
@ -151,6 +154,10 @@ class HobbiesApiAsyncHelper(client: TransportClient, config: SwaggerConfig) exte
case Some(param) => queryParams += "s" -> param.toString
case _ => queryParams
}
`class` match {
case Some(param) => queryParams += "class" -> param.toString
case _ => queryParams
}
i match {
case Some(param) => queryParams += "i" -> param.toString
case _ => queryParams

View File

@ -23,7 +23,7 @@ case class Hobby (
enabled: Option[Boolean] = None,
created: Option[Date] = None,
timestamp: Option[Date] = None,
bytes: Option[ArrayByte] = None,
bytes: Option[Array[Byte]] = None,
binary: Option[String] = None
)

View File

@ -167,6 +167,14 @@
"in": "query",
"default": "some string"
},
{
"type": "string",
"description": "a string, testing keyword escaping",
"name": "class",
"required": false,
"in": "query",
"default": "some string"
},
{
"type": "integer",
"format": "int32",

View File

@ -843,8 +843,10 @@
<!-- test non-java projects -->
<module>samples/client/petstore/go</module>
<!-- servers -->
<module>samples/server/petstore/java-vertx/rx</module>
<module>samples/server/petstore/java-vertx/async</module>
<module>samples/server/petstore/java-inflector</module>
<module>samples/server/petstore/java-pkmst</module>
<module>samples/server/petstore/java-pkmst</module>
<module>samples/server/petstore/java-play-framework</module>
<module>samples/server/petstore/undertow</module>
<module>samples/server/petstore/jaxrs/jersey1</module>

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1,4 +1,4 @@
# swagger-petstore-jersey2
# swagger-petstore-jersey2-java6
## Requirements
@ -27,7 +27,7 @@ Add this dependency to your project's POM:
```xml
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-petstore-jersey2</artifactId>
<artifactId>swagger-petstore-jersey2-java6</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
@ -38,7 +38,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:
```groovy
compile "io.swagger:swagger-petstore-jersey2:1.0.0"
compile "io.swagger:swagger-petstore-jersey2-java6:1.0.0"
```
### Others
@ -49,7 +49,7 @@ At first generate the JAR by executing:
Then manually install the following JARs:
* target/swagger-petstore-jersey2-1.0.0.jar
* target/swagger-petstore-jersey2-java6-1.0.0.jar
* target/lib/*.jar
## Getting Started
@ -61,22 +61,22 @@ Please follow the [installation](#installation) instruction and execute the foll
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.FakeApi;
import io.swagger.client.api.AnotherFakeApi;
import java.io.File;
import java.util.*;
public class FakeApiExample {
public class AnotherFakeApiExample {
public static void main(String[] args) {
FakeApi apiInstance = new FakeApi();
AnotherFakeApi apiInstance = new AnotherFakeApi();
Client body = new Client(); // Client | client model
try {
Client result = apiInstance.testClientModel(body);
Client result = apiInstance.testSpecialTags(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testClientModel");
System.err.println("Exception when calling AnotherFakeApi#testSpecialTags");
e.printStackTrace();
}
}
@ -86,13 +86,21 @@ public class FakeApiExample {
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**testSpecialTags**](docs/AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
@ -101,9 +109,9 @@ Class | Method | HTTP request | Description
*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
@ -123,10 +131,10 @@ Class | Method | HTTP request | Description
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [ArrayTest](docs/ArrayTest.md)
- [Cat](docs/Cat.md)
- [Capitalization](docs/Capitalization.md)
- [Category](docs/Category.md)
- [ClassModel](docs/ClassModel.md)
- [Client](docs/Client.md)
- [Dog](docs/Dog.md)
- [EnumArrays](docs/EnumArrays.md)
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
@ -140,11 +148,15 @@ Class | Method | HTTP request | Description
- [Name](docs/Name.md)
- [NumberOnly](docs/NumberOnly.md)
- [Order](docs/Order.md)
- [OuterComposite](docs/OuterComposite.md)
- [OuterEnum](docs/OuterEnum.md)
- [Pet](docs/Pet.md)
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [SpecialModelName](docs/SpecialModelName.md)
- [Tag](docs/Tag.md)
- [User](docs/User.md)
- [Cat](docs/Cat.md)
- [Dog](docs/Dog.md)
## Documentation for Authorization
@ -156,6 +168,12 @@ Authentication schemes defined for the API:
- **API key parameter name**: api_key
- **Location**: HTTP header
### api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
### http_basic_test
- **Type**: HTTP basic authentication

View File

@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.15"
jackson_version = "2.8.9"
jersey_version = "2.25.1"
jersey_version = "2.6"
commons_io_version=2.5
commons_lang3_version=3.6
junit_version = "4.12"

View File

@ -10,9 +10,9 @@ lazy val root = (project in file(".")).
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.15",
"org.glassfish.jersey.core" % "jersey-client" % "2.25.1",
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.25.1",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.25.1",
"org.glassfish.jersey.core" % "jersey-client" % "2.6",
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.6",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.6",
"com.fasterxml.jackson.core" % "jackson-core" % "2.6.4" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.6.4" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.6.4" % "compile",

View File

@ -15,7 +15,6 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.MultiPart;
@ -25,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.FileUtils;
import org.glassfish.jersey.filter.LoggingFilter;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@ -761,10 +761,7 @@ public class ApiClient {
clientConfig.register(JacksonFeature.class);
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
// Set logger to ALL
java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL);
clientConfig.register(new LoggingFilter(java.util.logging.Logger.getLogger(LoggingFilter.class.getName()), true));
}
performAdditionalClientConfiguration(clientConfig);
return ClientBuilder.newClient(clientConfig);

View File

@ -8,29 +8,19 @@
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client.api;
import io.swagger.client.ApiException;
import io.swagger.client.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import io.swagger.client.model.Client;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import io.swagger.client.model.OuterComposite;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.HashMap;
@ -40,15 +30,80 @@ import java.util.Map;
/**
* API tests for FakeApi
*/
@Ignore
public class FakeApiTest {
private final FakeApi api = new FakeApi();
/**
*
*
* Test serialization of outer boolean types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterBooleanSerializeTest() throws ApiException {
Boolean body = null;
Boolean response = api.fakeOuterBooleanSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of object with outer number type
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterCompositeSerializeTest() throws ApiException {
OuterComposite body = null;
OuterComposite response = api.fakeOuterCompositeSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of outer number types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterNumberSerializeTest() throws ApiException {
BigDecimal body = null;
BigDecimal response = api.fakeOuterNumberSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of outer string types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterStringSerializeTest() throws ApiException {
String body = null;
String response = api.fakeOuterStringSerialize(body);
// TODO: test validations
}
/**
* To test \&quot;client\&quot; model
*
*
* To test \&quot;client\&quot; model
*
* @throws ApiException
* if the Api call fails
@ -56,7 +111,7 @@ public class FakeApiTest {
@Test
public void testClientModelTest() throws ApiException {
Client body = null;
// Client response = api.testClientModel(body);
Client response = api.testClientModel(body);
// TODO: test validations
}
@ -82,10 +137,10 @@ public class FakeApiTest {
String string = null;
byte[] binary = null;
LocalDate date = null;
DateTime dateTime = null;
OffsetDateTime dateTime = null;
String password = null;
String paramCallback = null;
// api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
// TODO: test validations
}
@ -93,7 +148,7 @@ public class FakeApiTest {
/**
* To test enum parameters
*
*
* To test enum parameters
*
* @throws ApiException
* if the Api call fails
@ -106,9 +161,42 @@ public class FakeApiTest {
String enumHeaderString = null;
List<String> enumQueryStringArray = null;
String enumQueryString = null;
BigDecimal enumQueryInteger = null;
Integer enumQueryInteger = null;
Double enumQueryDouble = null;
// api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
// TODO: test validations
}
/**
* test inline additionalProperties
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testInlineAdditionalPropertiesTest() throws ApiException {
Object param = null;
api.testInlineAdditionalProperties(param);
// TODO: test validations
}
/**
* test json serialization of form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testJsonFormDataTest() throws ApiException {
String param = null;
String param2 = null;
api.testJsonFormData(param, param2);
// TODO: test validations
}

View File

@ -8,28 +8,17 @@
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client.api;
import io.swagger.client.ApiException;
import io.swagger.client.model.Pet;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
import io.swagger.client.model.Pet;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.HashMap;
@ -39,6 +28,7 @@ import java.util.Map;
/**
* API tests for PetApi
*/
@Ignore
public class PetApiTest {
private final PetApi api = new PetApi();
@ -55,7 +45,7 @@ public class PetApiTest {
@Test
public void addPetTest() throws ApiException {
Pet body = null;
// api.addPet(body);
api.addPet(body);
// TODO: test validations
}
@ -72,7 +62,7 @@ public class PetApiTest {
public void deletePetTest() throws ApiException {
Long petId = null;
String apiKey = null;
// api.deletePet(petId, apiKey);
api.deletePet(petId, apiKey);
// TODO: test validations
}
@ -88,7 +78,7 @@ public class PetApiTest {
@Test
public void findPetsByStatusTest() throws ApiException {
List<String> status = null;
// List<Pet> response = api.findPetsByStatus(status);
List<Pet> response = api.findPetsByStatus(status);
// TODO: test validations
}
@ -104,7 +94,7 @@ public class PetApiTest {
@Test
public void findPetsByTagsTest() throws ApiException {
List<String> tags = null;
// List<Pet> response = api.findPetsByTags(tags);
List<Pet> response = api.findPetsByTags(tags);
// TODO: test validations
}
@ -120,7 +110,7 @@ public class PetApiTest {
@Test
public void getPetByIdTest() throws ApiException {
Long petId = null;
// Pet response = api.getPetById(petId);
Pet response = api.getPetById(petId);
// TODO: test validations
}
@ -136,7 +126,7 @@ public class PetApiTest {
@Test
public void updatePetTest() throws ApiException {
Pet body = null;
// api.updatePet(body);
api.updatePet(body);
// TODO: test validations
}
@ -154,7 +144,7 @@ public class PetApiTest {
Long petId = null;
String name = null;
String status = null;
// api.updatePetWithForm(petId, name, status);
api.updatePetWithForm(petId, name, status);
// TODO: test validations
}
@ -172,7 +162,7 @@ public class PetApiTest {
Long petId = null;
String additionalMetadata = null;
File file = null;
// ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
// TODO: test validations
}

View File

@ -8,18 +8,6 @@
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@ -28,6 +16,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiException;
import io.swagger.client.model.Order;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.HashMap;
@ -37,6 +26,7 @@ import java.util.Map;
/**
* API tests for StoreApi
*/
@Ignore
public class StoreApiTest {
private final StoreApi api = new StoreApi();
@ -53,7 +43,7 @@ public class StoreApiTest {
@Test
public void deleteOrderTest() throws ApiException {
String orderId = null;
// api.deleteOrder(orderId);
api.deleteOrder(orderId);
// TODO: test validations
}
@ -68,7 +58,7 @@ public class StoreApiTest {
*/
@Test
public void getInventoryTest() throws ApiException {
// Map<String, Integer> response = api.getInventory();
Map<String, Integer> response = api.getInventory();
// TODO: test validations
}
@ -84,7 +74,7 @@ public class StoreApiTest {
@Test
public void getOrderByIdTest() throws ApiException {
Long orderId = null;
// Order response = api.getOrderById(orderId);
Order response = api.getOrderById(orderId);
// TODO: test validations
}
@ -100,7 +90,7 @@ public class StoreApiTest {
@Test
public void placeOrderTest() throws ApiException {
Order body = null;
// Order response = api.placeOrder(body);
Order response = api.placeOrder(body);
// TODO: test validations
}

View File

@ -8,18 +8,6 @@
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@ -28,6 +16,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiException;
import io.swagger.client.model.User;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.HashMap;
@ -37,6 +26,7 @@ import java.util.Map;
/**
* API tests for UserApi
*/
@Ignore
public class UserApiTest {
private final UserApi api = new UserApi();
@ -53,7 +43,7 @@ public class UserApiTest {
@Test
public void createUserTest() throws ApiException {
User body = null;
// api.createUser(body);
api.createUser(body);
// TODO: test validations
}
@ -69,7 +59,7 @@ public class UserApiTest {
@Test
public void createUsersWithArrayInputTest() throws ApiException {
List<User> body = null;
// api.createUsersWithArrayInput(body);
api.createUsersWithArrayInput(body);
// TODO: test validations
}
@ -85,7 +75,7 @@ public class UserApiTest {
@Test
public void createUsersWithListInputTest() throws ApiException {
List<User> body = null;
// api.createUsersWithListInput(body);
api.createUsersWithListInput(body);
// TODO: test validations
}
@ -101,7 +91,7 @@ public class UserApiTest {
@Test
public void deleteUserTest() throws ApiException {
String username = null;
// api.deleteUser(username);
api.deleteUser(username);
// TODO: test validations
}
@ -117,7 +107,7 @@ public class UserApiTest {
@Test
public void getUserByNameTest() throws ApiException {
String username = null;
// User response = api.getUserByName(username);
User response = api.getUserByName(username);
// TODO: test validations
}
@ -134,7 +124,7 @@ public class UserApiTest {
public void loginUserTest() throws ApiException {
String username = null;
String password = null;
// String response = api.loginUser(username, password);
String response = api.loginUser(username, password);
// TODO: test validations
}
@ -149,7 +139,7 @@ public class UserApiTest {
*/
@Test
public void logoutUserTest() throws ApiException {
// api.logoutUser();
api.logoutUser();
// TODO: test validations
}
@ -166,7 +156,7 @@ public class UserApiTest {
public void updateUserTest() throws ApiException {
String username = null;
User body = null;
// api.updateUser(username, body);
api.updateUser(username, body);
// TODO: test validations
}

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -61,32 +61,22 @@ Please follow the [installation](#installation) instruction and execute the foll
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.FakeApi;
import io.swagger.client.api.AnotherFakeApi;
import java.io.File;
import java.util.*;
public class FakeApiExample {
public class AnotherFakeApiExample {
public static void main(String[] args) {
FakeApi apiInstance = new FakeApi();
BigDecimal number = new BigDecimal(); // BigDecimal | None
Double _double = 3.4D; // Double | None
String string = "string_example"; // String | None
byte[] _byte = B; // byte[] | None
Integer integer = 56; // Integer | None
Integer int32 = 56; // Integer | None
Long int64 = 789L; // Long | None
Float _float = 3.4F; // Float | None
byte[] binary = B; // byte[] | None
LocalDate date = new LocalDate(); // LocalDate | None
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
String password = "password_example"; // String | None
AnotherFakeApi apiInstance = new AnotherFakeApi();
Client body = new Client(); // Client | client model
try {
apiInstance.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
Client result = apiInstance.testSpecialTags(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEndpointParameters");
System.err.println("Exception when calling AnotherFakeApi#testSpecialTags");
e.printStackTrace();
}
}
@ -96,11 +86,21 @@ public class FakeApiExample {
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**testSpecialTags**](docs/AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
@ -109,9 +109,9 @@ Class | Method | HTTP request | Description
*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
@ -128,29 +128,56 @@ Class | Method | HTTP request | Description
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [Animal](docs/Animal.md)
- [AnimalFarm](docs/AnimalFarm.md)
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [ArrayTest](docs/ArrayTest.md)
- [Cat](docs/Cat.md)
- [Capitalization](docs/Capitalization.md)
- [Category](docs/Category.md)
- [Dog](docs/Dog.md)
- [ClassModel](docs/ClassModel.md)
- [Client](docs/Client.md)
- [EnumArrays](docs/EnumArrays.md)
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
- [FormatTest](docs/FormatTest.md)
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model200Response](docs/Model200Response.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [ModelReturn](docs/ModelReturn.md)
- [Name](docs/Name.md)
- [NumberOnly](docs/NumberOnly.md)
- [Order](docs/Order.md)
- [OuterComposite](docs/OuterComposite.md)
- [OuterEnum](docs/OuterEnum.md)
- [Pet](docs/Pet.md)
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [SpecialModelName](docs/SpecialModelName.md)
- [Tag](docs/Tag.md)
- [User](docs/User.md)
- [Cat](docs/Cat.md)
- [Dog](docs/Dog.md)
## Documentation for Authorization
Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
### http_basic_test
- **Type**: HTTP basic authentication
### petstore_auth
- **Type**: OAuth
@ -160,16 +187,10 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account
- read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Recommendation
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue.
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
## Author

View File

@ -15,7 +15,6 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.MultiPart;
@ -26,6 +25,7 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import org.glassfish.jersey.logging.LoggingFeature;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;

View File

@ -1,6 +1,6 @@
/**
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
@ -8,28 +8,19 @@
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client.api;
import io.swagger.client.ApiException;
import java.time.OffsetDateTime;
import java.time.LocalDate;
import java.math.BigDecimal;
import io.swagger.client.model.Client;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import io.swagger.client.model.OuterComposite;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.HashMap;
@ -39,11 +30,92 @@ import java.util.Map;
/**
* API tests for FakeApi
*/
@Ignore
public class FakeApiTest {
private final FakeApi api = new FakeApi();
/**
*
*
* Test serialization of outer boolean types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterBooleanSerializeTest() throws ApiException {
Boolean body = null;
Boolean response = api.fakeOuterBooleanSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of object with outer number type
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterCompositeSerializeTest() throws ApiException {
OuterComposite body = null;
OuterComposite response = api.fakeOuterCompositeSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of outer number types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterNumberSerializeTest() throws ApiException {
BigDecimal body = null;
BigDecimal response = api.fakeOuterNumberSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of outer string types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterStringSerializeTest() throws ApiException {
String body = null;
String response = api.fakeOuterStringSerialize(body);
// TODO: test validations
}
/**
* To test \&quot;client\&quot; model
*
* To test \&quot;client\&quot; model
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testClientModelTest() throws ApiException {
Client body = null;
Client response = api.testClientModel(body);
// TODO: test validations
}
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*
@ -56,17 +128,75 @@ public class FakeApiTest {
public void testEndpointParametersTest() throws ApiException {
BigDecimal number = null;
Double _double = null;
String string = null;
String patternWithoutDelimiter = null;
byte[] _byte = null;
Integer integer = null;
Integer int32 = null;
Long int64 = null;
Float _float = null;
String string = null;
byte[] binary = null;
LocalDate date = null;
OffsetDateTime dateTime = null;
String password = null;
// api.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
String paramCallback = null;
api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
// TODO: test validations
}
/**
* To test enum parameters
*
* To test enum parameters
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testEnumParametersTest() throws ApiException {
List<String> enumFormStringArray = null;
String enumFormString = null;
List<String> enumHeaderStringArray = null;
String enumHeaderString = null;
List<String> enumQueryStringArray = null;
String enumQueryString = null;
Integer enumQueryInteger = null;
Double enumQueryDouble = null;
api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
// TODO: test validations
}
/**
* test inline additionalProperties
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testInlineAdditionalPropertiesTest() throws ApiException {
Object param = null;
api.testInlineAdditionalProperties(param);
// TODO: test validations
}
/**
* test json serialization of form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testJsonFormDataTest() throws ApiException {
String param = null;
String param2 = null;
api.testJsonFormData(param, param2);
// TODO: test validations
}

View File

@ -1,288 +1,170 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.TestUtils;
import io.swagger.client.*;
import io.swagger.client.api.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.io.BufferedWriter;
import io.swagger.client.ApiException;
import java.io.File;
import java.io.FileWriter;
import io.swagger.client.model.ModelApiResponse;
import io.swagger.client.model.Pet;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.*;
import static org.junit.Assert.*;
/**
* API tests for PetApi
*/
@Ignore
public class PetApiTest {
PetApi api = null;
@Before
public void setup() {
api = new PetApi();
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
}
private final PetApi api = new PetApi();
/**
* Add a new pet to the store
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testApiClient() {
// the default api client is used
assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());
public void addPetTest() throws ApiException {
Pet body = null;
api.addPet(body);
ApiClient oldClient = api.getApiClient();
ApiClient newClient = new ApiClient();
newClient.setBasePath("http://example.com");
newClient.setDebugging(true);
// set api client via constructor
api = new PetApi(newClient);
assertNotNull(api.getApiClient());
assertEquals("http://example.com", api.getApiClient().getBasePath());
assertTrue(api.getApiClient().isDebugging());
// set api client via setter method
api.setApiClient(oldClient);
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());
// TODO: test validations
}
/**
* Deletes a pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateAndGetPet() throws Exception {
Pet pet = createRandomPet();
api.addPet(pet);
public void deletePetTest() throws ApiException {
Long petId = null;
String apiKey = null;
api.deletePet(petId, apiKey);
Pet fetched = api.getPetById(pet.getId());
assertNotNull(fetched);
assertEquals(pet.getId(), fetched.getId());
assertNotNull(fetched.getCategory());
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
// TODO: test validations
}
/*
/**
* Finds Pets by status
*
* Multiple status values can be provided with comma separated strings
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateAndGetPetWithByteArray() throws Exception {
Pet pet = createRandomPet();
byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes();
api.addPetUsingByteArray(bytes);
public void findPetsByStatusTest() throws ApiException {
List<String> status = null;
List<Pet> response = api.findPetsByStatus(status);
byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(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());
// TODO: test validations
}
/**
* Finds Pets by tags
*
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testGetPetByIdInObject() throws Exception {
Pet pet = new Pet();
pet.setId(TestUtils.nextId());
pet.setName("pet " + pet.getId());
public void findPetsByTagsTest() throws ApiException {
List<String> tags = null;
List<Pet> response = api.findPetsByTags(tags);
Category category = new Category();
category.setId(TestUtils.nextId());
category.setName("category " + category.getId());
pet.setCategory(category);
pet.setStatus(Pet.StatusEnum.PENDING);
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1"});
pet.setPhotoUrls(photos);
api.addPet(pet);
InlineResponse200 fetched = api.getPetByIdInObject(pet.getId());
assertEquals(pet.getId(), fetched.getId());
assertEquals(pet.getName(), fetched.getName());
Object categoryObj = fetched.getCategory();
assertNotNull(categoryObj);
assertTrue(categoryObj instanceof Map);
Map categoryMap = (Map) categoryObj;
Object categoryIdObj = categoryMap.get("id");
assertTrue(categoryIdObj instanceof Integer);
Integer categoryIdInt = (Integer) categoryIdObj;
assertEquals(category.getId(), Long.valueOf(categoryIdInt));
assertEquals(category.getName(), categoryMap.get("name"));
// TODO: test validations
}
*/
/**
* Find pet by ID
*
* Returns a single pet
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testUpdatePet() throws Exception {
Pet pet = createRandomPet();
pet.setName("programmer");
public void getPetByIdTest() throws ApiException {
Long petId = null;
Pet response = api.getPetById(petId);
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());
// TODO: test validations
}
/**
* Update an existing pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testFindPetsByStatus() throws Exception {
Pet pet = createRandomPet();
pet.setName("programmer");
pet.setStatus(Pet.StatusEnum.AVAILABLE);
public void updatePetTest() throws ApiException {
Pet body = null;
api.updatePet(body);
api.updatePet(pet);
List<Pet> 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);
// TODO: test validations
}
/**
* Updates a pet in the store with form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testFindPetsByTags() throws Exception {
Pet pet = createRandomPet();
pet.setName("monster");
pet.setStatus(Pet.StatusEnum.AVAILABLE);
public void updatePetWithFormTest() throws ApiException {
Long petId = null;
String name = null;
String status = null;
api.updatePetWithForm(petId, name, status);
List<Tag> tags = new ArrayList<Tag>();
Tag tag1 = new Tag();
tag1.setName("friendly");
tags.add(tag1);
pet.setTags(tags);
api.updatePet(pet);
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
assertNotNull(pets);
boolean found = false;
for (Pet fetched : pets) {
if (fetched.getId().equals(pet.getId())) {
found = true;
break;
}
}
assertTrue(found);
// TODO: test validations
}
/**
* uploads an image
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testUpdatePetWithForm() throws Exception {
Pet pet = createRandomPet();
pet.setName("frank");
api.addPet(pet);
public void uploadFileTest() throws ApiException {
Long petId = null;
String additionalMetadata = null;
File file = null;
ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
Pet fetched = api.getPetById(pet.getId());
api.updatePetWithForm(fetched.getId(), "furt", null);
Pet updated = api.getPetById(fetched.getId());
assertEquals(updated.getName(), "furt");
}
@Test
public void testDeletePet() 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 testUploadFile() 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()));
}
@Test
public void testEqualsAndHashCode() {
Pet pet1 = new Pet();
Pet pet2 = new Pet();
assertTrue(pet1.equals(pet2));
assertTrue(pet2.equals(pet1));
assertTrue(pet1.hashCode() == pet2.hashCode());
assertTrue(pet1.equals(pet1));
assertTrue(pet1.hashCode() == pet1.hashCode());
pet2.setName("really-happy");
pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
assertFalse(pet1.equals(pet2));
assertFalse(pet2.equals(pet1));
assertFalse(pet1.hashCode() == (pet2.hashCode()));
assertTrue(pet2.equals(pet2));
assertTrue(pet2.hashCode() == pet2.hashCode());
pet1.setName("really-happy");
pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
assertTrue(pet1.equals(pet2));
assertTrue(pet2.equals(pet1));
assertTrue(pet1.hashCode() == pet2.hashCode());
assertTrue(pet1.equals(pet1));
assertTrue(pet1.hashCode() == pet1.hashCode());
}
private Pet createRandomPet() {
Pet pet = new Pet();
pet.setId(TestUtils.nextId());
pet.setName("gorilla");
Category category = new Category();
category.setName("really-happy");
pet.setCategory(category);
pet.setStatus(Pet.StatusEnum.AVAILABLE);
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
pet.setPhotoUrls(photos);
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> T deserializeJson(String json, Class<T> klass, ApiClient apiClient) {
ObjectMapper mapper = apiClient.getJSON().getContext(null);
try {
return mapper.readValue(json, klass);
} catch (Exception e) {
throw new RuntimeException(e);
}
// TODO: test validations
}
}

View File

@ -1,101 +1,98 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import io.swagger.TestUtils;
import io.swagger.client.ApiException;
import io.swagger.client.model.Order;
import org.junit.Test;
import org.junit.Ignore;
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.lang.reflect.Field;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.time.OffsetDateTime;
import org.junit.*;
import static org.junit.Assert.*;
/**
* API tests for StoreApi
*/
@Ignore
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"));
}
private final StoreApi api = new StoreApi();
/**
* Delete purchase order by ID
*
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testGetInventory() throws Exception {
Map<String, Integer> inventory = api.getInventory();
assertTrue(inventory.keySet().size() > 0);
}
public void deleteOrderTest() throws ApiException {
String orderId = null;
api.deleteOrder(orderId);
/*
// TODO: test validations
}
/**
* Returns pet inventories by status
*
* Returns a map of status codes to quantities
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testGetInventoryInObject() throws Exception {
Object inventoryObj = api.getInventoryInObject();
assertTrue(inventoryObj instanceof Map);
public void getInventoryTest() throws ApiException {
Map<String, Integer> response = api.getInventory();
Map inventoryMap = (Map) inventoryObj;
assertTrue(inventoryMap.keySet().size() > 0);
Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next();
assertTrue(firstEntry.getKey() instanceof String);
assertTrue(firstEntry.getValue() instanceof Integer);
// TODO: test validations
}
*/
/**
* Find purchase order by ID
*
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testPlaceOrder() throws Exception {
Order order = createOrder();
api.placeOrder(order);
public void getOrderByIdTest() throws ApiException {
Long orderId = null;
Order response = api.getOrderById(orderId);
Order fetched = api.getOrderById(order.getId());
assertEquals(order.getId(), fetched.getId());
assertEquals(order.getPetId(), fetched.getPetId());
assertEquals(order.getQuantity(), fetched.getQuantity());
assertEquals(order.getShipDate().toInstant(), fetched.getShipDate().toInstant());
// TODO: test validations
}
/**
* Place an order for a pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testDeleteOrder() throws Exception {
Order order = createOrder();
api.placeOrder(order);
public void placeOrderTest() throws ApiException {
Order body = null;
Order response = api.placeOrder(body);
Order fetched = api.getOrderById(order.getId());
assertEquals(fetched.getId(), order.getId());
api.deleteOrder(String.valueOf(order.getId()));
try {
api.getOrderById(order.getId());
// fail("expected an error");
} catch (ApiException e) {
// ok
}
}
private Order createOrder() {
Order order = new Order();
order.setPetId(200L);
order.setQuantity(13);
//Ensure 3 fractional digits because of a bug in the petstore server
order.setShipDate(OffsetDateTime.now().withNano(123000000));
order.setStatus(Order.StatusEnum.PLACED);
order.setComplete(true);
try {
Field idField = Order.class.getDeclaredField("id");
idField.setAccessible(true);
idField.set(order, TestUtils.nextId());
} catch (Exception e) {
throw new RuntimeException(e);
}
return order;
// TODO: test validations
}
}

View File

@ -1,88 +1,164 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import io.swagger.TestUtils;
import io.swagger.client.ApiException;
import io.swagger.client.model.User;
import org.junit.Test;
import org.junit.Ignore;
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.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* API tests for UserApi
*/
@Ignore
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");
}
private final UserApi api = new UserApi();
/**
* Create user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateUser() throws Exception {
User user = createUser();
public void createUserTest() throws ApiException {
User body = null;
api.createUser(body);
api.createUser(user);
User fetched = api.getUserByName(user.getUsername());
assertEquals(user.getId(), fetched.getId());
// TODO: test validations
}
/**
* Creates list of users with given input array
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateUsersWithArray() throws Exception {
User user1 = createUser();
user1.setUsername("user" + user1.getId());
User user2 = createUser();
user2.setUsername("user" + user2.getId());
public void createUsersWithArrayInputTest() throws ApiException {
List<User> body = null;
api.createUsersWithArrayInput(body);
api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
User fetched = api.getUserByName(user1.getUsername());
assertEquals(user1.getId(), fetched.getId());
// TODO: test validations
}
/**
* Creates list of users with given input array
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateUsersWithList() throws Exception {
User user1 = createUser();
user1.setUsername("user" + user1.getId());
User user2 = createUser();
user2.setUsername("user" + user2.getId());
public void createUsersWithListInputTest() throws ApiException {
List<User> body = null;
api.createUsersWithListInput(body);
api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
User fetched = api.getUserByName(user1.getUsername());
assertEquals(user1.getId(), fetched.getId());
// TODO: test validations
}
/**
* Delete user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testLoginUser() throws Exception {
User user = createUser();
api.createUser(user);
public void deleteUserTest() throws ApiException {
String username = null;
api.deleteUser(username);
String token = api.loginUser(user.getUsername(), user.getPassword());
assertTrue(token.startsWith("logged in user session:"));
// TODO: test validations
}
/**
* Get user by user name
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void logoutUser() throws Exception {
public void getUserByNameTest() throws ApiException {
String username = null;
User response = api.getUserByName(username);
// TODO: test validations
}
/**
* Logs user into the system
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void loginUserTest() throws ApiException {
String username = null;
String password = null;
String response = api.loginUser(username, password);
// TODO: test validations
}
/**
* Logs out current logged in user session
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void logoutUserTest() throws ApiException {
api.logoutUser();
}
private User createUser() {
User user = new User();
user.setId(TestUtils.nextId());
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;
// TODO: test validations
}
/**
* Updated user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void updateUserTest() throws ApiException {
String username = null;
User body = null;
api.updateUser(username, body);
// TODO: test validations
}
}

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -61,30 +61,22 @@ Please follow the [installation](#installation) instruction and execute the foll
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.PetApi;
import io.swagger.client.api.AnotherFakeApi;
import java.io.File;
import java.util.*;
public class PetApiExample {
public class AnotherFakeApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: petstore_auth
OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth");
petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
PetApi apiInstance = new PetApi();
Pet body = new Pet(); // Pet | Pet object that needs to be added to the store
AnotherFakeApi apiInstance = new AnotherFakeApi();
Client body = new Client(); // Client | client model
try {
apiInstance.addPet(body);
Client result = apiInstance.testSpecialTags(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
System.err.println("Exception when calling AnotherFakeApi#testSpecialTags");
e.printStackTrace();
}
}
@ -94,26 +86,32 @@ public class PetApiExample {
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**testSpecialTags**](docs/AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
@ -127,21 +125,59 @@ Class | Method | HTTP request | Description
## Documentation for Models
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [Animal](docs/Animal.md)
- [AnimalFarm](docs/AnimalFarm.md)
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [ArrayTest](docs/ArrayTest.md)
- [Capitalization](docs/Capitalization.md)
- [Category](docs/Category.md)
- [InlineResponse200](docs/InlineResponse200.md)
- [ClassModel](docs/ClassModel.md)
- [Client](docs/Client.md)
- [EnumArrays](docs/EnumArrays.md)
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
- [FormatTest](docs/FormatTest.md)
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [Model200Response](docs/Model200Response.md)
- [ModelApiResponse](docs/ModelApiResponse.md)
- [ModelReturn](docs/ModelReturn.md)
- [Name](docs/Name.md)
- [NumberOnly](docs/NumberOnly.md)
- [Order](docs/Order.md)
- [OuterComposite](docs/OuterComposite.md)
- [OuterEnum](docs/OuterEnum.md)
- [Pet](docs/Pet.md)
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [SpecialModelName](docs/SpecialModelName.md)
- [Tag](docs/Tag.md)
- [User](docs/User.md)
- [Cat](docs/Cat.md)
- [Dog](docs/Dog.md)
## Documentation for Authorization
Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
### http_basic_test
- **Type**: HTTP basic authentication
### petstore_auth
- **Type**: OAuth
@ -151,44 +187,10 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account
- read:pets: read your pets
### test_api_client_id
- **Type**: API key
- **API key parameter name**: x-test_api_client_id
- **Location**: HTTP header
### test_api_client_secret
- **Type**: API key
- **API key parameter name**: x-test_api_client_secret
- **Location**: HTTP header
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### test_http_basic
- **Type**: HTTP basic authentication
### test_api_key_query
- **Type**: API key
- **API key parameter name**: test_api_key_query
- **Location**: URL query string
### test_api_key_header
- **Type**: API key
- **API key parameter name**: test_api_key_header
- **Location**: HTTP header
## Recommendation
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue.
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
## Author

View File

@ -15,7 +15,6 @@ import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.MultiPart;
@ -26,6 +25,7 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import org.glassfish.jersey.logging.LoggingFeature;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;

View File

@ -1,9 +1,26 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import io.swagger.client.ApiException;
import java.math.BigDecimal;
import java.util.Date;
import io.swagger.client.model.Client;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import io.swagger.client.model.OuterComposite;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.HashMap;
@ -13,11 +30,92 @@ import java.util.Map;
/**
* API tests for FakeApi
*/
@Ignore
public class FakeApiTest {
private final FakeApi api = new FakeApi();
/**
*
*
* Test serialization of outer boolean types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterBooleanSerializeTest() throws ApiException {
Boolean body = null;
Boolean response = api.fakeOuterBooleanSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of object with outer number type
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterCompositeSerializeTest() throws ApiException {
OuterComposite body = null;
OuterComposite response = api.fakeOuterCompositeSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of outer number types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterNumberSerializeTest() throws ApiException {
BigDecimal body = null;
BigDecimal response = api.fakeOuterNumberSerialize(body);
// TODO: test validations
}
/**
*
*
* Test serialization of outer string types
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void fakeOuterStringSerializeTest() throws ApiException {
String body = null;
String response = api.fakeOuterStringSerialize(body);
// TODO: test validations
}
/**
* To test \&quot;client\&quot; model
*
* To test \&quot;client\&quot; model
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testClientModelTest() throws ApiException {
Client body = null;
Client response = api.testClientModel(body);
// TODO: test validations
}
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*
@ -30,17 +128,75 @@ public class FakeApiTest {
public void testEndpointParametersTest() throws ApiException {
BigDecimal number = null;
Double _double = null;
String string = null;
String patternWithoutDelimiter = null;
byte[] _byte = null;
Integer integer = null;
Integer int32 = null;
Long int64 = null;
Float _float = null;
String string = null;
byte[] binary = null;
Date date = null;
Date dateTime = null;
LocalDate date = null;
OffsetDateTime dateTime = null;
String password = null;
// api.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
String paramCallback = null;
api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
// TODO: test validations
}
/**
* To test enum parameters
*
* To test enum parameters
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testEnumParametersTest() throws ApiException {
List<String> enumFormStringArray = null;
String enumFormString = null;
List<String> enumHeaderStringArray = null;
String enumHeaderString = null;
List<String> enumQueryStringArray = null;
String enumQueryString = null;
Integer enumQueryInteger = null;
Double enumQueryDouble = null;
api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
// TODO: test validations
}
/**
* test inline additionalProperties
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testInlineAdditionalPropertiesTest() throws ApiException {
Object param = null;
api.testInlineAdditionalProperties(param);
// TODO: test validations
}
/**
* test json serialization of form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testJsonFormDataTest() throws ApiException {
String param = null;
String param2 = null;
api.testJsonFormData(param, param2);
// TODO: test validations
}

View File

@ -1,288 +1,170 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.TestUtils;
import io.swagger.client.*;
import io.swagger.client.api.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.io.BufferedWriter;
import io.swagger.client.ApiException;
import java.io.File;
import java.io.FileWriter;
import io.swagger.client.model.ModelApiResponse;
import io.swagger.client.model.Pet;
import org.junit.Test;
import org.junit.Ignore;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.*;
import static org.junit.Assert.*;
/**
* API tests for PetApi
*/
@Ignore
public class PetApiTest {
PetApi api = null;
@Before
public void setup() {
api = new PetApi();
// setup authentication
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
apiKeyAuth.setApiKey("special-key");
}
private final PetApi api = new PetApi();
/**
* Add a new pet to the store
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testApiClient() {
// the default api client is used
assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());
public void addPetTest() throws ApiException {
Pet body = null;
api.addPet(body);
ApiClient oldClient = api.getApiClient();
ApiClient newClient = new ApiClient();
newClient.setBasePath("http://example.com");
newClient.setDebugging(true);
// set api client via constructor
api = new PetApi(newClient);
assertNotNull(api.getApiClient());
assertEquals("http://example.com", api.getApiClient().getBasePath());
assertTrue(api.getApiClient().isDebugging());
// set api client via setter method
api.setApiClient(oldClient);
assertNotNull(api.getApiClient());
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
assertFalse(api.getApiClient().isDebugging());
// TODO: test validations
}
/**
* Deletes a pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateAndGetPet() throws Exception {
Pet pet = createRandomPet();
api.addPet(pet);
public void deletePetTest() throws ApiException {
Long petId = null;
String apiKey = null;
api.deletePet(petId, apiKey);
Pet fetched = api.getPetById(pet.getId());
assertNotNull(fetched);
assertEquals(pet.getId(), fetched.getId());
assertNotNull(fetched.getCategory());
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
// TODO: test validations
}
/*
/**
* Finds Pets by status
*
* Multiple status values can be provided with comma separated strings
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateAndGetPetWithByteArray() throws Exception {
Pet pet = createRandomPet();
byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes();
api.addPetUsingByteArray(bytes);
public void findPetsByStatusTest() throws ApiException {
List<String> status = null;
List<Pet> response = api.findPetsByStatus(status);
byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(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());
// TODO: test validations
}
/**
* Finds Pets by tags
*
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testGetPetByIdInObject() throws Exception {
Pet pet = new Pet();
pet.setId(TestUtils.nextId());
pet.setName("pet " + pet.getId());
public void findPetsByTagsTest() throws ApiException {
List<String> tags = null;
List<Pet> response = api.findPetsByTags(tags);
Category category = new Category();
category.setId(TestUtils.nextId());
category.setName("category " + category.getId());
pet.setCategory(category);
pet.setStatus(Pet.StatusEnum.PENDING);
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1"});
pet.setPhotoUrls(photos);
api.addPet(pet);
InlineResponse200 fetched = api.getPetByIdInObject(pet.getId());
assertEquals(pet.getId(), fetched.getId());
assertEquals(pet.getName(), fetched.getName());
Object categoryObj = fetched.getCategory();
assertNotNull(categoryObj);
assertTrue(categoryObj instanceof Map);
Map categoryMap = (Map) categoryObj;
Object categoryIdObj = categoryMap.get("id");
assertTrue(categoryIdObj instanceof Integer);
Integer categoryIdInt = (Integer) categoryIdObj;
assertEquals(category.getId(), Long.valueOf(categoryIdInt));
assertEquals(category.getName(), categoryMap.get("name"));
// TODO: test validations
}
*/
/**
* Find pet by ID
*
* Returns a single pet
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testUpdatePet() throws Exception {
Pet pet = createRandomPet();
pet.setName("programmer");
public void getPetByIdTest() throws ApiException {
Long petId = null;
Pet response = api.getPetById(petId);
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());
// TODO: test validations
}
/**
* Update an existing pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testFindPetsByStatus() throws Exception {
Pet pet = createRandomPet();
pet.setName("programmer");
pet.setStatus(Pet.StatusEnum.AVAILABLE);
public void updatePetTest() throws ApiException {
Pet body = null;
api.updatePet(body);
api.updatePet(pet);
List<Pet> 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);
// TODO: test validations
}
/**
* Updates a pet in the store with form data
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testFindPetsByTags() throws Exception {
Pet pet = createRandomPet();
pet.setName("monster");
pet.setStatus(Pet.StatusEnum.AVAILABLE);
public void updatePetWithFormTest() throws ApiException {
Long petId = null;
String name = null;
String status = null;
api.updatePetWithForm(petId, name, status);
List<Tag> tags = new ArrayList<Tag>();
Tag tag1 = new Tag();
tag1.setName("friendly");
tags.add(tag1);
pet.setTags(tags);
api.updatePet(pet);
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
assertNotNull(pets);
boolean found = false;
for (Pet fetched : pets) {
if (fetched.getId().equals(pet.getId())) {
found = true;
break;
}
}
assertTrue(found);
// TODO: test validations
}
/**
* uploads an image
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testUpdatePetWithForm() throws Exception {
Pet pet = createRandomPet();
pet.setName("frank");
api.addPet(pet);
public void uploadFileTest() throws ApiException {
Long petId = null;
String additionalMetadata = null;
File file = null;
ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
Pet fetched = api.getPetById(pet.getId());
api.updatePetWithForm(fetched.getId(), "furt", null);
Pet updated = api.getPetById(fetched.getId());
assertEquals(updated.getName(), "furt");
}
@Test
public void testDeletePet() 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 testUploadFile() 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()));
}
@Test
public void testEqualsAndHashCode() {
Pet pet1 = new Pet();
Pet pet2 = new Pet();
assertTrue(pet1.equals(pet2));
assertTrue(pet2.equals(pet1));
assertTrue(pet1.hashCode() == pet2.hashCode());
assertTrue(pet1.equals(pet1));
assertTrue(pet1.hashCode() == pet1.hashCode());
pet2.setName("really-happy");
pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
assertFalse(pet1.equals(pet2));
assertFalse(pet2.equals(pet1));
assertFalse(pet1.hashCode() == (pet2.hashCode()));
assertTrue(pet2.equals(pet2));
assertTrue(pet2.hashCode() == pet2.hashCode());
pet1.setName("really-happy");
pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
assertTrue(pet1.equals(pet2));
assertTrue(pet2.equals(pet1));
assertTrue(pet1.hashCode() == pet2.hashCode());
assertTrue(pet1.equals(pet1));
assertTrue(pet1.hashCode() == pet1.hashCode());
}
private Pet createRandomPet() {
Pet pet = new Pet();
pet.setId(TestUtils.nextId());
pet.setName("gorilla");
Category category = new Category();
category.setName("really-happy");
pet.setCategory(category);
pet.setStatus(Pet.StatusEnum.AVAILABLE);
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
pet.setPhotoUrls(photos);
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> T deserializeJson(String json, Class<T> klass, ApiClient apiClient) {
ObjectMapper mapper = apiClient.getJSON().getContext(null);
try {
return mapper.readValue(json, klass);
} catch (Exception e) {
throw new RuntimeException(e);
}
// TODO: test validations
}
}

View File

@ -1,101 +1,98 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import io.swagger.TestUtils;
import io.swagger.client.ApiException;
import io.swagger.client.model.Order;
import org.junit.Test;
import org.junit.Ignore;
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import org.junit.*;
import org.threeten.bp.OffsetDateTime;
import static org.junit.Assert.*;
/**
* API tests for StoreApi
*/
@Ignore
public class StoreApiTest {
private 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"));
}
private final StoreApi api = new StoreApi();
/**
* Delete purchase order by ID
*
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testGetInventory() throws Exception {
Map<String, Integer> inventory = api.getInventory();
assertTrue(inventory.keySet().size() > 0);
}
public void deleteOrderTest() throws ApiException {
String orderId = null;
api.deleteOrder(orderId);
/*
// TODO: test validations
}
/**
* Returns pet inventories by status
*
* Returns a map of status codes to quantities
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testGetInventoryInObject() throws Exception {
Object inventoryObj = api.getInventoryInObject();
assertTrue(inventoryObj instanceof Map);
public void getInventoryTest() throws ApiException {
Map<String, Integer> response = api.getInventory();
Map inventoryMap = (Map) inventoryObj;
assertTrue(inventoryMap.keySet().size() > 0);
Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next();
assertTrue(firstEntry.getKey() instanceof String);
assertTrue(firstEntry.getValue() instanceof Integer);
// TODO: test validations
}
*/
/**
* Find purchase order by ID
*
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testPlaceOrder() throws Exception {
Order order = createOrder();
api.placeOrder(order);
public void getOrderByIdTest() throws ApiException {
Long orderId = null;
Order response = api.getOrderById(orderId);
Order fetched = api.getOrderById(order.getId());
assertEquals(order.getId(), fetched.getId());
assertEquals(order.getPetId(), fetched.getPetId());
assertEquals(order.getQuantity(), fetched.getQuantity());
assertTrue(order.getShipDate().isEqual(fetched.getShipDate()));
// TODO: test validations
}
/**
* Place an order for a pet
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testDeleteOrder() throws Exception {
Order order = createOrder();
api.placeOrder(order);
public void placeOrderTest() throws ApiException {
Order body = null;
Order response = api.placeOrder(body);
Order fetched = api.getOrderById(order.getId());
assertEquals(fetched.getId(), order.getId());
api.deleteOrder(String.valueOf(order.getId()));
try {
api.getOrderById(order.getId());
// fail("expected an error");
} catch (ApiException e) {
// ok
}
}
private Order createOrder() {
Order order = new Order();
order.setPetId(200L);
order.setQuantity(13);
//Ensure 3 fractional digits because of a bug in the petstore server
order.setShipDate(OffsetDateTime.now().withNano(123000000));
order.setStatus(Order.StatusEnum.PLACED);
order.setComplete(true);
try {
Field idField = Order.class.getDeclaredField("id");
idField.setAccessible(true);
idField.set(order, TestUtils.nextId());
} catch (Exception e) {
throw new RuntimeException(e);
}
return order;
// TODO: test validations
}
}

View File

@ -1,88 +1,164 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package io.swagger.client.api;
import io.swagger.TestUtils;
import io.swagger.client.ApiException;
import io.swagger.client.model.User;
import org.junit.Test;
import org.junit.Ignore;
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.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* API tests for UserApi
*/
@Ignore
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");
}
private final UserApi api = new UserApi();
/**
* Create user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateUser() throws Exception {
User user = createUser();
public void createUserTest() throws ApiException {
User body = null;
api.createUser(body);
api.createUser(user);
User fetched = api.getUserByName(user.getUsername());
assertEquals(user.getId(), fetched.getId());
// TODO: test validations
}
/**
* Creates list of users with given input array
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateUsersWithArray() throws Exception {
User user1 = createUser();
user1.setUsername("user" + user1.getId());
User user2 = createUser();
user2.setUsername("user" + user2.getId());
public void createUsersWithArrayInputTest() throws ApiException {
List<User> body = null;
api.createUsersWithArrayInput(body);
api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
User fetched = api.getUserByName(user1.getUsername());
assertEquals(user1.getId(), fetched.getId());
// TODO: test validations
}
/**
* Creates list of users with given input array
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testCreateUsersWithList() throws Exception {
User user1 = createUser();
user1.setUsername("user" + user1.getId());
User user2 = createUser();
user2.setUsername("user" + user2.getId());
public void createUsersWithListInputTest() throws ApiException {
List<User> body = null;
api.createUsersWithListInput(body);
api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
User fetched = api.getUserByName(user1.getUsername());
assertEquals(user1.getId(), fetched.getId());
// TODO: test validations
}
/**
* Delete user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testLoginUser() throws Exception {
User user = createUser();
api.createUser(user);
public void deleteUserTest() throws ApiException {
String username = null;
api.deleteUser(username);
String token = api.loginUser(user.getUsername(), user.getPassword());
assertTrue(token.startsWith("logged in user session:"));
// TODO: test validations
}
/**
* Get user by user name
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void logoutUser() throws Exception {
public void getUserByNameTest() throws ApiException {
String username = null;
User response = api.getUserByName(username);
// TODO: test validations
}
/**
* Logs user into the system
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void loginUserTest() throws ApiException {
String username = null;
String password = null;
String response = api.loginUser(username, password);
// TODO: test validations
}
/**
* Logs out current logged in user session
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void logoutUserTest() throws ApiException {
api.logoutUser();
}
private User createUser() {
User user = new User();
user.setId(TestUtils.nextId());
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;
// TODO: test validations
}
/**
* Updated user
*
* This can only be done by the logged in user.
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void updateUserTest() throws ApiException {
String username = null;
User body = null;
api.updateUser(username, body);
// TODO: test validations
}
}

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -21,9 +21,9 @@ public class Category {
@ApiModelProperty(value = "")
private Long id = null;
@ApiModelProperty(value = "")
private String name = null;
/**
* Get id
* @return id

View File

@ -21,11 +21,12 @@ public class ModelApiResponse {
@ApiModelProperty(value = "")
private Integer code = null;
@ApiModelProperty(value = "")
private String type = null;
@ApiModelProperty(value = "")
private String message = null;
/**
* Get code
* @return code

View File

@ -22,13 +22,17 @@ public class Order {
@ApiModelProperty(value = "")
private Long id = null;
@ApiModelProperty(value = "")
private Long petId = null;
@ApiModelProperty(value = "")
private Integer quantity = null;
@ApiModelProperty(value = "")
private Date shipDate = null;
@XmlType(name="StatusEnum")
@XmlEnum(String.class)
public enum StatusEnum {
@ -66,9 +70,9 @@ public enum StatusEnum {
* Order Status
**/
private StatusEnum status = null;
@ApiModelProperty(value = "")
private Boolean complete = false;
/**
* Get id
* @return id

View File

@ -25,14 +25,19 @@ public class Pet {
@ApiModelProperty(value = "")
private Long id = null;
@ApiModelProperty(value = "")
private Category category = null;
@ApiModelProperty(example = "doggie", required = true, value = "")
private String name = null;
@ApiModelProperty(required = true, value = "")
private List<String> photoUrls = new ArrayList<String>();
@ApiModelProperty(value = "")
private List<Tag> tags = new ArrayList<Tag>();
private List<Tag> tags = null;
@XmlType(name="StatusEnum")
@XmlEnum(String.class)
@ -71,7 +76,6 @@ public enum StatusEnum {
* pet status in the store
**/
private StatusEnum status = null;
/**
* Get id
* @return id

View File

@ -21,9 +21,9 @@ public class Tag {
@ApiModelProperty(value = "")
private Long id = null;
@ApiModelProperty(value = "")
private String name = null;
/**
* Get id
* @return id

View File

@ -21,24 +21,30 @@ public class User {
@ApiModelProperty(value = "")
private Long id = null;
@ApiModelProperty(value = "")
private String username = null;
@ApiModelProperty(value = "")
private String firstName = null;
@ApiModelProperty(value = "")
private String lastName = null;
@ApiModelProperty(value = "")
private String email = null;
@ApiModelProperty(value = "")
private String password = null;
@ApiModelProperty(value = "")
private String phone = null;
@ApiModelProperty(value = "User Status")
/**
* User Status
**/
private Integer userStatus = null;
/**
* Get id
* @return id

View File

@ -15,7 +15,7 @@ package io.swagger.client.model
case class ApiResponse (
code: Option[Integer] = None,
_type: Option[String] = None,
`type`: Option[String] = None,
message: Option[String] = None
)

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -128,7 +128,6 @@ paths:
- petstore_auth:
- "write:pets"
- "read:pets"
x-contentType: "application/json"
x-accepts: "application/json"
/pet/findByTags:
get:
@ -164,7 +163,6 @@ paths:
- "write:pets"
- "read:pets"
deprecated: true
x-contentType: "application/json"
x-accepts: "application/json"
/pet/{petId}:
get:
@ -194,7 +192,6 @@ paths:
description: "Pet not found"
security:
- api_key: []
x-contentType: "application/json"
x-accepts: "application/json"
post:
tags:
@ -260,7 +257,6 @@ paths:
- petstore_auth:
- "write:pets"
- "read:pets"
x-contentType: "application/json"
x-accepts: "application/json"
/pet/{petId}/uploadImage:
post:
@ -321,7 +317,6 @@ paths:
format: "int32"
security:
- api_key: []
x-contentType: "application/json"
x-accepts: "application/json"
/store/order:
post:
@ -378,7 +373,6 @@ paths:
description: "Invalid ID supplied"
404:
description: "Order not found"
x-contentType: "application/json"
x-accepts: "application/json"
delete:
tags:
@ -401,7 +395,6 @@ paths:
description: "Invalid ID supplied"
404:
description: "Order not found"
x-contentType: "application/json"
x-accepts: "application/json"
/user:
post:
@ -510,7 +503,6 @@ paths:
description: "date in UTC when toekn expires"
400:
description: "Invalid username/password supplied"
x-contentType: "application/json"
x-accepts: "application/json"
/user/logout:
get:
@ -526,7 +518,6 @@ paths:
responses:
default:
description: "successful operation"
x-contentType: "application/json"
x-accepts: "application/json"
/user/{username}:
get:
@ -553,7 +544,6 @@ paths:
description: "Invalid username supplied"
404:
description: "User not found"
x-contentType: "application/json"
x-accepts: "application/json"
put:
tags:
@ -603,7 +593,6 @@ paths:
description: "Invalid username supplied"
404:
description: "User not found"
x-contentType: "application/json"
x-accepts: "application/json"
/fake_classname_test:
patch:

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (2.3.1-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

View File

@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT

View File

@ -15,7 +15,7 @@
<junit.version>4.12</junit.version>
<vertx.version>3.4.1</vertx.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<vertx-swagger-router.version>1.2.0</vertx-swagger-router.version>
<vertx-swagger-router.version>1.4.0</vertx-swagger-router.version>
<maven-shade-plugin.version>2.3</maven-shade-plugin.version>
<jackson-datatype-jsr310.version>2.7.4</jackson-datatype-jsr310.version>
</properties>
@ -28,25 +28,24 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.phiz71</groupId>
<artifactId>vertx-swagger-router</artifactId>
<version>${vertx-swagger-router.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
<groupId>com.github.phiz71</groupId>
<artifactId>vertx-swagger-router</artifactId>
<version>${vertx-swagger-router.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-datatype-jsr310.version}</version>
</dependency>
</dependencies>
<build>
@ -88,4 +87,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -28,8 +28,17 @@ public class PetApiVerticle extends AbstractVerticle {
final static String UPDATEPETWITHFORM_SERVICE_ID = "updatePetWithForm";
final static String UPLOADFILE_SERVICE_ID = "uploadFile";
//TODO : create Implementation
PetApi service = new PetApiImpl();
final PetApi service;
public PetApiVerticle() {
try {
Class serviceImplClass = getClass().getClassLoader().loadClass("io.swagger.server.api.verticle.PetApiImpl");
service = (PetApi)serviceImplClass.newInstance();
} catch (Exception e) {
logUnexpectedError("PetApiVerticle constructor", e);
throw new RuntimeException(e);
}
}
@Override
public void start() throws Exception {

Some files were not shown because too many files have changed in this diff Show More