diff --git a/samples/server/petstore/spring-mvc/README.md b/samples/server/petstore/spring-mvc/README.md
new file mode 100644
index 00000000000..615cc51f369
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/README.md
@@ -0,0 +1,11 @@
+# Swagger generated server
+
+Spring MVC Server
+
+
+## Overview
+This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework.
+
+The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox)
+
+You can view the server in swagger-ui by pointing to http://localhost:8002/v2/swagger.json
\ No newline at end of file
diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml
new file mode 100644
index 00000000000..61a985b802c
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/pom.xml
@@ -0,0 +1,227 @@
+
+ 4.0.0
+ io.swagger
+ swagger-spring-mvc-server
+ jar
+ swagger-spring-mvc-server
+ 1.0.0
+
+ src/main/java
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 2.1.1
+
+
+ maven-failsafe-plugin
+ 2.6
+
+
+
+ integration-test
+ verify
+
+
+
+
+
+ org.mortbay.jetty
+ jetty-maven-plugin
+ ${jetty-version}
+
+
+ /v2
+
+ target/${project.artifactId}-${project-version}
+ ${project.basedir}/conf/jetty/webdefault.xml
+ 8079
+ stopit
+
+
+ 8002
+ 60000
+ 8443
+
+
+
+
+
+ start-jetty
+ pre-integration-test
+
+ run
+
+
+ 0
+ true
+
+
+
+ stop-jetty
+ post-integration-test
+
+ stop
+
+
+
+
+
+ com.googlecode.maven-download-plugin
+ download-maven-plugin
+ 1.2.1
+
+
+ swagger-ui
+
+ wget
+
+
+ https://github.com/swagger-api/swagger-ui/archive/v${swagger-ui-version}.tar.gz
+ true
+ ${project.build.directory}
+
+
+
+
+
+ maven-resources-plugin
+ 2.6
+
+
+ copy-resources
+ validate
+
+ copy-resources
+
+
+ target/${project.artifactId}-${project.version}
+
+
+ ${project.build.directory}/swagger-ui-${swagger-ui-version}/dist
+ true
+
+ index.html
+
+
+
+
+
+
+
+
+
+
+
+ com.wordnik
+ swagger-jersey-jaxrs
+ ${swagger-core-version}
+
+
+ org.slf4j
+ slf4j-log4j12
+ ${slf4j-version}
+
+
+ com.sun.jersey
+ jersey-core
+ ${jersey-version}
+
+
+ com.sun.jersey
+ jersey-json
+ ${jersey-version}
+
+
+ com.sun.jersey
+ jersey-servlet
+ ${jersey-version}
+
+
+ com.sun.jersey.contribs
+ jersey-multipart
+ ${jersey-version}
+
+
+ com.sun.jersey
+ jersey-server
+ ${jersey-version}
+
+
+
+
+ org.springframework
+ spring-core
+ ${spring-version}
+
+
+ org.springframework
+ spring-webmvc
+ ${spring-version}
+
+
+ org.springframework
+ spring-web
+ ${spring-version}
+
+
+
+
+ io.springfox
+ springfox-core
+ ${springfox-version}
+
+
+ io.springfox
+ springfox-spi
+ ${springfox-version}
+
+
+ io.springfox
+ springfox-spring-web
+ ${springfox-version}
+
+
+ io.springfox
+ springfox-swagger2
+ ${springfox-version}
+
+
+
+ org.scalatest
+ scalatest_2.9.1
+ ${scala-test-version}
+ test
+
+
+ junit
+ junit
+ ${junit-version}
+ test
+
+
+ javax.servlet
+ servlet-api
+ ${servlet-api-version}
+
+
+
+
+ jcenter-snapshots
+ jcenter
+ http://oss.jfrog.org/artifactory/oss-snapshot-local/
+
+
+
+ 1.5.3-M1-SNAPSHOT
+ 8.1.11.v20130520
+ 2.1.0-M2
+ 1.13
+ 1.6.3
+ 1.6.1
+ 4.8.1
+ 2.5
+ 2.0.0-SNAPSHOT
+ 4.0.9.RELEASE
+
+
\ No newline at end of file
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java
new file mode 100644
index 00000000000..cae767c0393
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java
@@ -0,0 +1,9 @@
+package io.swagger.api;
+
+public class ApiException extends Exception{
+ private int code;
+ public ApiException (int code, String msg) {
+ super(msg);
+ this.code = code;
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java
new file mode 100644
index 00000000000..c2eeacf13d3
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java
@@ -0,0 +1,26 @@
+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 {
+ }
+}
\ No newline at end of file
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java
new file mode 100644
index 00000000000..9e5b0ee44e2
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java
@@ -0,0 +1,68 @@
+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;
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java
new file mode 100644
index 00000000000..9c8410e47ab
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java
@@ -0,0 +1,9 @@
+package io.swagger.api;
+
+public class NotFoundException extends ApiException {
+ private int code;
+ public NotFoundException (int code, String msg) {
+ super(code, msg);
+ this.code = code;
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java
new file mode 100644
index 00000000000..e58a4c2c120
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java
@@ -0,0 +1,169 @@
+package io.swagger.api;
+
+import io.swagger.model.*;
+
+import io.swagger.model.Pet;
+import java.io.File;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiParam;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+import static org.springframework.http.MediaType.*;
+
+@Controller
+@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
+@Api(value = "/pet", description = "the pet API")
+public class PetApi {
+
+
+ @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 405, message = "Validation exception"),
+ @ApiResponse(code = 404, message = "Pet not found"),
+ @ApiResponse(code = 400, message = "Invalid ID supplied") })
+ @RequestMapping(value = "",
+ produces = { "application/json", "application/xml" },
+ consumes = { "application/json", "application/xml", },
+ method = RequestMethod.PUT)
+ public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 405, message = "Invalid input") })
+ @RequestMapping(value = "",
+ produces = { "application/json", "application/xml" },
+ consumes = { "application/json", "application/xml", },
+ method = RequestMethod.POST)
+ public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid status value") })
+ @RequestMapping(value = "/findByStatus",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter") @RequestParam("status") List status)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @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")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid tag value") })
+ @RequestMapping(value = "/findByTags",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam("tags") List tags)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @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)
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Pet not found"),
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid ID supplied") })
+ @RequestMapping(value = "/{petId}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 405, message = "Invalid input") })
+ @RequestMapping(value = "/{petId}",
+ produces = { "application/json", "application/xml" },
+ consumes = { "application/x-www-form-urlencoded", },
+ method = RequestMethod.POST)
+ public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId,
+
+@ApiParam(value = "Updated name of the pet" )@RequestPart("name") String name,
+
+@ApiParam(value = "Updated status of the pet" )@RequestPart("status") String status)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 400, message = "Invalid pet value") })
+ @RequestMapping(value = "/{petId}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.DELETE)
+ public ResponseEntity deletePet(@ApiParam(value = "" )@RequestHeader("apiKey") String apiKey,
+ @ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "uploads an image", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 0, message = "successful operation") })
+ @RequestMapping(value = "/{petId}/uploadImage",
+ produces = { "application/json", "application/xml" },
+ consumes = { "multipart/form-data", },
+ method = RequestMethod.POST)
+ public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
+
+@ApiParam(value = "Additional data to pass to server" )@RequestPart("additionalMetadata") String additionalMetadata,
+ @ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java
new file mode 100644
index 00000000000..4f3eb963e16
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java
@@ -0,0 +1,99 @@
+package io.swagger.api;
+
+import io.swagger.model.*;
+
+import java.util.Map;
+import io.swagger.model.Order;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiParam;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+import static org.springframework.http.MediaType.*;
+
+@Controller
+@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
+@Api(value = "/store", description = "the store API")
+public class StoreApi {
+
+
+ @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful operation") })
+ @RequestMapping(value = "/inventory",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity getInventory()
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid Order") })
+ @RequestMapping(value = "/order",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.POST)
+ public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Order not found"),
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid ID supplied") })
+ @RequestMapping(value = "/order/{orderId}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Order not found"),
+ @ApiResponse(code = 400, message = "Invalid ID supplied") })
+ @RequestMapping(value = "/order/{orderId}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.DELETE)
+ public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java
new file mode 100644
index 00000000000..4a84a38612b
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java
@@ -0,0 +1,162 @@
+package io.swagger.api;
+
+import io.swagger.model.*;
+
+import io.swagger.model.User;
+import java.util.*;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiParam;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+import static org.springframework.http.MediaType.*;
+
+@Controller
+@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
+@Api(value = "/user", description = "the user API")
+public class UserApi {
+
+
+ @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 0, message = "successful operation") })
+ @RequestMapping(value = "",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.POST)
+ public ResponseEntity createUser(@ApiParam(value = "Created user object" ) User body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 0, message = "successful operation") })
+ @RequestMapping(value = "/createWithArray",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.POST)
+ public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 0, message = "successful operation") })
+ @RequestMapping(value = "/createWithList",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.POST)
+ public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ) List body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid username/password supplied") })
+ @RequestMapping(value = "/login",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity loginUser(@ApiParam(value = "The user name for login") @RequestParam("username") String username,
+ @ApiParam(value = "The password for login in clear text") @RequestParam("password") String password)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 0, message = "successful operation") })
+ @RequestMapping(value = "/logout",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity logoutUser()
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Get user by user name", notes = "", response = User.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "User not found"),
+ @ApiResponse(code = 200, message = "successful operation"),
+ @ApiResponse(code = 400, message = "Invalid username supplied") })
+ @RequestMapping(value = "/{username}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.GET)
+ public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "User not found"),
+ @ApiResponse(code = 400, message = "Invalid user supplied") })
+ @RequestMapping(value = "/{username}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.PUT)
+ public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
+ @ApiParam(value = "Updated user object" ) User body)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+
+ @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "User not found"),
+ @ApiResponse(code = 400, message = "Invalid username supplied") })
+ @RequestMapping(value = "/{username}",
+ produces = { "application/json", "application/xml" },
+
+ method = RequestMethod.DELETE)
+ public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username)
+ throws NotFoundException {
+ // do some magic!
+ return new ResponseEntity(HttpStatus.OK);
+ }
+
+
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java
new file mode 100644
index 00000000000..07aa9ac789c
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java
@@ -0,0 +1,39 @@
+package io.swagger.configuration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+
+@Configuration
+@ComponentScan(basePackages = "io.swagger.api")
+@EnableWebMvc
+@EnableSwagger2 //Loads the spring beans required by the framework
+@PropertySource("classpath:swagger.properties")
+public class SwaggerConfig {
+
+ @Bean
+ ApiInfo apiInfo() {
+ ApiInfo apiInfo = new ApiInfo(
+ "Swagger Petstore",
+ "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
+ "1.0.0",
+ "",
+ "apiteam@wordnik.com",
+ "Apache 2.0",
+ "http://www.apache.org/licenses/LICENSE-2.0.html" );
+ return apiInfo;
+ }
+
+ @Bean
+ public Docket customImplementation(){
+ return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
+ }
+
+}
\ No newline at end of file
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java
new file mode 100644
index 00000000000..05f7dae29ec
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java
@@ -0,0 +1,21 @@
+package io.swagger.configuration;
+
+import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
+
+public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
+
+ @Override
+ protected Class>[] getRootConfigClasses() {
+ return new Class[] { SwaggerConfig.class };
+ }
+
+ @Override
+ protected Class>[] getServletConfigClasses() {
+ return new Class>[] { WebMvcConfiguration.class };
+ }
+
+ @Override
+ protected String[] getServletMappings() {
+ return new String[] { "/" };
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java
new file mode 100644
index 00000000000..206e011dd48
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java
@@ -0,0 +1,11 @@
+package io.swagger.configuration;
+
+import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
+public class WebMvcConfiguration extends WebMvcConfigurationSupport {
+ @Override
+ public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
+ configurer.enable();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java
new file mode 100644
index 00000000000..98cc0b4d273
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java
@@ -0,0 +1,50 @@
+package io.swagger.model;
+
+
+import com.wordnik.swagger.annotations.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@ApiModel(description = "")
+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();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java
new file mode 100644
index 00000000000..cff15e3bd2a
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java
@@ -0,0 +1,111 @@
+package io.swagger.model;
+
+import java.util.Date;
+
+import com.wordnik.swagger.annotations.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@ApiModel(description = "")
+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();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java
new file mode 100644
index 00000000000..e8503c6bd31
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java
@@ -0,0 +1,113 @@
+package io.swagger.model;
+
+import io.swagger.model.Category;
+import io.swagger.model.Tag;
+import java.util.*;
+
+import com.wordnik.swagger.annotations.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@ApiModel(description = "")
+public class Pet {
+
+ private Long id = null;
+ private Category category = null;
+ private String name = null;
+ private List photoUrls = new ArrayList() ;
+ private List tags = new ArrayList() ;
+ 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 getPhotoUrls() {
+ return photoUrls;
+ }
+ public void setPhotoUrls(List photoUrls) {
+ this.photoUrls = photoUrls;
+ }
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ @JsonProperty("tags")
+ public List getTags() {
+ return tags;
+ }
+ public void setTags(List 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();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java
new file mode 100644
index 00000000000..d99a24f8cc1
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java
@@ -0,0 +1,50 @@
+package io.swagger.model;
+
+
+import com.wordnik.swagger.annotations.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@ApiModel(description = "")
+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();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java
new file mode 100644
index 00000000000..24d707e921f
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java
@@ -0,0 +1,135 @@
+package io.swagger.model;
+
+
+import com.wordnik.swagger.annotations.*;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@ApiModel(description = "")
+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();
+ }
+}
diff --git a/samples/server/petstore/spring-mvc/src/main/resources/swagger.properties b/samples/server/petstore/spring-mvc/src/main/resources/swagger.properties
new file mode 100644
index 00000000000..2be15be87ee
--- /dev/null
+++ b/samples/server/petstore/spring-mvc/src/main/resources/swagger.properties
@@ -0,0 +1 @@
+springfox.documentation.swagger.v2.path=/swagger.json
\ No newline at end of file