forked from loafle/openapi-generator-original
Generate JAXRS and SpringMVC samples to demo Authorization annotations
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package io.swagger.api;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class ApiException extends Exception{
|
||||
private int code;
|
||||
public ApiException (int code, String msg) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.swagger.api;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@javax.xml.bind.annotation.XmlRootElement
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class ApiResponseMessage {
|
||||
public static final int ERROR = 1;
|
||||
public static final int WARNING = 2;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.swagger.api;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class NotFoundException extends ApiException {
|
||||
private int code;
|
||||
public NotFoundException (int code, String msg) {
|
||||
|
||||
@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import io.swagger.annotations.AuthorizationScope;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -30,15 +32,20 @@ import static org.springframework.http.MediaType.*;
|
||||
@Controller
|
||||
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
|
||||
@Api(value = "/pet", description = "the pet API")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class PetApi {
|
||||
|
||||
|
||||
@ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
|
||||
@ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Validation exception"),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ApiResponse(code = 404, message = "Pet not found"),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||
@ApiResponse(code = 405, message = "Validation exception") })
|
||||
@RequestMapping(value = "",
|
||||
produces = { "application/json", "application/xml" },
|
||||
consumes = { "application/json", "application/xml" },
|
||||
@@ -54,7 +61,12 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
|
||||
@ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input") })
|
||||
@RequestMapping(value = "",
|
||||
@@ -72,7 +84,12 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
|
||||
@ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation"),
|
||||
@ApiResponse(code = 400, message = "Invalid status value") })
|
||||
@@ -91,7 +108,12 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation"),
|
||||
@ApiResponse(code = 400, message = "Invalid tag value") })
|
||||
@@ -110,11 +132,17 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class)
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class, authorizations = {
|
||||
@Authorization(value = "api_key"),
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "Pet not found"),
|
||||
@ApiResponse(code = 200, message = "successful operation"),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ApiResponse(code = 404, message = "Pet not found") })
|
||||
@RequestMapping(value = "/{petId}",
|
||||
produces = { "application/json", "application/xml" },
|
||||
|
||||
@@ -130,7 +158,12 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input") })
|
||||
@RequestMapping(value = "/{petId}",
|
||||
@@ -158,7 +191,12 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
|
||||
@ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid pet value") })
|
||||
@RequestMapping(value = "/{petId}",
|
||||
@@ -180,7 +218,12 @@ public class PetApi {
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "uploads an image", notes = "", response = Void.class)
|
||||
@ApiOperation(value = "uploads an image", notes = "", response = Void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read:pets", description = "read your pets")
|
||||
})
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
@RequestMapping(value = "/{petId}/uploadImage",
|
||||
|
||||
@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import io.swagger.annotations.AuthorizationScope;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -30,11 +32,13 @@ import static org.springframework.http.MediaType.*;
|
||||
@Controller
|
||||
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
|
||||
@Api(value = "/store", description = "the store API")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class StoreApi {
|
||||
|
||||
|
||||
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map")
|
||||
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
|
||||
@Authorization(value = "api_key")
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation") })
|
||||
@RequestMapping(value = "/inventory",
|
||||
@@ -70,9 +74,9 @@ public class StoreApi {
|
||||
|
||||
@ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "Order not found"),
|
||||
@ApiResponse(code = 200, message = "successful operation"),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ApiResponse(code = 404, message = "Order not found") })
|
||||
@RequestMapping(value = "/order/{orderId}",
|
||||
produces = { "application/json", "application/xml" },
|
||||
|
||||
@@ -90,8 +94,8 @@ public class StoreApi {
|
||||
|
||||
@ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "Order not found"),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied") })
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied"),
|
||||
@ApiResponse(code = 404, message = "Order not found") })
|
||||
@RequestMapping(value = "/order/{orderId}",
|
||||
produces = { "application/json", "application/xml" },
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import io.swagger.annotations.AuthorizationScope;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -30,7 +32,7 @@ import static org.springframework.http.MediaType.*;
|
||||
@Controller
|
||||
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
|
||||
@Api(value = "/user", description = "the user API")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class UserApi {
|
||||
|
||||
|
||||
@@ -128,9 +130,9 @@ public class UserApi {
|
||||
|
||||
@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") })
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied"),
|
||||
@ApiResponse(code = 404, message = "User not found") })
|
||||
@RequestMapping(value = "/{username}",
|
||||
produces = { "application/json", "application/xml" },
|
||||
|
||||
@@ -148,8 +150,8 @@ public class UserApi {
|
||||
|
||||
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "User not found"),
|
||||
@ApiResponse(code = 400, message = "Invalid user supplied") })
|
||||
@ApiResponse(code = 400, message = "Invalid user supplied"),
|
||||
@ApiResponse(code = 404, message = "User not found") })
|
||||
@RequestMapping(value = "/{username}",
|
||||
produces = { "application/json", "application/xml" },
|
||||
|
||||
@@ -171,8 +173,8 @@ public class UserApi {
|
||||
|
||||
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 404, message = "User not found"),
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied") })
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied"),
|
||||
@ApiResponse(code = 404, message = "User not found") })
|
||||
@RequestMapping(value = "/{username}",
|
||||
produces = { "application/json", "application/xml" },
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
@EnableSwagger2 //Loads the spring beans required by the framework
|
||||
@PropertySource("classpath:swagger.properties")
|
||||
@Import(SwaggerUiConfiguration.class)
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
ApiInfo apiInfo() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.swagger.configuration;
|
||||
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.swagger.configuration;
|
||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
@Override
|
||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
@ApiModel(description = "")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-09-30T16:27:59.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-10-16T21:16:24.594-04:00")
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
|
||||
Reference in New Issue
Block a user