Merge pull request #1029 from swagger-api/jaxrs-server-codegen-improvements

fixed generated code to go to target/generated-sources, added maven-c…
This commit is contained in:
Tony Tam 2015-08-23 17:32:29 -07:00
commit 0fc5702e4d
37 changed files with 2154 additions and 815 deletions

View File

@ -143,7 +143,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (String templateName : config.modelTemplateFiles().keySet()) { for (String templateName : config.modelTemplateFiles().keySet()) {
String suffix = config.modelTemplateFiles().get(templateName); String suffix = config.modelTemplateFiles().get(templateName);
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix; String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
if (!config.shouldOverwrite(filename)) { if ( new File(filename).exists() && !config.shouldOverwrite(filename)) {
continue; continue;
} }
String templateFile = getFullTemplateFile(config, templateName); String templateFile = getFullTemplateFile(config, templateName);
@ -195,7 +195,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
for (String templateName : config.apiTemplateFiles().keySet()) { for (String templateName : config.apiTemplateFiles().keySet()) {
String filename = config.apiFilename(templateName, tag); String filename = config.apiFilename(templateName, tag);
if (!config.shouldOverwrite(filename) && new File(filename).exists()) { if( new File( filename ).exists() && !config.shouldOverwrite(filename)) {
continue; continue;
} }
@ -267,7 +267,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
of.mkdirs(); of.mkdirs();
} }
String outputFilename = outputFolder + File.separator + support.destinationFilename; String outputFilename = outputFolder + File.separator + support.destinationFilename;
if (!config.shouldOverwrite(outputFilename)) { if (new File( outputFilename ).exists() && !config.shouldOverwrite(outputFilename)) {
continue; continue;
} }

View File

@ -5,11 +5,15 @@ 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;
import io.swagger.models.Operation; import io.swagger.models.Operation;
import io.swagger.models.Swagger;
import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property; import io.swagger.models.properties.Property;
import io.swagger.util.Json;
import java.io.File; import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@ -17,6 +21,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig { public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig {
public static final String DEFAULT_IMPL_SOURCE_FOLDER = "src/main/java";
protected String invokerPackage = "io.swagger.api"; protected String invokerPackage = "io.swagger.api";
protected String groupId = "io.swagger"; protected String groupId = "io.swagger";
protected String artifactId = "swagger-jaxrs-server"; protected String artifactId = "swagger-jaxrs-server";
@ -26,9 +31,9 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
public JaxRSServerCodegen() { public JaxRSServerCodegen() {
super.processOpts(); super.processOpts();
sourceFolder = "src/gen/java"; sourceFolder = "target/generated-sources";
outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "generated-code/javaJaxRS"); outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "target/generated-sources");
modelTemplateFiles.put("model.mustache", ".java"); modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java");
apiTemplateFiles.put("apiService.mustache", ".java"); apiTemplateFiles.put("apiService.mustache", ".java");
@ -169,7 +174,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
int ix = result.lastIndexOf('/'); int ix = result.lastIndexOf('/');
result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java"; result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java";
String output = System.getProperty("swagger.codegen.jaxrs.impl.source"); String output = System.getProperty("swagger.codegen.jaxrs.impl.source", DEFAULT_IMPL_SOURCE_FOLDER);
if (output != null) { if (output != null) {
result = result.replace(apiFileFolder(), implFileFolder(output)); result = result.replace(apiFileFolder(), implFileFolder(output));
} }
@ -177,7 +182,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
int ix = result.lastIndexOf('/'); int ix = result.lastIndexOf('/');
result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java"; result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java";
String output = System.getProperty("swagger.codegen.jaxrs.impl.source"); String output = System.getProperty("swagger.codegen.jaxrs.impl.source", DEFAULT_IMPL_SOURCE_FOLDER);
if (output != null) { if (output != null) {
result = result.replace(apiFileFolder(), implFileFolder(output)); result = result.replace(apiFileFolder(), implFileFolder(output));
} }
@ -189,11 +194,31 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf
return result; return result;
} }
@Override
public void processSwagger(Swagger swagger) {
super.processSwagger(swagger);
try {
File file = new File( outputFolder + "/src/main/resources/swagger.json" );
file.getParentFile().mkdirs();
FileWriter swaggerFile = new FileWriter(file);
swaggerFile.write( Json.pretty(swagger));
swaggerFile.flush();
swaggerFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private String implFileFolder(String output) { private String implFileFolder(String output) {
return outputFolder + "/" + output + "/" + apiPackage().replace('.', File.separatorChar); return outputFolder + "/" + output + "/" + apiPackage().replace('.', File.separatorChar);
} }
public boolean shouldOverwrite(String filename) { public boolean shouldOverwrite(String filename) {
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java"); return filename.startsWith( outputFolder + File.separatorChar + sourceFolder);
// return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java")
// && !filename.endsWith("ServiceFactory.java");
} }
} }

View File

@ -1,10 +1,5 @@
# Swagger generated server # Swagger generated server
## Overview ## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project using the
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This JAX-RS template.
is an example of building a swagger-enabled scalatra server.
This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra)

View File

@ -50,7 +50,6 @@
</goals> </goals>
<configuration> <configuration>
<scanIntervalSeconds>0</scanIntervalSeconds> <scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
@ -75,12 +74,29 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source>src/gen/java</source> <source>target/generated-sources</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.1.3-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger.json</inputSpec>
<language>jaxrs</language>
<output>.</output>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
@ -148,7 +164,7 @@
</repository> </repository>
</repositories> </repositories>
<properties> <properties>
<swagger-core-version>1.5.0</swagger-core-version> <swagger-core-version>1.5.1-SNAPSHOT</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.13</jersey-version>
<slf4j-version>1.6.3</slf4j-version> <slf4j-version>1.6.3</slf4j-version>

View File

@ -37,7 +37,7 @@ public class Generator {
throw new BadRequestException(400, "No swagger specification was supplied"); throw new BadRequestException(400, "No swagger specification was supplied");
} }
} else { } else {
swagger = new SwaggerParser().read(node, true); swagger = new SwaggerParser().read(node);
} }
if (swagger == null) { if (swagger == null) {
throw new BadRequestException(400, "The swagger specification supplied was not valid"); throw new BadRequestException(400, "The swagger specification supplied was not valid");
@ -97,7 +97,7 @@ public class Generator {
throw new BadRequestException(400, "No swagger specification was supplied"); throw new BadRequestException(400, "No swagger specification was supplied");
} }
} else { } else {
swagger = new SwaggerParser().read(node, true); swagger = new SwaggerParser().read(node);
} }
if (swagger == null) { if (swagger == null) {
throw new BadRequestException(400, "The swagger specification supplied was not valid"); throw new BadRequestException(400, "The swagger specification supplied was not valid");

View File

@ -0,0 +1,8 @@
# Swagger Inflector
Run with
```
mvn package jetty:run
``

View File

@ -0,0 +1,10 @@
controllerPackage: io.swagger.handler
modelPackage: io.swagger.model
swaggerUrl: ./src/main/swagger/swagger.json
modelMappings:
User : io.swagger.model.User
Category : io.swagger.model.Category
Pet : io.swagger.model.Pet
Tag : io.swagger.model.Tag
Order : io.swagger.model.Order

View File

@ -0,0 +1,174 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-inflector-server</artifactId>
<packaging>jar</packaging>
<name>swagger-inflector-server</name>
<version>1.0.0</version>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<build>
<defaultGoal>install</defaultGoal>
<directory>target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<excludes>
<exclude>**/logback.xml</exclude>
</excludes>
<archive>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
<implementation-version>${project.version}</implementation-version>
<package>io.swagger</package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<monitoredDirName>.</monitoredDirName>
<scanTargets>
<scanTarget>inflector.yaml</scanTarget>
<scanTarget>src/main/swagger/swagger.yaml</scanTarget>
</scanTargets>
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
<httpConnector>
<port>8080</port>
<idleTimeout>60000</idleTimeout>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey2-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
<scope>provided</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<!-- Utils -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang-version}</version>
</dependency>
<!-- http client -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-inflector</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<properties>
<maven-plugin-version>1.0.0</maven-plugin-version>
<swagger-core-version>1.5.0</swagger-core-version>
<swagger-parser-version>1.0.8</swagger-parser-version>
<jackson-version>2.4.2</jackson-version>
<joda-time-version>2.2</joda-time-version>
<joda-version>1.2</joda-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey2-version>2.6</jersey2-version>
<servlet-api-version>2.5</servlet-api-version>
<commons-io-version>2.4</commons-io-version>
<commons-lang-version>2.4</commons-lang-version>
<commons-csv-version>1.1</commons-csv-version>
<logback-version>1.0.1</logback-version>
<junit-version>4.8.2</junit-version>
<slf4j-version>1.6.3</slf4j-version>
</properties>
</project>

View File

@ -0,0 +1,51 @@
package io.swagger.handler;
import io.swagger.inflector.models.RequestContext;
import io.swagger.inflector.models.ResponseContext;
import javax.ws.rs.core.Response.Status;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import java.io.File;
import java.util.List;
import io.swagger.model.*;
import io.swagger.model.Pet;
import java.io.File;
public class PetController {
public ResponseContext updatePet(RequestContext request ,Pet body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext addPet(RequestContext request ,Pet body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext findPetsByStatus(RequestContext request ,List<String> status)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext findPetsByTags(RequestContext request ,List<String> tags)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext getPetById(RequestContext request ,Long petId)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext updatePetWithForm(RequestContext request ,String petId,String name,String status)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext deletePet(RequestContext request ,Long petId,String apiKey)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext uploadFile(RequestContext request ,Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
}

View File

@ -0,0 +1,35 @@
package io.swagger.handler;
import io.swagger.inflector.models.RequestContext;
import io.swagger.inflector.models.ResponseContext;
import javax.ws.rs.core.Response.Status;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import java.io.File;
import java.util.List;
import io.swagger.model.*;
import java.util.Map;
import io.swagger.model.Order;
public class StoreController {
public ResponseContext getInventory(RequestContext request )
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext placeOrder(RequestContext request ,Order body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext getOrderById(RequestContext request ,String orderId)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext deleteOrder(RequestContext request ,String orderId)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
}

View File

@ -0,0 +1,51 @@
package io.swagger.handler;
import io.swagger.inflector.models.RequestContext;
import io.swagger.inflector.models.ResponseContext;
import javax.ws.rs.core.Response.Status;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import java.io.File;
import java.util.List;
import io.swagger.model.*;
import io.swagger.model.User;
import java.util.*;
public class UserController {
public ResponseContext createUser(RequestContext request ,User body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext createUsersWithArrayInput(RequestContext request ,List<User> body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext createUsersWithListInput(RequestContext request ,List<User> body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext loginUser(RequestContext request ,String username,String password)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext logoutUser(RequestContext request )
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext getUserByName(RequestContext request ,String username)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext updateUser(RequestContext request ,String username,User body)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
public ResponseContext deleteUser(RequestContext request ,String username)
{
return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" );
}
}

View File

@ -1,8 +1,8 @@
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;
@ -14,8 +14,8 @@ public class Pet {
private Long id = null; private Long id = null;
private Category category = null; private Category category = null;
private String name = null; private String name = null;
private List<String> photoUrls = new ArrayList<String>() ; private List<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>() ; private List<Tag> tags = new ArrayList<Tag>();
public enum StatusEnum { public enum StatusEnum {
available, pending, sold, available, pending, sold,
}; };

View File

@ -0,0 +1,762 @@
{
"swagger" : "2.0",
"info" : {
"description" : "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version" : "1.0.0",
"title" : "Swagger Petstore",
"termsOfService" : "http://swagger.io/terms/",
"contact" : {
"email" : "apiteam@swagger.io"
},
"license" : {
"name" : "Apache 2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host" : "petstore.swagger.io",
"basePath" : "/v2",
"schemes" : [ "http" ],
"paths" : {
"/pet" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "Add a new pet to the store",
"description" : "",
"operationId" : "addPet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"put" : {
"tags" : [ "pet" ],
"summary" : "Update an existing pet",
"description" : "",
"operationId" : "updatePet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"405" : {
"description" : "Validation exception"
},
"404" : {
"description" : "Pet not found"
},
"400" : {
"description" : "Invalid ID supplied"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByStatus" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by status",
"description" : "Multiple status values can be provided with comma seperated strings",
"operationId" : "findPetsByStatus",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "status",
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi",
"default" : "available"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid status value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByTags" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by tags",
"description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
"operationId" : "findPetsByTags",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid tag value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Find pet by ID",
"description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
"operationId" : "getPetById",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"404" : {
"description" : "Pet not found"
},
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Pet"
}
},
"400" : {
"description" : "Invalid ID supplied"
}
},
"security" : [ {
"api_key" : [ ]
}, {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"post" : {
"tags" : [ "pet" ],
"summary" : "Updates a pet in the store with form data",
"description" : "",
"operationId" : "updatePetWithForm",
"consumes" : [ "application/x-www-form-urlencoded" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be updated",
"required" : true,
"type" : "string"
}, {
"name" : "name",
"in" : "formData",
"description" : "Updated name of the pet",
"required" : false,
"type" : "string"
}, {
"name" : "status",
"in" : "formData",
"description" : "Updated status of the pet",
"required" : false,
"type" : "string"
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"delete" : {
"tags" : [ "pet" ],
"summary" : "Deletes a pet",
"description" : "",
"operationId" : "deletePet",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "api_key",
"in" : "header",
"description" : "",
"required" : false,
"type" : "string"
}, {
"name" : "petId",
"in" : "path",
"description" : "Pet id to delete",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"400" : {
"description" : "Invalid pet value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}/uploadImage" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "uploads an image",
"description" : "",
"operationId" : "uploadFile",
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to update",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "additionalMetadata",
"in" : "formData",
"description" : "Additional data to pass to server",
"required" : false,
"type" : "string"
}, {
"name" : "file",
"in" : "formData",
"description" : "file to upload",
"required" : false,
"type" : "file"
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/store/inventory" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Returns pet inventories by status",
"description" : "Returns a map of status codes to quantities",
"operationId" : "getInventory",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"security" : [ {
"api_key" : [ ]
} ]
}
},
"/store/order" : {
"post" : {
"tags" : [ "store" ],
"summary" : "Place an order for a pet",
"description" : "",
"operationId" : "placeOrder",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "order placed for purchasing the pet",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Order"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid Order"
}
}
}
},
"/store/order/{orderId}" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Find purchase order by ID",
"description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
"operationId" : "getOrderById",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "Order not found"
},
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid ID supplied"
}
}
},
"delete" : {
"tags" : [ "store" ],
"summary" : "Delete purchase order by ID",
"description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"operationId" : "deleteOrder",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of the order that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "Order not found"
},
"400" : {
"description" : "Invalid ID supplied"
}
}
}
},
"/user" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Create user",
"description" : "This can only be done by the logged in user.",
"operationId" : "createUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : false,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithArray" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithArrayInput",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : false,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithList" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithListInput",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : false,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/login" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs user into the system",
"description" : "",
"operationId" : "loginUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "query",
"description" : "The user name for login",
"required" : false,
"type" : "string"
}, {
"name" : "password",
"in" : "query",
"description" : "The password for login in clear text",
"required" : false,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "string"
}
},
"400" : {
"description" : "Invalid username/password supplied"
}
}
}
},
"/user/logout" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs out current logged in user session",
"description" : "",
"operationId" : "logoutUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/{username}" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Get user by user name",
"description" : "",
"operationId" : "getUserByName",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be fetched. Use user1 for testing. ",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "User not found"
},
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/User"
},
"examples" : {
"application/json" : {
"id" : 1,
"username" : "johnp",
"firstName" : "John",
"lastName" : "Public",
"email" : "johnp@swagger.io",
"password" : "-secret-",
"phone" : "0123456789",
"userStatus" : 0
}
}
},
"400" : {
"description" : "Invalid username supplied"
}
}
},
"put" : {
"tags" : [ "user" ],
"summary" : "Updated user",
"description" : "This can only be done by the logged in user.",
"operationId" : "updateUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "name that need to be deleted",
"required" : true,
"type" : "string"
}, {
"in" : "body",
"name" : "body",
"description" : "Updated user object",
"required" : false,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"404" : {
"description" : "User not found"
},
"400" : {
"description" : "Invalid user supplied"
}
}
},
"delete" : {
"tags" : [ "user" ],
"summary" : "Delete user",
"description" : "This can only be done by the logged in user.",
"operationId" : "deleteUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "User not found"
},
"400" : {
"description" : "Invalid username supplied"
}
}
}
}
},
"securityDefinitions" : {
"api_key" : {
"type" : "apiKey",
"name" : "api_key",
"in" : "header"
},
"petstore_auth" : {
"type" : "oauth2",
"authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog",
"flow" : "implicit",
"scopes" : {
"write:pets" : "modify pets in your account",
"read:pets" : "read your pets"
}
}
},
"definitions" : {
"User" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"username" : {
"type" : "string"
},
"firstName" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"email" : {
"type" : "string"
},
"password" : {
"type" : "string"
},
"phone" : {
"type" : "string"
},
"userStatus" : {
"type" : "integer",
"format" : "int32",
"description" : "User Status"
}
},
"xml" : {
"name" : "User"
}
},
"Category" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"xml" : {
"name" : "Category"
}
},
"Pet" : {
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"category" : {
"$ref" : "#/definitions/Category"
},
"name" : {
"type" : "string",
"example" : "doggie"
},
"photoUrls" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"tags" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Tag"
}
},
"status" : {
"type" : "string",
"description" : "pet status in the store",
"enum" : [ "available", "pending", "sold" ]
}
},
"xml" : {
"name" : "Pet"
}
},
"Tag" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"xml" : {
"name" : "Tag"
}
},
"Order" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"petId" : {
"type" : "integer",
"format" : "int64"
},
"quantity" : {
"type" : "integer",
"format" : "int32"
},
"shipDate" : {
"type" : "string",
"format" : "date-time"
},
"status" : {
"type" : "string",
"description" : "Order Status",
"enum" : [ "placed", "approved", "delivered" ]
},
"complete" : {
"type" : "boolean"
}
},
"xml" : {
"name" : "Order"
}
}
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>swagger-inflector</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>io.swagger.inflector.SwaggerInflector</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>swagger-inflector</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>CORSFilter</filter-name>
<filter-class>io.swagger.inflector.utils.CORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CORSFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@ -1,10 +1,5 @@
# Swagger generated server # Swagger generated server
## Overview ## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project using the
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This JAX-RS template.
is an example of building a swagger-enabled scalatra server.
This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra)

View File

@ -50,7 +50,6 @@
</goals> </goals>
<configuration> <configuration>
<scanIntervalSeconds>0</scanIntervalSeconds> <scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
@ -75,12 +74,29 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source>src/gen/java</source> <source>target/generated-sources</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.1.3-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger.json</inputSpec>
<language>jaxrs</language>
<output>.</output>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
@ -148,7 +164,7 @@
</repository> </repository>
</repositories> </repositories>
<properties> <properties>
<swagger-core-version>1.5.0</swagger-core-version> <swagger-core-version>1.5.1-SNAPSHOT</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.13</jersey-version>
<slf4j-version>1.6.3</slf4j-version> <slf4j-version>1.6.3</slf4j-version>

View File

@ -1,9 +0,0 @@
package io.swagger.api;
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
super(msg);
this.code = code;
}
}

View File

@ -1,26 +0,0 @@
package io.swagger.api;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
}

View File

@ -1,68 +0,0 @@
package io.swagger.api;
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
public static final int INFO = 3;
public static final int OK = 4;
public static final int TOO_BUSY = 5;
int code;
String type;
String message;
public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){
this.code = code;
switch(code){
case ERROR:
setType("error");
break;
case WARNING:
setType("warning");
break;
case INFO:
setType("info");
break;
case OK:
setType("ok");
break;
case TOO_BUSY:
setType("too busy");
break;
default:
setType("unknown");
break;
}
this.message = message;
}
@XmlTransient
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -1,9 +0,0 @@
package io.swagger.api;
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {
super(code, msg);
this.code = code;
}
}

View File

@ -1,148 +0,0 @@
package io.swagger.api;
import io.swagger.model.*;
import io.swagger.api.PetApiService;
import io.swagger.api.factories.PetApiServiceFactory;
import io.swagger.annotations.ApiParam;
import com.sun.jersey.multipart.FormDataParam;
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.*;
@Path("/pet")
@io.swagger.annotations.Api(value = "/pet", description = "the pet API")
public class PetApi {
private final PetApiService delegate = PetApiServiceFactory.getPetApi();
@PUT
@Consumes({ "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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"),
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
throws NotFoundException {
return delegate.updatePet(body);
}
@POST
@Consumes({ "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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
throws NotFoundException {
return delegate.addPet(body);
}
@GET
@Path("/findByStatus")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List<String> status)
throws NotFoundException {
return delegate.findPetsByStatus(status);
}
@GET
@Path("/findByTags")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") })
public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List<String> tags)
throws NotFoundException {
return delegate.findPetsByTags(tags);
}
@GET
@Path("/{petId}")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId)
throws NotFoundException {
return delegate.getPetById(petId);
}
@POST
@Path("/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
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 status of the pet" )@FormParam("status") String status)
throws NotFoundException {
return delegate.updatePetWithForm(petId,name,status);
}
@DELETE
@Path("/{petId}")
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") })
public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey,
@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId)
throws NotFoundException {
return delegate.deletePet(apiKey,petId);
}
@POST
@Path("/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
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 = "file to upload") @FormDataParam("file") InputStream inputStream,
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail)
throws NotFoundException {
return delegate.uploadFile(petId,additionalMetadata,fileDetail);
}
}

View File

@ -1,47 +0,0 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import com.sun.jersey.multipart.FormDataParam;
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;
public abstract class PetApiService {
public abstract Response updatePet(Pet body)
throws NotFoundException;
public abstract Response addPet(Pet body)
throws NotFoundException;
public abstract Response findPetsByStatus(List<String> status)
throws NotFoundException;
public abstract Response findPetsByTags(List<String> tags)
throws NotFoundException;
public abstract Response getPetById(Long petId)
throws NotFoundException;
public abstract Response updatePetWithForm(String petId,String name,String status)
throws NotFoundException;
public abstract Response deletePet(String apiKey,Long petId)
throws NotFoundException;
public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
throws NotFoundException;
}

View File

@ -1,90 +0,0 @@
package io.swagger.api;
import io.swagger.model.*;
import io.swagger.api.StoreApiService;
import io.swagger.api.factories.StoreApiServiceFactory;
import io.swagger.annotations.ApiParam;
import com.sun.jersey.multipart.FormDataParam;
import java.util.Map;
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.*;
@Path("/store")
@io.swagger.annotations.Api(value = "/store", description = "the store API")
public class StoreApi {
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
@GET
@Path("/inventory")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
public Response getInventory()
throws NotFoundException {
return delegate.getInventory();
}
@POST
@Path("/order")
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") })
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
throws NotFoundException {
return delegate.placeOrder(body);
}
@GET
@Path("/order/{orderId}")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId)
throws NotFoundException {
return delegate.getOrderById(orderId);
}
@DELETE
@Path("/order/{orderId}")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId)
throws NotFoundException {
return delegate.deleteOrder(orderId);
}
}

View File

@ -1,35 +0,0 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import com.sun.jersey.multipart.FormDataParam;
import java.util.Map;
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;
public abstract class StoreApiService {
public abstract Response getInventory()
throws NotFoundException;
public abstract Response placeOrder(Order body)
throws NotFoundException;
public abstract Response getOrderById(String orderId)
throws NotFoundException;
public abstract Response deleteOrder(String orderId)
throws NotFoundException;
}

View File

@ -1,142 +0,0 @@
package io.swagger.api;
import io.swagger.model.*;
import io.swagger.api.UserApiService;
import io.swagger.api.factories.UserApiServiceFactory;
import io.swagger.annotations.ApiParam;
import com.sun.jersey.multipart.FormDataParam;
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.*;
@Path("/user")
@io.swagger.annotations.Api(value = "/user", description = "the user API")
public class UserApi {
private final UserApiService delegate = UserApiServiceFactory.getUserApi();
@POST
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
public Response createUser(@ApiParam(value = "Created user object" ) User body)
throws NotFoundException {
return delegate.createUser(body);
}
@POST
@Path("/createWithArray")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List<User> body)
throws NotFoundException {
return delegate.createUsersWithArrayInput(body);
}
@POST
@Path("/createWithList")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List<User> body)
throws NotFoundException {
return delegate.createUsersWithListInput(body);
}
@GET
@Path("/login")
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") })
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)
throws NotFoundException {
return delegate.loginUser(username,password);
}
@GET
@Path("/logout")
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
public Response logoutUser()
throws NotFoundException {
return delegate.logoutUser();
}
@GET
@Path("/{username}")
@Produces({ "application/json", "application/xml" })
@io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username)
throws NotFoundException {
return delegate.getUserByName(username);
}
@PUT
@Path("/{username}")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") })
public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username,
@ApiParam(value = "Updated user object" ) User body)
throws NotFoundException {
return delegate.updateUser(username,body);
}
@DELETE
@Path("/{username}")
@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.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") })
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username)
throws NotFoundException {
return delegate.deleteUser(username);
}
}

View File

@ -1,47 +0,0 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import com.sun.jersey.multipart.FormDataParam;
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;
public abstract class UserApiService {
public abstract Response createUser(User body)
throws NotFoundException;
public abstract Response createUsersWithArrayInput(List<User> body)
throws NotFoundException;
public abstract Response createUsersWithListInput(List<User> body)
throws NotFoundException;
public abstract Response loginUser(String username,String password)
throws NotFoundException;
public abstract Response logoutUser()
throws NotFoundException;
public abstract Response getUserByName(String username)
throws NotFoundException;
public abstract Response updateUser(String username,User body)
throws NotFoundException;
public abstract Response deleteUser(String username)
throws NotFoundException;
}

View File

@ -5,9 +5,10 @@ import io.swagger.api.impl.PetApiServiceImpl;
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;
}
} }

View File

@ -5,9 +5,10 @@ import io.swagger.api.impl.StoreApiServiceImpl;
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;
}
} }

View File

@ -5,9 +5,10 @@ import io.swagger.api.impl.UserApiServiceImpl;
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;
}
} }

View File

@ -1,69 +1,79 @@
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;
public class PetApiServiceImpl extends PetApiService { public class PetApiServiceImpl extends PetApiService {
@Override @Override
public Response updatePet(Pet body) public Response updatePet(Pet body)
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();
} }
@Override @Override
public Response addPet(Pet body) public Response addPet(Pet body)
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();
} }
@Override @Override
public Response findPetsByStatus(List<String> status) public Response findPetsByStatus(List<String> status)
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();
} }
@Override @Override
public Response findPetsByTags(List<String> tags) public Response findPetsByTags(List<String> tags)
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();
} }
@Override @Override
public Response getPetById(Long petId) public Response getPetById(Long petId)
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();
} }
@Override @Override
public Response updatePetWithForm(String petId, String name, String status) public Response updatePetWithForm(String petId,String name,String status)
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();
} }
@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();
} }
@Override @Override
public Response uploadFile(Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) public Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
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();
} }
} }

View File

@ -1,39 +1,51 @@
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;
public class StoreApiServiceImpl extends StoreApiService { public class StoreApiServiceImpl extends StoreApiService {
@Override @Override
public Response getInventory() public Response getInventory()
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();
} }
@Override @Override
public Response placeOrder(Order body) public Response placeOrder(Order body)
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();
} }
@Override @Override
public Response getOrderById(String orderId) public Response getOrderById(String orderId)
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();
} }
@Override @Override
public Response deleteOrder(String orderId) public Response deleteOrder(String orderId)
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();
} }
} }

View File

@ -1,68 +1,79 @@
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;
public class UserApiServiceImpl extends UserApiService { public class UserApiServiceImpl extends UserApiService {
@Override @Override
public Response createUser(User body) public Response createUser(User body)
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();
} }
@Override @Override
public Response createUsersWithArrayInput(List<User> body) public Response createUsersWithArrayInput(List<User> body)
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();
} }
@Override @Override
public Response createUsersWithListInput(List<User> body) public Response createUsersWithListInput(List<User> body)
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();
} }
@Override @Override
public Response loginUser(String username, String password) public Response loginUser(String username,String password)
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();
} }
@Override @Override
public Response logoutUser() public Response logoutUser()
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();
} }
@Override @Override
public Response getUserByName(String username) public Response getUserByName(String username)
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();
} }
@Override @Override
public Response updateUser(String username, User body) public Response updateUser(String username,User body)
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();
} }
@Override @Override
public Response deleteUser(String username) public Response deleteUser(String username)
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();
} }
} }

View File

@ -0,0 +1,762 @@
{
"swagger" : "2.0",
"info" : {
"description" : "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version" : "1.0.0",
"title" : "Swagger Petstore",
"termsOfService" : "http://swagger.io/terms/",
"contact" : {
"email" : "apiteam@swagger.io"
},
"license" : {
"name" : "Apache 2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host" : "petstore.swagger.io",
"basePath" : "/v2",
"schemes" : [ "http" ],
"paths" : {
"/pet" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "Add a new pet to the store",
"description" : "",
"operationId" : "addPet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"put" : {
"tags" : [ "pet" ],
"summary" : "Update an existing pet",
"description" : "",
"operationId" : "updatePet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Pet"
}
} ],
"responses" : {
"405" : {
"description" : "Validation exception"
},
"404" : {
"description" : "Pet not found"
},
"400" : {
"description" : "Invalid ID supplied"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByStatus" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by status",
"description" : "Multiple status values can be provided with comma seperated strings",
"operationId" : "findPetsByStatus",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "status",
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi",
"default" : "available"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid status value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByTags" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by tags",
"description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
"operationId" : "findPetsByTags",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid tag value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Find pet by ID",
"description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
"operationId" : "getPetById",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"404" : {
"description" : "Pet not found"
},
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Pet"
}
},
"400" : {
"description" : "Invalid ID supplied"
}
},
"security" : [ {
"api_key" : [ ]
}, {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"post" : {
"tags" : [ "pet" ],
"summary" : "Updates a pet in the store with form data",
"description" : "",
"operationId" : "updatePetWithForm",
"consumes" : [ "application/x-www-form-urlencoded" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be updated",
"required" : true,
"type" : "string"
}, {
"name" : "name",
"in" : "formData",
"description" : "Updated name of the pet",
"required" : false,
"type" : "string"
}, {
"name" : "status",
"in" : "formData",
"description" : "Updated status of the pet",
"required" : false,
"type" : "string"
} ],
"responses" : {
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
},
"delete" : {
"tags" : [ "pet" ],
"summary" : "Deletes a pet",
"description" : "",
"operationId" : "deletePet",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "api_key",
"in" : "header",
"description" : "",
"required" : false,
"type" : "string"
}, {
"name" : "petId",
"in" : "path",
"description" : "Pet id to delete",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"400" : {
"description" : "Invalid pet value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}/uploadImage" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "uploads an image",
"description" : "",
"operationId" : "uploadFile",
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to update",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "additionalMetadata",
"in" : "formData",
"description" : "Additional data to pass to server",
"required" : false,
"type" : "string"
}, {
"name" : "file",
"in" : "formData",
"description" : "file to upload",
"required" : false,
"type" : "file"
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/store/inventory" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Returns pet inventories by status",
"description" : "Returns a map of status codes to quantities",
"operationId" : "getInventory",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"security" : [ {
"api_key" : [ ]
} ]
}
},
"/store/order" : {
"post" : {
"tags" : [ "store" ],
"summary" : "Place an order for a pet",
"description" : "",
"operationId" : "placeOrder",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "order placed for purchasing the pet",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Order"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid Order"
}
}
}
},
"/store/order/{orderId}" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Find purchase order by ID",
"description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
"operationId" : "getOrderById",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "Order not found"
},
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid ID supplied"
}
}
},
"delete" : {
"tags" : [ "store" ],
"summary" : "Delete purchase order by ID",
"description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"operationId" : "deleteOrder",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of the order that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "Order not found"
},
"400" : {
"description" : "Invalid ID supplied"
}
}
}
},
"/user" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Create user",
"description" : "This can only be done by the logged in user.",
"operationId" : "createUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : false,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithArray" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithArrayInput",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : false,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithList" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithListInput",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : false,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/login" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs user into the system",
"description" : "",
"operationId" : "loginUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "query",
"description" : "The user name for login",
"required" : false,
"type" : "string"
}, {
"name" : "password",
"in" : "query",
"description" : "The password for login in clear text",
"required" : false,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "string"
}
},
"400" : {
"description" : "Invalid username/password supplied"
}
}
}
},
"/user/logout" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs out current logged in user session",
"description" : "",
"operationId" : "logoutUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/{username}" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Get user by user name",
"description" : "",
"operationId" : "getUserByName",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be fetched. Use user1 for testing. ",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "User not found"
},
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/User"
},
"examples" : {
"application/json" : {
"id" : 1,
"username" : "johnp",
"firstName" : "John",
"lastName" : "Public",
"email" : "johnp@swagger.io",
"password" : "-secret-",
"phone" : "0123456789",
"userStatus" : 0
}
}
},
"400" : {
"description" : "Invalid username supplied"
}
}
},
"put" : {
"tags" : [ "user" ],
"summary" : "Updated user",
"description" : "This can only be done by the logged in user.",
"operationId" : "updateUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "name that need to be deleted",
"required" : true,
"type" : "string"
}, {
"in" : "body",
"name" : "body",
"description" : "Updated user object",
"required" : false,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"404" : {
"description" : "User not found"
},
"400" : {
"description" : "Invalid user supplied"
}
}
},
"delete" : {
"tags" : [ "user" ],
"summary" : "Delete user",
"description" : "This can only be done by the logged in user.",
"operationId" : "deleteUser",
"produces" : [ "application/json", "application/xml" ],
"parameters" : [ {
"name" : "username",
"in" : "path",
"description" : "The name that needs to be deleted",
"required" : true,
"type" : "string"
} ],
"responses" : {
"404" : {
"description" : "User not found"
},
"400" : {
"description" : "Invalid username supplied"
}
}
}
}
},
"securityDefinitions" : {
"api_key" : {
"type" : "apiKey",
"name" : "api_key",
"in" : "header"
},
"petstore_auth" : {
"type" : "oauth2",
"authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog",
"flow" : "implicit",
"scopes" : {
"write:pets" : "modify pets in your account",
"read:pets" : "read your pets"
}
}
},
"definitions" : {
"User" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"username" : {
"type" : "string"
},
"firstName" : {
"type" : "string"
},
"lastName" : {
"type" : "string"
},
"email" : {
"type" : "string"
},
"password" : {
"type" : "string"
},
"phone" : {
"type" : "string"
},
"userStatus" : {
"type" : "integer",
"format" : "int32",
"description" : "User Status"
}
},
"xml" : {
"name" : "User"
}
},
"Category" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"xml" : {
"name" : "Category"
}
},
"Pet" : {
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"category" : {
"$ref" : "#/definitions/Category"
},
"name" : {
"type" : "string",
"example" : "doggie"
},
"photoUrls" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"tags" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Tag"
}
},
"status" : {
"type" : "string",
"description" : "pet status in the store",
"enum" : [ "available", "pending", "sold" ]
}
},
"xml" : {
"name" : "Pet"
}
},
"Tag" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"xml" : {
"name" : "Tag"
}
},
"Order" : {
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"petId" : {
"type" : "integer",
"format" : "int64"
},
"quantity" : {
"type" : "integer",
"format" : "int32"
},
"shipDate" : {
"type" : "string",
"format" : "date-time"
},
"status" : {
"type" : "string",
"description" : "Order Status",
"enum" : [ "placed", "approved", "delivered" ]
},
"complete" : {
"type" : "boolean"
}
},
"xml" : {
"name" : "Order"
}
}
}
}