forked from loafle/openapi-generator-original
Merge pull request #1116 from swagger-api/issue-1115
fixes for jaxrs codegen
This commit is contained in:
commit
a3c7e22d55
@ -1,5 +1,5 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
language: java
|
language: java
|
||||||
script: mvn verify
|
script: mvn verify -Psamples
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk7
|
- oraclejdk7
|
||||||
|
@ -139,7 +139,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey("serializableModel")) {
|
if (additionalProperties.containsKey("serializableModel")) {
|
||||||
this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel")));
|
this.setSerializableModel(Boolean.valueOf(additionalProperties.get("serializableModel").toString()));
|
||||||
} else {
|
} else {
|
||||||
additionalProperties.put("serializableModel", serializableModel);
|
additionalProperties.put("serializableModel", serializableModel);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import io.swagger.codegen.CodegenConfig;
|
import io.swagger.codegen.CodegenConfig;
|
||||||
|
import io.swagger.codegen.CodegenResponse;
|
||||||
import io.swagger.codegen.CodegenOperation;
|
import io.swagger.codegen.CodegenOperation;
|
||||||
import io.swagger.codegen.CodegenType;
|
import io.swagger.codegen.CodegenType;
|
||||||
import io.swagger.codegen.SupportingFile;
|
import io.swagger.codegen.SupportingFile;
|
||||||
@ -122,27 +123,35 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
|
|||||||
if (operations != null) {
|
if (operations != null) {
|
||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation operation : ops) {
|
for (CodegenOperation operation : ops) {
|
||||||
|
List<CodegenResponse> responses = operation.responses;
|
||||||
|
if (responses != null) {
|
||||||
|
for (CodegenResponse resp : responses) {
|
||||||
|
if ("0".equals(resp.code)) {
|
||||||
|
resp.code = "200";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (operation.returnType == null) {
|
if (operation.returnType == null) {
|
||||||
operation.returnType = "Void";
|
operation.returnType = "Void";
|
||||||
} else if (operation.returnType.startsWith("List")) {
|
} else if (operation.returnType.startsWith("List")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
operation.returnType = rt.substring("List<".length(), end);
|
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||||
operation.returnContainer = "List";
|
operation.returnContainer = "List";
|
||||||
}
|
}
|
||||||
} else if (operation.returnType.startsWith("Map")) {
|
} else if (operation.returnType.startsWith("Map")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
operation.returnType = rt.substring("Map<".length(), end);
|
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||||
operation.returnContainer = "Map";
|
operation.returnContainer = "Map";
|
||||||
}
|
}
|
||||||
} else if (operation.returnType.startsWith("Set")) {
|
} else if (operation.returnType.startsWith("Set")) {
|
||||||
String rt = operation.returnType;
|
String rt = operation.returnType;
|
||||||
int end = rt.lastIndexOf(">");
|
int end = rt.lastIndexOf(">");
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
operation.returnType = rt.substring("Set<".length(), end);
|
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||||
operation.returnContainer = "Set";
|
operation.returnContainer = "Set";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||||
@Override
|
|
||||||
public void doFilter(ServletRequest request, ServletResponse response,
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
FilterChain chain) throws IOException, ServletException {
|
FilterChain chain) throws IOException, ServletException {
|
||||||
HttpServletResponse res = (HttpServletResponse) response;
|
HttpServletResponse res = (HttpServletResponse) response;
|
||||||
@ -17,11 +16,7 @@ public class ApiOriginFilter implements javax.servlet.Filter {
|
|||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void destroy() {}
|
||||||
public void destroy() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void init(FilterConfig filterConfig) throws ServletException {}
|
||||||
public void init(FilterConfig filterConfig) throws ServletException {
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ public class {{classname}} {
|
|||||||
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||||
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
|
@io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
|
||||||
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
|
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
|
||||||
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
|
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},
|
||||||
{{/hasMore}}{{/responses}} })
|
{{/hasMore}}{{/responses}} })
|
||||||
|
|
||||||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @FormDataParam("file") InputStream inputStream,
|
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @FormDataParam("file") InputStream inputStream,
|
||||||
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
|
@FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
|
@ -119,13 +119,12 @@
|
|||||||
<artifactId>jersey-server</artifactId>
|
<artifactId>jersey-server</artifactId>
|
||||||
<version>${jersey-version}</version>
|
<version>${jersey-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scalatest</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>scalatest_2.9.1</artifactId>
|
<artifactId>servlet-api</artifactId>
|
||||||
<version>${scala-test-version}</version>
|
<version>${servlet-api-version}</version>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@ -133,9 +132,30 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>com.sun.jersey</groupId>
|
||||||
<artifactId>servlet-api</artifactId>
|
<artifactId>jersey-client</artifactId>
|
||||||
<version>${servlet-api-version}</version>
|
<version>${jersey-version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testng</groupId>
|
||||||
|
<artifactId>testng</artifactId>
|
||||||
|
<version>6.8.8</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bsh</artifactId>
|
||||||
|
<groupId>org.beanshell</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -148,11 +168,10 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.0</swagger-core-version>
|
<swagger-core-version>1.5.3</swagger-core-version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
<jersey-version>1.13</jersey-version>
|
<jersey-version>1.18.1</jersey-version>
|
||||||
<slf4j-version>1.6.3</slf4j-version>
|
<slf4j-version>1.6.3</slf4j-version>
|
||||||
<scala-test-version>1.6.1</scala-test-version>
|
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.8.1</junit-version>
|
||||||
<servlet-api-version>2.5</servlet-api-version>
|
<servlet-api-version>2.5</servlet-api-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{{#returnContainer}}{{#isMapContainer}}Map<String, {{{returnType}}}>{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
|
2
pom.xml
2
pom.xml
@ -392,10 +392,10 @@
|
|||||||
<module>samples/client/petstore/java/default</module>
|
<module>samples/client/petstore/java/default</module>
|
||||||
<module>samples/client/petstore/java/jersey2</module>
|
<module>samples/client/petstore/java/jersey2</module>
|
||||||
<module>samples/client/petstore/scala</module>
|
<module>samples/client/petstore/scala</module>
|
||||||
<module>samples/server/petstore/jaxrs</module>
|
|
||||||
<module>samples/server/petstore/spring-mvc</module>
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
<!--module>samples/client/petstore/objc</module-->
|
<!--module>samples/client/petstore/objc</module-->
|
||||||
<module>samples/client/petstore/ruby</module>
|
<module>samples/client/petstore/ruby</module>
|
||||||
|
<module>samples/server/petstore/jaxrs</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
@ -119,13 +119,12 @@
|
|||||||
<artifactId>jersey-server</artifactId>
|
<artifactId>jersey-server</artifactId>
|
||||||
<version>${jersey-version}</version>
|
<version>${jersey-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scalatest</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>scalatest_2.9.1</artifactId>
|
<artifactId>servlet-api</artifactId>
|
||||||
<version>${scala-test-version}</version>
|
<version>${servlet-api-version}</version>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@ -133,9 +132,30 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>com.sun.jersey</groupId>
|
||||||
<artifactId>servlet-api</artifactId>
|
<artifactId>jersey-client</artifactId>
|
||||||
<version>${servlet-api-version}</version>
|
<version>${jersey-version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testng</groupId>
|
||||||
|
<artifactId>testng</artifactId>
|
||||||
|
<version>6.8.8</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>bsh</artifactId>
|
||||||
|
<groupId>org.beanshell</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -148,11 +168,10 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.0</swagger-core-version>
|
<swagger-core-version>1.5.3</swagger-core-version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
<jersey-version>1.13</jersey-version>
|
<jersey-version>1.18.1</jersey-version>
|
||||||
<slf4j-version>1.6.3</slf4j-version>
|
<slf4j-version>1.6.3</slf4j-version>
|
||||||
<scala-test-version>1.6.1</scala-test-version>
|
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.8.1</junit-version>
|
||||||
<servlet-api-version>2.5</servlet-api-version>
|
<servlet-api-version>2.5</servlet-api-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.api;
|
package io.swagger.api;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception{
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
public ApiException (int code, String msg) {
|
||||||
|
@ -5,8 +5,8 @@ import java.io.IOException;
|
|||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||||
@Override
|
|
||||||
public void doFilter(ServletRequest request, ServletResponse response,
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
FilterChain chain) throws IOException, ServletException {
|
FilterChain chain) throws IOException, ServletException {
|
||||||
HttpServletResponse res = (HttpServletResponse) response;
|
HttpServletResponse res = (HttpServletResponse) response;
|
||||||
@ -16,11 +16,7 @@ public class ApiOriginFilter implements javax.servlet.Filter {
|
|||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void destroy() {}
|
||||||
public void destroy() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void init(FilterConfig filterConfig) throws ServletException {}
|
||||||
public void init(FilterConfig filterConfig) throws ServletException {
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package io.swagger.api;
|
|||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
@javax.xml.bind.annotation.XmlRootElement
|
@javax.xml.bind.annotation.XmlRootElement
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class ApiResponseMessage {
|
public class ApiResponseMessage {
|
||||||
public static final int ERROR = 1;
|
public static final int ERROR = 1;
|
||||||
public static final int WARNING = 2;
|
public static final int WARNING = 2;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.swagger.api;
|
package io.swagger.api;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class NotFoundException extends ApiException {
|
public class NotFoundException extends ApiException {
|
||||||
private int code;
|
private int code;
|
||||||
public NotFoundException (int code, String msg) {
|
public NotFoundException (int code, String msg) {
|
||||||
|
@ -26,6 +26,7 @@ import javax.ws.rs.*;
|
|||||||
|
|
||||||
|
|
||||||
@io.swagger.annotations.Api(value = "/pet", description = "the pet API")
|
@io.swagger.annotations.Api(value = "/pet", description = "the pet API")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
|
|
||||||
private final PetApiService delegate = PetApiServiceFactory.getPetApi();
|
private final PetApiService delegate = PetApiServiceFactory.getPetApi();
|
||||||
@ -36,11 +37,11 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"),
|
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class) })
|
||||||
|
|
||||||
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -52,7 +53,7 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
|
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
|
||||||
|
|
||||||
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -64,9 +65,9 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
|
@io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") })
|
||||||
|
|
||||||
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List<String> status)
|
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List<String> status)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -78,9 +79,9 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
|
@io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") })
|
||||||
|
|
||||||
public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List<String> tags)
|
public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List<String> tags)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -92,11 +93,11 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class)
|
@io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class) })
|
||||||
|
|
||||||
public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId)
|
public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -108,7 +109,7 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
|
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
|
||||||
|
|
||||||
public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId,
|
public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId,
|
||||||
@ApiParam(value = "Updated name of the pet" )@FormParam("name") String name,
|
@ApiParam(value = "Updated name of the pet" )@FormParam("name") String name,
|
||||||
@ -122,12 +123,12 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
|
||||||
|
|
||||||
public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey,
|
public Response deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId,
|
||||||
@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId)
|
@ApiParam(value = "" )@HeaderParam("api_key") String apiKey)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
return delegate.deletePet(apiKey,petId);
|
return delegate.deletePet(petId,apiKey);
|
||||||
}
|
}
|
||||||
@POST
|
@POST
|
||||||
@Path("/{petId}/uploadImage")
|
@Path("/{petId}/uploadImage")
|
||||||
@ -135,12 +136,12 @@ public class PetApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||||
|
|
||||||
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId,
|
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId,
|
||||||
@ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata,
|
@ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata,
|
||||||
@ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream,
|
@FormDataParam("file") InputStream inputStream,
|
||||||
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail)
|
@FormDataParam("file") FormDataContentDisposition fileDetail)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
return delegate.uploadFile(petId,additionalMetadata,fileDetail);
|
return delegate.uploadFile(petId,additionalMetadata,fileDetail);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
|||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public abstract class PetApiService {
|
public abstract class PetApiService {
|
||||||
|
|
||||||
public abstract Response updatePet(Pet body)
|
public abstract Response updatePet(Pet body)
|
||||||
@ -38,7 +39,7 @@ public abstract class PetApiService {
|
|||||||
public abstract Response updatePetWithForm(String petId,String name,String status)
|
public abstract Response updatePetWithForm(String petId,String name,String status)
|
||||||
throws NotFoundException;
|
throws NotFoundException;
|
||||||
|
|
||||||
public abstract Response deletePet(String apiKey,Long petId)
|
public abstract Response deletePet(Long petId,String apiKey)
|
||||||
throws NotFoundException;
|
throws NotFoundException;
|
||||||
|
|
||||||
public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
|
public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
|
||||||
|
@ -26,6 +26,7 @@ import javax.ws.rs.*;
|
|||||||
|
|
||||||
|
|
||||||
@io.swagger.annotations.Api(value = "/store", description = "the store API")
|
@io.swagger.annotations.Api(value = "/store", description = "the store API")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
|
|
||||||
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
|
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
|
||||||
@ -34,9 +35,9 @@ public class StoreApi {
|
|||||||
@Path("/inventory")
|
@Path("/inventory")
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map")
|
@io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map")
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") })
|
||||||
|
|
||||||
public Response getInventory()
|
public Response getInventory()
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -48,9 +49,9 @@ public class StoreApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
|
@io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
|
||||||
|
|
||||||
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
|
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -62,11 +63,11 @@ public class StoreApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
|
@io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class) })
|
||||||
|
|
||||||
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId)
|
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -78,9 +79,9 @@ public class StoreApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class) })
|
||||||
|
|
||||||
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId)
|
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
|||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public abstract class StoreApiService {
|
public abstract class StoreApiService {
|
||||||
|
|
||||||
public abstract Response getInventory()
|
public abstract Response getInventory()
|
||||||
|
@ -26,6 +26,7 @@ import javax.ws.rs.*;
|
|||||||
|
|
||||||
|
|
||||||
@io.swagger.annotations.Api(value = "/user", description = "the user API")
|
@io.swagger.annotations.Api(value = "/user", description = "the user API")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
|
|
||||||
private final UserApiService delegate = UserApiServiceFactory.getUserApi();
|
private final UserApiService delegate = UserApiServiceFactory.getUserApi();
|
||||||
@ -36,7 +37,7 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||||
|
|
||||||
public Response createUser(@ApiParam(value = "Created user object" ) User body)
|
public Response createUser(@ApiParam(value = "Created user object" ) User body)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -48,7 +49,7 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||||
|
|
||||||
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List<User> body)
|
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List<User> body)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -60,7 +61,7 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||||
|
|
||||||
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List<User> body)
|
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List<User> body)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -72,9 +73,9 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
|
@io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
|
||||||
|
|
||||||
public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username,
|
public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username,
|
||||||
@ApiParam(value = "The password for login in clear text") @QueryParam("password") String password)
|
@ApiParam(value = "The password for login in clear text") @QueryParam("password") String password)
|
||||||
@ -87,7 +88,7 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
|
||||||
|
|
||||||
public Response logoutUser()
|
public Response logoutUser()
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -99,11 +100,11 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class)
|
@io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
|
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class) })
|
||||||
|
|
||||||
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username)
|
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
@ -115,9 +116,9 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class) })
|
||||||
|
|
||||||
public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username,
|
public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username,
|
||||||
@ApiParam(value = "Updated user object" ) User body)
|
@ApiParam(value = "Updated user object" ) User body)
|
||||||
@ -130,9 +131,9 @@ public class UserApi {
|
|||||||
@Produces({ "application/json", "application/xml" })
|
@Produces({ "application/json", "application/xml" })
|
||||||
@io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
|
@io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||||
@io.swagger.annotations.ApiResponses(value = {
|
@io.swagger.annotations.ApiResponses(value = {
|
||||||
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
|
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class),
|
||||||
|
|
||||||
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
|
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class) })
|
||||||
|
|
||||||
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username)
|
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
|||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public abstract class UserApiService {
|
public abstract class UserApiService {
|
||||||
|
|
||||||
public abstract Response createUser(User body)
|
public abstract Response createUser(User body)
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class Order {
|
public class Order {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package io.swagger.model;
|
package io.swagger.model;
|
||||||
|
|
||||||
import io.swagger.model.Category;
|
import io.swagger.model.Category;
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.model.Tag;
|
import io.swagger.model.Tag;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class Pet {
|
public class Pet {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class Tag {
|
public class Tag {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00")
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -3,11 +3,13 @@ package io.swagger.api.factories;
|
|||||||
import io.swagger.api.PetApiService;
|
import io.swagger.api.PetApiService;
|
||||||
import io.swagger.api.impl.PetApiServiceImpl;
|
import io.swagger.api.impl.PetApiServiceImpl;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00")
|
||||||
public class PetApiServiceFactory {
|
public class PetApiServiceFactory {
|
||||||
|
|
||||||
private final static PetApiService service = new PetApiServiceImpl();
|
private final static PetApiService service = new PetApiServiceImpl();
|
||||||
|
|
||||||
public static PetApiService getPetApi() {
|
public static PetApiService getPetApi()
|
||||||
|
{
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@ package io.swagger.api.factories;
|
|||||||
import io.swagger.api.StoreApiService;
|
import io.swagger.api.StoreApiService;
|
||||||
import io.swagger.api.impl.StoreApiServiceImpl;
|
import io.swagger.api.impl.StoreApiServiceImpl;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00")
|
||||||
public class StoreApiServiceFactory {
|
public class StoreApiServiceFactory {
|
||||||
|
|
||||||
private final static StoreApiService service = new StoreApiServiceImpl();
|
private final static StoreApiService service = new StoreApiServiceImpl();
|
||||||
|
|
||||||
public static StoreApiService getStoreApi() {
|
public static StoreApiService getStoreApi()
|
||||||
|
{
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@ package io.swagger.api.factories;
|
|||||||
import io.swagger.api.UserApiService;
|
import io.swagger.api.UserApiService;
|
||||||
import io.swagger.api.impl.UserApiServiceImpl;
|
import io.swagger.api.impl.UserApiServiceImpl;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00")
|
||||||
public class UserApiServiceFactory {
|
public class UserApiServiceFactory {
|
||||||
|
|
||||||
private final static UserApiService service = new UserApiServiceImpl();
|
private final static UserApiService service = new UserApiServiceImpl();
|
||||||
|
|
||||||
public static UserApiService getUserApi() {
|
public static UserApiService getUserApi()
|
||||||
|
{
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
package io.swagger.api.impl;
|
package io.swagger.api.impl;
|
||||||
|
|
||||||
import com.sun.jersey.core.header.FormDataContentDisposition;
|
|
||||||
import io.swagger.api.*;
|
import io.swagger.api.*;
|
||||||
import io.swagger.api.NotFoundException;
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import io.swagger.model.Pet;
|
import io.swagger.model.Pet;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00")
|
||||||
public class PetApiServiceImpl extends PetApiService {
|
public class PetApiServiceImpl extends PetApiService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,7 +64,7 @@ public class PetApiServiceImpl extends PetApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response deletePet(String apiKey, Long petId)
|
public Response deletePet(Long petId,String apiKey)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
package io.swagger.api.impl;
|
package io.swagger.api.impl;
|
||||||
|
|
||||||
import io.swagger.api.*;
|
import io.swagger.api.*;
|
||||||
import io.swagger.api.NotFoundException;
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import io.swagger.model.Order;
|
import io.swagger.model.Order;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00")
|
||||||
public class StoreApiServiceImpl extends StoreApiService {
|
public class StoreApiServiceImpl extends StoreApiService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,12 +1,24 @@
|
|||||||
package io.swagger.api.impl;
|
package io.swagger.api.impl;
|
||||||
|
|
||||||
import io.swagger.api.*;
|
import io.swagger.api.*;
|
||||||
import io.swagger.api.NotFoundException;
|
import io.swagger.model.*;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import io.swagger.model.User;
|
import io.swagger.model.User;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import io.swagger.api.NotFoundException;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.sun.jersey.core.header.FormDataContentDisposition;
|
||||||
|
import com.sun.jersey.multipart.FormDataParam;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00")
|
||||||
public class UserApiServiceImpl extends UserApiService {
|
public class UserApiServiceImpl extends UserApiService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,553 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
import com.sun.jersey.api.client.Client;
|
||||||
|
import com.sun.jersey.api.client.ClientResponse;
|
||||||
|
import com.sun.jersey.api.client.config.ClientConfig;
|
||||||
|
import com.sun.jersey.api.client.config.DefaultClientConfig;
|
||||||
|
import com.sun.jersey.api.client.filter.LoggingFilter;
|
||||||
|
import com.sun.jersey.api.client.WebResource.Builder;
|
||||||
|
|
||||||
|
import com.sun.jersey.multipart.FormDataMultiPart;
|
||||||
|
import com.sun.jersey.multipart.file.FileDataBodyPart;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response.Status.Family;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
import io.swagger.client.auth.Authentication;
|
||||||
|
import io.swagger.client.auth.HttpBasicAuth;
|
||||||
|
import io.swagger.client.auth.ApiKeyAuth;
|
||||||
|
import io.swagger.client.auth.OAuth;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class ApiClient {
|
||||||
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
|
private boolean debugging = false;
|
||||||
|
private String basePath = "http://petstore.swagger.io/v2";
|
||||||
|
private JSON json = new JSON();
|
||||||
|
|
||||||
|
private Map<String, Authentication> authentications;
|
||||||
|
|
||||||
|
private DateFormat dateFormat;
|
||||||
|
|
||||||
|
public ApiClient() {
|
||||||
|
// Use ISO 8601 format for date and datetime.
|
||||||
|
// See https://en.wikipedia.org/wiki/ISO_8601
|
||||||
|
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||||
|
|
||||||
|
// Use UTC as the default time zone.
|
||||||
|
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
|
||||||
|
// Set default User-Agent.
|
||||||
|
setUserAgent("Java-Swagger");
|
||||||
|
|
||||||
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
|
authentications = new HashMap<String, Authentication>();
|
||||||
|
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||||
|
authentications.put("petstore_auth", new OAuth());
|
||||||
|
// Prevent the authentications from being modified.
|
||||||
|
authentications = Collections.unmodifiableMap(authentications);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBasePath() {
|
||||||
|
return basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient setBasePath(String basePath) {
|
||||||
|
this.basePath = basePath;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get authentications (key: authentication name, value: authentication).
|
||||||
|
*/
|
||||||
|
public Map<String, Authentication> getAuthentications() {
|
||||||
|
return authentications;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get authentication for the given name.
|
||||||
|
*
|
||||||
|
* @param authName The authentication name
|
||||||
|
* @return The authentication, null if not found
|
||||||
|
*/
|
||||||
|
public Authentication getAuthentication(String authName) {
|
||||||
|
return authentications.get(authName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set username for the first HTTP basic authentication.
|
||||||
|
*/
|
||||||
|
public void setUsername(String username) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBasicAuth) {
|
||||||
|
((HttpBasicAuth) auth).setUsername(username);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No HTTP basic authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set password for the first HTTP basic authentication.
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof HttpBasicAuth) {
|
||||||
|
((HttpBasicAuth) auth).setPassword(password);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No HTTP basic authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set API key value for the first API key authentication.
|
||||||
|
*/
|
||||||
|
public void setApiKey(String apiKey) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof ApiKeyAuth) {
|
||||||
|
((ApiKeyAuth) auth).setApiKey(apiKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No API key authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set API key prefix for the first API key authentication.
|
||||||
|
*/
|
||||||
|
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||||
|
for (Authentication auth : authentications.values()) {
|
||||||
|
if (auth instanceof ApiKeyAuth) {
|
||||||
|
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No API key authentication configured!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the User-Agent header's value (by adding to the default header map).
|
||||||
|
*/
|
||||||
|
public ApiClient setUserAgent(String userAgent) {
|
||||||
|
addDefaultHeader("User-Agent", userAgent);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a default header.
|
||||||
|
*
|
||||||
|
* @param key The header's key
|
||||||
|
* @param value The header's value
|
||||||
|
*/
|
||||||
|
public ApiClient addDefaultHeader(String key, String value) {
|
||||||
|
defaultHeaderMap.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that whether debugging is enabled for this API client.
|
||||||
|
*/
|
||||||
|
public boolean isDebugging() {
|
||||||
|
return debugging;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/disable debugging for this API client.
|
||||||
|
*
|
||||||
|
* @param debugging To enable (true) or disable (false) debugging
|
||||||
|
*/
|
||||||
|
public ApiClient setDebugging(boolean debugging) {
|
||||||
|
this.debugging = debugging;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the date format used to parse/format date parameters.
|
||||||
|
*/
|
||||||
|
public DateFormat getDateFormat() {
|
||||||
|
return dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the date format used to parse/format date parameters.
|
||||||
|
*/
|
||||||
|
public ApiClient getDateFormat(DateFormat dateFormat) {
|
||||||
|
this.dateFormat = dateFormat;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the given string into Date object.
|
||||||
|
*/
|
||||||
|
public Date parseDate(String str) {
|
||||||
|
try {
|
||||||
|
return dateFormat.parse(str);
|
||||||
|
} catch (java.text.ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the given Date object into string.
|
||||||
|
*/
|
||||||
|
public String formatDate(Date date) {
|
||||||
|
return dateFormat.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the given parameter object into string.
|
||||||
|
*/
|
||||||
|
public String parameterToString(Object param) {
|
||||||
|
if (param == null) {
|
||||||
|
return "";
|
||||||
|
} else if (param instanceof Date) {
|
||||||
|
return formatDate((Date) param);
|
||||||
|
} else if (param instanceof Collection) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
for(Object o : (Collection)param) {
|
||||||
|
if(b.length() > 0) {
|
||||||
|
b.append(",");
|
||||||
|
}
|
||||||
|
b.append(String.valueOf(o));
|
||||||
|
}
|
||||||
|
return b.toString();
|
||||||
|
} else {
|
||||||
|
return String.valueOf(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Format to {@code Pair} objects.
|
||||||
|
*/
|
||||||
|
public List<Pair> parameterToPairs(String collectionFormat, String name, Object value){
|
||||||
|
List<Pair> params = new ArrayList<Pair>();
|
||||||
|
|
||||||
|
// preconditions
|
||||||
|
if (name == null || name.isEmpty() || value == null) return params;
|
||||||
|
|
||||||
|
Collection valueCollection = null;
|
||||||
|
if (value instanceof Collection) {
|
||||||
|
valueCollection = (Collection) value;
|
||||||
|
} else {
|
||||||
|
params.add(new Pair(name, parameterToString(value)));
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueCollection.isEmpty()){
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the collection format
|
||||||
|
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv
|
||||||
|
|
||||||
|
// create the params based on the collection format
|
||||||
|
if (collectionFormat.equals("multi")) {
|
||||||
|
for (Object item : valueCollection) {
|
||||||
|
params.add(new Pair(name, parameterToString(item)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
String delimiter = ",";
|
||||||
|
|
||||||
|
if (collectionFormat.equals("csv")) {
|
||||||
|
delimiter = ",";
|
||||||
|
} else if (collectionFormat.equals("ssv")) {
|
||||||
|
delimiter = " ";
|
||||||
|
} else if (collectionFormat.equals("tsv")) {
|
||||||
|
delimiter = "\t";
|
||||||
|
} else if (collectionFormat.equals("pipes")) {
|
||||||
|
delimiter = "|";
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder() ;
|
||||||
|
for (Object item : valueCollection) {
|
||||||
|
sb.append(delimiter);
|
||||||
|
sb.append(parameterToString(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
params.add(new Pair(name, sb.substring(1)));
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the Accept header's value from the given accepts array:
|
||||||
|
* if JSON exists in the given array, use it;
|
||||||
|
* otherwise use all of them (joining into a string)
|
||||||
|
*
|
||||||
|
* @param accepts The accepts array to select from
|
||||||
|
* @return The Accept header to use. If the given array is empty,
|
||||||
|
* null will be returned (not to set the Accept header explicitly).
|
||||||
|
*/
|
||||||
|
public String selectHeaderAccept(String[] accepts) {
|
||||||
|
if (accepts.length == 0) return null;
|
||||||
|
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
||||||
|
return StringUtil.join(accepts, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the Content-Type header's value from the given array:
|
||||||
|
* if JSON exists in the given array, use it;
|
||||||
|
* otherwise use the first one of the array.
|
||||||
|
*
|
||||||
|
* @param contentTypes The Content-Type array to select from
|
||||||
|
* @return The Content-Type header to use. If the given array is empty,
|
||||||
|
* JSON will be used.
|
||||||
|
*/
|
||||||
|
public String selectHeaderContentType(String[] contentTypes) {
|
||||||
|
if (contentTypes.length == 0) return "application/json";
|
||||||
|
if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json";
|
||||||
|
return contentTypes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape the given string to be used as URL query value.
|
||||||
|
*/
|
||||||
|
public String escapeString(String str) {
|
||||||
|
try {
|
||||||
|
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize the given Java object into string according the given
|
||||||
|
* Content-Type (only JSON is supported for now).
|
||||||
|
*/
|
||||||
|
public String serialize(Object obj, String contentType) throws ApiException {
|
||||||
|
if (contentType.startsWith("application/json")) {
|
||||||
|
return json.serialize(obj);
|
||||||
|
} else {
|
||||||
|
throw new ApiException(400, "can not serialize object into Content-Type: " + contentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize response body to Java object according to the Content-Type.
|
||||||
|
*/
|
||||||
|
public <T> T deserialize(ClientResponse response, TypeRef returnType) throws ApiException {
|
||||||
|
String contentType = null;
|
||||||
|
List<String> contentTypes = response.getHeaders().get("Content-Type");
|
||||||
|
if (contentTypes != null && !contentTypes.isEmpty())
|
||||||
|
contentType = contentTypes.get(0);
|
||||||
|
if (contentType == null)
|
||||||
|
throw new ApiException(500, "missing Content-Type in response");
|
||||||
|
|
||||||
|
String body;
|
||||||
|
if (response.hasEntity())
|
||||||
|
body = (String) response.getEntity(String.class);
|
||||||
|
else
|
||||||
|
body = "";
|
||||||
|
|
||||||
|
if (contentType.startsWith("application/json")) {
|
||||||
|
return json.deserialize(body, returnType);
|
||||||
|
} else {
|
||||||
|
throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoke API by sending HTTP request with the given options.
|
||||||
|
*
|
||||||
|
* @param path The sub-path of the HTTP URL
|
||||||
|
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
|
||||||
|
* @param queryParams The query parameters
|
||||||
|
* @param body The request body object
|
||||||
|
* @param headerParams The header parameters
|
||||||
|
* @param formParams The form parameters
|
||||||
|
* @param accept The request's Accept header
|
||||||
|
* @param contentType The request's Content-Type header
|
||||||
|
* @param authNames The authentications to apply
|
||||||
|
* @param returnType The return type into which to deserialize the response
|
||||||
|
* @return The response body in type of string
|
||||||
|
*/
|
||||||
|
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException {
|
||||||
|
updateParamsForAuth(authNames, queryParams, headerParams);
|
||||||
|
|
||||||
|
Client client = getClient();
|
||||||
|
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append("?");
|
||||||
|
if (queryParams != null){
|
||||||
|
for (Pair queryParam : queryParams){
|
||||||
|
if (!queryParam.getName().isEmpty()) {
|
||||||
|
b.append(escapeString(queryParam.getName()));
|
||||||
|
b.append("=");
|
||||||
|
b.append(escapeString(queryParam.getValue()));
|
||||||
|
b.append("&");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String querystring = b.substring(0, b.length() - 1);
|
||||||
|
|
||||||
|
Builder builder;
|
||||||
|
if (accept == null)
|
||||||
|
builder = client.resource(basePath + path + querystring).getRequestBuilder();
|
||||||
|
else
|
||||||
|
builder = client.resource(basePath + path + querystring).accept(accept);
|
||||||
|
|
||||||
|
for (String key : headerParams.keySet()) {
|
||||||
|
builder = builder.header(key, headerParams.get(key));
|
||||||
|
}
|
||||||
|
for (String key : defaultHeaderMap.keySet()) {
|
||||||
|
if (!headerParams.containsKey(key)) {
|
||||||
|
builder = builder.header(key, defaultHeaderMap.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String encodedFormParams = null;
|
||||||
|
if (contentType.startsWith("multipart/form-data")) {
|
||||||
|
FormDataMultiPart mp = new FormDataMultiPart();
|
||||||
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
|
if (param.getValue() instanceof File) {
|
||||||
|
File file = (File) param.getValue();
|
||||||
|
mp.field(param.getKey(), file.getName());
|
||||||
|
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
} else {
|
||||||
|
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body = mp;
|
||||||
|
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||||
|
encodedFormParams = this.getXWWWFormUrlencodedParams(formParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientResponse response = null;
|
||||||
|
|
||||||
|
if ("GET".equals(method)) {
|
||||||
|
response = (ClientResponse) builder.get(ClientResponse.class);
|
||||||
|
} else if ("POST".equals(method)) {
|
||||||
|
if (encodedFormParams != null) {
|
||||||
|
response = builder.type(contentType).post(ClientResponse.class, encodedFormParams);
|
||||||
|
} else if (body == null) {
|
||||||
|
response = builder.post(ClientResponse.class, null);
|
||||||
|
} else if (body instanceof FormDataMultiPart) {
|
||||||
|
response = builder.type(contentType).post(ClientResponse.class, body);
|
||||||
|
} else {
|
||||||
|
response = builder.type(contentType).post(ClientResponse.class, serialize(body, contentType));
|
||||||
|
}
|
||||||
|
} else if ("PUT".equals(method)) {
|
||||||
|
if (encodedFormParams != null) {
|
||||||
|
response = builder.type(contentType).put(ClientResponse.class, encodedFormParams);
|
||||||
|
} else if(body == null) {
|
||||||
|
response = builder.put(ClientResponse.class, serialize(body, contentType));
|
||||||
|
} else {
|
||||||
|
response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType));
|
||||||
|
}
|
||||||
|
} else if ("DELETE".equals(method)) {
|
||||||
|
if (encodedFormParams != null) {
|
||||||
|
response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams);
|
||||||
|
} else if(body == null) {
|
||||||
|
response = builder.delete(ClientResponse.class);
|
||||||
|
} else {
|
||||||
|
response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) {
|
||||||
|
return null;
|
||||||
|
} else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
|
||||||
|
if (returnType == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return deserialize(response, returnType);
|
||||||
|
} else {
|
||||||
|
String message = "error";
|
||||||
|
String respBody = null;
|
||||||
|
if (response.hasEntity()) {
|
||||||
|
try {
|
||||||
|
respBody = String.valueOf(response.getEntity(String.class));
|
||||||
|
message = respBody;
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ApiException(
|
||||||
|
response.getStatusInfo().getStatusCode(),
|
||||||
|
message,
|
||||||
|
response.getHeaders(),
|
||||||
|
respBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update query and header parameters based on authentication settings.
|
||||||
|
*
|
||||||
|
* @param authNames The authentications to apply
|
||||||
|
*/
|
||||||
|
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
for (String authName : authNames) {
|
||||||
|
Authentication auth = authentications.get(authName);
|
||||||
|
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
|
||||||
|
auth.applyToParams(queryParams, headerParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode the given form parameters as request body.
|
||||||
|
*/
|
||||||
|
private String getXWWWFormUrlencodedParams(Map<String, Object> formParams) {
|
||||||
|
StringBuilder formParamBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (Entry<String, Object> param : formParams.entrySet()) {
|
||||||
|
String keyStr = param.getKey();
|
||||||
|
String valueStr = parameterToString(param.getValue());
|
||||||
|
try {
|
||||||
|
formParamBuilder.append(URLEncoder.encode(param.getKey(), "utf8"))
|
||||||
|
.append("=")
|
||||||
|
.append(URLEncoder.encode(valueStr, "utf8"));
|
||||||
|
formParamBuilder.append("&");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// move on to next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String encodedFormParams = formParamBuilder.toString();
|
||||||
|
if (encodedFormParams.endsWith("&")) {
|
||||||
|
encodedFormParams = encodedFormParams.substring(0, encodedFormParams.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return encodedFormParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an existing client or create a new client to handle HTTP request.
|
||||||
|
*/
|
||||||
|
private Client getClient() {
|
||||||
|
if(!hostMap.containsKey(basePath)) {
|
||||||
|
Client client = Client.create();
|
||||||
|
if (debugging)
|
||||||
|
client.addFilter(new LoggingFilter());
|
||||||
|
hostMap.put(basePath, client);
|
||||||
|
}
|
||||||
|
return hostMap.get(basePath);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class ApiException extends Exception {
|
||||||
|
private int code = 0;
|
||||||
|
private String message = null;
|
||||||
|
private Map<String, List<String>> responseHeaders = null;
|
||||||
|
private String responseBody = null;
|
||||||
|
|
||||||
|
public ApiException() {}
|
||||||
|
|
||||||
|
public ApiException(int code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
this.responseHeaders = responseHeaders;
|
||||||
|
this.responseBody = responseBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTTP response headers.
|
||||||
|
*/
|
||||||
|
public Map<String, List<String>> getResponseHeaders() {
|
||||||
|
return responseHeaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTTP response body.
|
||||||
|
*/
|
||||||
|
public String getResponseBody() {
|
||||||
|
return responseBody;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class Configuration {
|
||||||
|
private static ApiClient defaultApiClient = new ApiClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default API client, which would be used when creating API
|
||||||
|
* instances without providing an API client.
|
||||||
|
*/
|
||||||
|
public static ApiClient getDefaultApiClient() {
|
||||||
|
return defaultApiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default API client, which would be used when creating API
|
||||||
|
* instances without providing an API client.
|
||||||
|
*/
|
||||||
|
public static void setDefaultApiClient(ApiClient apiClient) {
|
||||||
|
defaultApiClient = apiClient;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.*;
|
||||||
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
import com.fasterxml.jackson.datatype.joda.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class JSON {
|
||||||
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
|
public JSON() {
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
mapper.registerModule(new JodaModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize the given Java object into JSON string.
|
||||||
|
*/
|
||||||
|
public String serialize(Object obj) throws ApiException {
|
||||||
|
try {
|
||||||
|
if (obj != null)
|
||||||
|
return mapper.writeValueAsString(obj);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ApiException(400, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize the given JSON string to Java object.
|
||||||
|
*
|
||||||
|
* @param body The JSON string
|
||||||
|
* @param returnType The type to deserialize inot
|
||||||
|
* @return The deserialized Java object
|
||||||
|
*/
|
||||||
|
public <T> T deserialize(String body, TypeRef returnType) throws ApiException {
|
||||||
|
JavaType javaType = mapper.constructType(returnType.getType());
|
||||||
|
try {
|
||||||
|
return mapper.readValue(body, javaType);
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (returnType.getType().equals(String.class))
|
||||||
|
return (T) body;
|
||||||
|
else
|
||||||
|
throw new ApiException(500, e.getMessage(), null, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class Pair {
|
||||||
|
private String name = "";
|
||||||
|
private String value = "";
|
||||||
|
|
||||||
|
public Pair (String name, String value) {
|
||||||
|
setName(name);
|
||||||
|
setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setName(String name) {
|
||||||
|
if (!isValidString(name)) return;
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setValue(String value) {
|
||||||
|
if (!isValidString(value)) return;
|
||||||
|
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidString(String arg) {
|
||||||
|
if (arg == null) return false;
|
||||||
|
if (arg.trim().isEmpty()) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class StringUtil {
|
||||||
|
/**
|
||||||
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
*
|
||||||
|
* @param array The array
|
||||||
|
* @param value The value to search
|
||||||
|
* @return true if the array contains the value
|
||||||
|
*/
|
||||||
|
public static boolean containsIgnoreCase(String[] array, String value) {
|
||||||
|
for (String str : array) {
|
||||||
|
if (value == null && str == null) return true;
|
||||||
|
if (value != null && value.equalsIgnoreCase(str)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join an array of strings with the given separator.
|
||||||
|
* <p>
|
||||||
|
* Note: This might be replaced by utility method from commons-lang or guava someday
|
||||||
|
* if one of those libraries is added as dependency.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param array The array of strings
|
||||||
|
* @param separator The separator
|
||||||
|
* @return the resulting string
|
||||||
|
*/
|
||||||
|
public static String join(String[] array, String separator) {
|
||||||
|
int len = array.length;
|
||||||
|
if (len == 0) return "";
|
||||||
|
|
||||||
|
StringBuilder out = new StringBuilder();
|
||||||
|
out.append(array[0]);
|
||||||
|
for (int i = 1; i < len; i++) {
|
||||||
|
out.append(separator).append(array[i]);
|
||||||
|
}
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package io.swagger.client;
|
||||||
|
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class TypeRef<T> {
|
||||||
|
private final Type type;
|
||||||
|
|
||||||
|
public TypeRef() {
|
||||||
|
this.type = getGenericType(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Type getGenericType(Class<?> klass) {
|
||||||
|
Type superclass = klass.getGenericSuperclass();
|
||||||
|
if (superclass instanceof Class) {
|
||||||
|
throw new RuntimeException("No type parameter provided");
|
||||||
|
}
|
||||||
|
ParameterizedType parameterized = (ParameterizedType) superclass;
|
||||||
|
return parameterized.getActualTypeArguments()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,407 @@
|
|||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.ApiClient;
|
||||||
|
import io.swagger.client.Configuration;
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import io.swagger.client.model.Pet;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class PetApi {
|
||||||
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
public PetApi() {
|
||||||
|
this(Configuration.getDefaultApiClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public PetApi(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient getApiClient() {
|
||||||
|
return apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiClient(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing pet
|
||||||
|
*
|
||||||
|
* @param body Pet object that needs to be added to the store
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void updatePet (Pet body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new pet to the store
|
||||||
|
*
|
||||||
|
* @param body Pet object that needs to be added to the store
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void addPet (Pet body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds Pets by status
|
||||||
|
* Multiple status values can be provided with comma seperated strings
|
||||||
|
* @param status Status values that need to be considered for filter
|
||||||
|
* @return List<Pet>
|
||||||
|
*/
|
||||||
|
public List<Pet> findPetsByStatus (List<String> status) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
queryParams.addAll(apiClient.parameterToPairs("multi", "status", status));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<List<Pet>>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds Pets by tags
|
||||||
|
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* @param tags Tags to filter by
|
||||||
|
* @return List<Pet>
|
||||||
|
*/
|
||||||
|
public List<Pet> findPetsByTags (List<String> tags) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<List<Pet>>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find pet by ID
|
||||||
|
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
|
* @param petId ID of pet that needs to be fetched
|
||||||
|
* @return Pet
|
||||||
|
*/
|
||||||
|
public Pet getPetById (Long petId) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'petId' is set
|
||||||
|
if (petId == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<Pet>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
*
|
||||||
|
* @param petId ID of pet that needs to be updated
|
||||||
|
* @param name Updated name of the pet
|
||||||
|
* @param status Updated status of the pet
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void updatePetWithForm (String petId, String name, String status) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'petId' is set
|
||||||
|
if (petId == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (name != null)
|
||||||
|
formParams.put("name", name);
|
||||||
|
if (status != null)
|
||||||
|
formParams.put("status", status);
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
"application/x-www-form-urlencoded"
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a pet
|
||||||
|
*
|
||||||
|
* @param petId Pet id to delete
|
||||||
|
* @param apiKey
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void deletePet (Long petId, String apiKey) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'petId' is set
|
||||||
|
if (petId == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet/{petId}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (apiKey != null)
|
||||||
|
headerParams.put("api_key", apiClient.parameterToString(apiKey));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uploads an image
|
||||||
|
*
|
||||||
|
* @param petId ID of pet to update
|
||||||
|
* @param additionalMetadata Additional data to pass to server
|
||||||
|
* @param file file to upload
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'petId' is set
|
||||||
|
if (petId == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (additionalMetadata != null)
|
||||||
|
formParams.put("additionalMetadata", additionalMetadata);
|
||||||
|
if (file != null)
|
||||||
|
formParams.put("file", file);
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
"multipart/form-data"
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "petstore_auth" };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,215 @@
|
|||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.ApiClient;
|
||||||
|
import io.swagger.client.Configuration;
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import io.swagger.client.model.Order;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class StoreApi {
|
||||||
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
public StoreApi() {
|
||||||
|
this(Configuration.getDefaultApiClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreApi(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient getApiClient() {
|
||||||
|
return apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiClient(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns pet inventories by status
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* @return Map<String, Integer>
|
||||||
|
*/
|
||||||
|
public Map<String, Integer> getInventory () throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/store/inventory".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { "api_key" };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<Map<String, Integer>>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place an order for a pet
|
||||||
|
*
|
||||||
|
* @param body order placed for purchasing the pet
|
||||||
|
* @return Order
|
||||||
|
*/
|
||||||
|
public Order placeOrder (Order body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/store/order".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<Order>() {};
|
||||||
|
return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find purchase order by ID
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* @param orderId ID of pet that needs to be fetched
|
||||||
|
* @return Order
|
||||||
|
*/
|
||||||
|
public Order getOrderById (String orderId) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'orderId' is set
|
||||||
|
if (orderId == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<Order>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* @param orderId ID of the order that needs to be deleted
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void deleteOrder (String orderId) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'orderId' is set
|
||||||
|
if (orderId == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,386 @@
|
|||||||
|
package io.swagger.client.api;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.ApiClient;
|
||||||
|
import io.swagger.client.Configuration;
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import io.swagger.client.model.User;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class UserApi {
|
||||||
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
public UserApi() {
|
||||||
|
this(Configuration.getDefaultApiClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserApi(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiClient getApiClient() {
|
||||||
|
return apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiClient(ApiClient apiClient) {
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* @param body Created user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void createUser (User body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*
|
||||||
|
* @param body List of user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void createUsersWithArrayInput (List<User> body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates list of users with given input array
|
||||||
|
*
|
||||||
|
* @param body List of user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void createUsersWithListInput (List<User> body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user into the system
|
||||||
|
*
|
||||||
|
* @param username The user name for login
|
||||||
|
* @param password The password for login in clear text
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String loginUser (String username, String password) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/login".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
queryParams.addAll(apiClient.parameterToPairs("", "username", username));
|
||||||
|
|
||||||
|
queryParams.addAll(apiClient.parameterToPairs("", "password", password));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<String>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void logoutUser () throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/logout".replaceAll("\\{format\\}","json");
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user by user name
|
||||||
|
*
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public User getUserByName (String username) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'username' is set
|
||||||
|
if (username == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
TypeRef returnType = new TypeRef<User>() {};
|
||||||
|
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updated user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* @param username name that need to be deleted
|
||||||
|
* @param body Updated user object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void updateUser (String username, User body) throws ApiException {
|
||||||
|
Object postBody = body;
|
||||||
|
|
||||||
|
// verify the required parameter 'username' is set
|
||||||
|
if (username == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete user
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* @param username The name that needs to be deleted
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void deleteUser (String username) throws ApiException {
|
||||||
|
Object postBody = null;
|
||||||
|
|
||||||
|
// verify the required parameter 'username' is set
|
||||||
|
if (username == null) {
|
||||||
|
throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String path = "/user/{username}".replaceAll("\\{format\\}","json")
|
||||||
|
.replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString()));
|
||||||
|
|
||||||
|
// query params
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String[] accepts = {
|
||||||
|
"application/json", "application/xml"
|
||||||
|
};
|
||||||
|
final String accept = apiClient.selectHeaderAccept(accepts);
|
||||||
|
|
||||||
|
final String[] contentTypes = {
|
||||||
|
|
||||||
|
};
|
||||||
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
|
String[] authNames = new String[] { };
|
||||||
|
|
||||||
|
apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package io.swagger.client.auth;
|
||||||
|
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class ApiKeyAuth implements Authentication {
|
||||||
|
private final String location;
|
||||||
|
private final String paramName;
|
||||||
|
|
||||||
|
private String apiKey;
|
||||||
|
private String apiKeyPrefix;
|
||||||
|
|
||||||
|
public ApiKeyAuth(String location, String paramName) {
|
||||||
|
this.location = location;
|
||||||
|
this.paramName = paramName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParamName() {
|
||||||
|
return paramName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApiKey() {
|
||||||
|
return apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiKey(String apiKey) {
|
||||||
|
this.apiKey = apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApiKeyPrefix() {
|
||||||
|
return apiKeyPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||||
|
this.apiKeyPrefix = apiKeyPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
String value;
|
||||||
|
if (apiKeyPrefix != null) {
|
||||||
|
value = apiKeyPrefix + " " + apiKey;
|
||||||
|
} else {
|
||||||
|
value = apiKey;
|
||||||
|
}
|
||||||
|
if (location == "query") {
|
||||||
|
queryParams.add(new Pair(paramName, value));
|
||||||
|
} else if (location == "header") {
|
||||||
|
headerParams.put(paramName, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package io.swagger.client.auth;
|
||||||
|
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public interface Authentication {
|
||||||
|
/** Apply authentication settings to header and query params. */
|
||||||
|
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package io.swagger.client.auth;
|
||||||
|
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class HttpBasicAuth implements Authentication {
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||||
|
try {
|
||||||
|
headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8")));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.swagger.client.auth;
|
||||||
|
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class OAuth implements Authentication {
|
||||||
|
@Override
|
||||||
|
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||||
|
// TODO: support oauth
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package io.swagger.client.model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class Category {
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
private String name = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Category {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" name: ").append(name).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package io.swagger.client.model;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class Order {
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
private Long petId = null;
|
||||||
|
private Integer quantity = null;
|
||||||
|
private Date shipDate = null;
|
||||||
|
public enum StatusEnum {
|
||||||
|
placed, approved, delivered,
|
||||||
|
};
|
||||||
|
private StatusEnum status = null;
|
||||||
|
private Boolean complete = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("petId")
|
||||||
|
public Long getPetId() {
|
||||||
|
return petId;
|
||||||
|
}
|
||||||
|
public void setPetId(Long petId) {
|
||||||
|
this.petId = petId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("quantity")
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
public void setQuantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("shipDate")
|
||||||
|
public Date getShipDate() {
|
||||||
|
return shipDate;
|
||||||
|
}
|
||||||
|
public void setShipDate(Date shipDate) {
|
||||||
|
this.shipDate = shipDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "Order Status")
|
||||||
|
@JsonProperty("status")
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("complete")
|
||||||
|
public Boolean getComplete() {
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
public void setComplete(Boolean complete) {
|
||||||
|
this.complete = complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Order {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" petId: ").append(petId).append("\n");
|
||||||
|
sb.append(" quantity: ").append(quantity).append("\n");
|
||||||
|
sb.append(" shipDate: ").append(shipDate).append("\n");
|
||||||
|
sb.append(" status: ").append(status).append("\n");
|
||||||
|
sb.append(" complete: ").append(complete).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
package io.swagger.client.model;
|
||||||
|
|
||||||
|
import io.swagger.client.model.Category;
|
||||||
|
import io.swagger.client.model.Tag;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class Pet {
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
private Category category = null;
|
||||||
|
private String name = null;
|
||||||
|
private List<String> photoUrls = new ArrayList<String>();
|
||||||
|
private List<Tag> tags = new ArrayList<Tag>();
|
||||||
|
public enum StatusEnum {
|
||||||
|
available, pending, sold,
|
||||||
|
};
|
||||||
|
private StatusEnum status = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("category")
|
||||||
|
public Category getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
public void setCategory(Category category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
@JsonProperty("name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
@JsonProperty("photoUrls")
|
||||||
|
public List<String> getPhotoUrls() {
|
||||||
|
return photoUrls;
|
||||||
|
}
|
||||||
|
public void setPhotoUrls(List<String> photoUrls) {
|
||||||
|
this.photoUrls = photoUrls;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("tags")
|
||||||
|
public List<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
public void setTags(List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "pet status in the store")
|
||||||
|
@JsonProperty("status")
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Pet {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" category: ").append(category).append("\n");
|
||||||
|
sb.append(" name: ").append(name).append("\n");
|
||||||
|
sb.append(" photoUrls: ").append(photoUrls).append("\n");
|
||||||
|
sb.append(" tags: ").append(tags).append("\n");
|
||||||
|
sb.append(" status: ").append(status).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package io.swagger.client.model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class Tag {
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
private String name = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("name")
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class Tag {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" name: ").append(name).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
package io.swagger.client.model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00")
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private Long id = null;
|
||||||
|
private String username = null;
|
||||||
|
private String firstName = null;
|
||||||
|
private String lastName = null;
|
||||||
|
private String email = null;
|
||||||
|
private String password = null;
|
||||||
|
private String phone = null;
|
||||||
|
private Integer userStatus = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("id")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("username")
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("firstName")
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("lastName")
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("email")
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("password")
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "")
|
||||||
|
@JsonProperty("phone")
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(value = "User Status")
|
||||||
|
@JsonProperty("userStatus")
|
||||||
|
public Integer getUserStatus() {
|
||||||
|
return userStatus;
|
||||||
|
}
|
||||||
|
public void setUserStatus(Integer userStatus) {
|
||||||
|
this.userStatus = userStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class User {\n");
|
||||||
|
|
||||||
|
sb.append(" id: ").append(id).append("\n");
|
||||||
|
sb.append(" username: ").append(username).append("\n");
|
||||||
|
sb.append(" firstName: ").append(firstName).append("\n");
|
||||||
|
sb.append(" lastName: ").append(lastName).append("\n");
|
||||||
|
sb.append(" email: ").append(email).append("\n");
|
||||||
|
sb.append(" password: ").append(password).append("\n");
|
||||||
|
sb.append(" phone: ").append(phone).append("\n");
|
||||||
|
sb.append(" userStatus: ").append(userStatus).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 SmartBear Software
|
||||||
|
*
|
||||||
|
* 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.test.integration;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiClient;
|
||||||
|
import io.swagger.client.Pair;
|
||||||
|
import io.swagger.client.TypeRef;
|
||||||
|
import io.swagger.models.Operation;
|
||||||
|
import io.swagger.models.Response;
|
||||||
|
import io.swagger.models.Swagger;
|
||||||
|
import io.swagger.models.parameters.Parameter;
|
||||||
|
import io.swagger.models.properties.IntegerProperty;
|
||||||
|
import io.swagger.models.properties.MapProperty;
|
||||||
|
import io.swagger.models.properties.Property;
|
||||||
|
import io.swagger.util.Json;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
public class ResourceListingTestIT {
|
||||||
|
ApiClient client = new ApiClient();
|
||||||
|
Swagger swagger = null;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public void setup() throws Exception {
|
||||||
|
TypeRef<String> ref = new TypeRef<String>(){};
|
||||||
|
List<Pair> queryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> headerParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> formParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
String str = client.invokeAPI("/swagger.json", "GET", queryParams, null, headerParams, formParams, "application/json", "", new String[0], ref);
|
||||||
|
swagger = Json.mapper().readValue(str, Swagger.class);
|
||||||
|
assertNotNull(swagger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyFileInput() throws Exception {
|
||||||
|
Operation op = swagger.getPath("/pet/{petId}/uploadImage").getPost();
|
||||||
|
List<Parameter> parameters = op.getParameters();
|
||||||
|
Parameter petId = parameters.get(0);
|
||||||
|
assertEquals(petId.getName(), "petId");
|
||||||
|
assertEquals(petId.getIn(), "path");
|
||||||
|
|
||||||
|
Parameter additionalMetadata = parameters.get(1);
|
||||||
|
assertEquals(additionalMetadata.getName(), "additionalMetadata");
|
||||||
|
assertEquals(additionalMetadata.getIn(), "formData");
|
||||||
|
|
||||||
|
Parameter file = parameters.get(2);
|
||||||
|
assertEquals(file.getName(), "file");
|
||||||
|
assertEquals(file.getIn(), "formData");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyMapResponse() throws Exception {
|
||||||
|
Operation op = swagger.getPath("/store/inventory").getGet();
|
||||||
|
Response response = op.getResponses().get("200");
|
||||||
|
|
||||||
|
Property property = response.getSchema();
|
||||||
|
assertTrue(property instanceof MapProperty);
|
||||||
|
|
||||||
|
MapProperty mp = (MapProperty) property;
|
||||||
|
assertTrue(mp.getAdditionalProperties() instanceof IntegerProperty);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user