[Java][Spring] Fix spring cloud client due to enhancement in adding server example responses. (#5497)

* add use spring cloud client option

* uncomment spring cloud client test

* remove scala-related tests from pom.xml for circleci

* fix mismstach tag
This commit is contained in:
wing328 2017-04-27 20:00:56 +08:00 committed by GitHub
parent e8feca2753
commit 42a5a13fef
13 changed files with 110 additions and 33 deletions

View File

@ -206,8 +206,8 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation
if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) { if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) {
additionalProperties.put(SINGLE_CONTENT_TYPES, "true"); additionalProperties.put(SINGLE_CONTENT_TYPES, "true");
this.setSingleContentTypes(true); this.setSingleContentTypes(true);
} }
additionalProperties.put("useSpringCloudClient", true);
} else { } else {
apiTemplateFiles.put("apiController.mustache", "Controller.java"); apiTemplateFiles.put("apiController.mustache", "Controller.java");

View File

@ -16,7 +16,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
{{#useSpringCloudClient}}
import java.io.IOException; import java.io.IOException;
{{/useSpringCloudClient}}
import java.util.List; import java.util.List;
{{#async}} {{#async}}
@ -52,11 +54,20 @@ public interface {{classname}} {
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
method = RequestMethod.{{httpMethod}}) method = RequestMethod.{{httpMethod}})
{{#useSpringCloudClient}}
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
// do some magic!
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
}{{/jdk8}}
{{/useSpringCloudClient}}
{{^useSpringCloudClient}}
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} { {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} {
// do some magic! // do some magic!
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
}{{/jdk8}} }{{/jdk8}}
{{/useSpringCloudClient}}
{{/operation}} {{/operation}}
} }
{{/operations}} {{/operations}}

View File

@ -17,8 +17,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
{{^useSpringCloudClient}}
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException; import java.io.IOException;
{{/useSpringCloudClient}}
import java.util.List; import java.util.List;
{{#async}} {{#async}}
@ -52,6 +54,25 @@ public class {{classname}}Controller implements {{classname}} {
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}, public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
{{/allParams}}@RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} { {{/allParams}}@RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} {
// do some magic! // do some magic!
{{#useSpringCloudClient}}
{{^isDelegate}}
{{^async}}
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
{{/async}}
{{#async}}
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
@Override
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
}
};
{{/async}}
{{/isDelegate}}
{{#isDelegate}}
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/isDelegate}}
{{/useSpringCloudClient}}
{{^useSpringCloudClient}}
{{^isDelegate}} {{^isDelegate}}
{{^async}} {{^async}}
{{#examples}} {{#examples}}
@ -75,6 +96,7 @@ public class {{classname}}Controller implements {{classname}} {
{{#isDelegate}} {{#isDelegate}}
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/isDelegate}} {{/isDelegate}}
{{/useSpringCloudClient}}
} }
{{/operation}} {{/operation}}

View File

@ -831,15 +831,13 @@
<module>samples/server/petstore/jaxrs-resteasy/joda</module> <module>samples/server/petstore/jaxrs-resteasy/joda</module>
<module>samples/server/petstore/scalatra</module> <module>samples/server/petstore/scalatra</module>
<module>samples/server/petstore/spring-mvc</module> <module>samples/server/petstore/spring-mvc</module>
<!-- comment out due to change in method signature <module>samples/client/petstore/spring-cloud</module>
<module>samples/client/petstore/spring-cloud</module> -->
<module>samples/server/petstore/springboot</module> <module>samples/server/petstore/springboot</module>
<module>samples/server/petstore/springboot-beanvalidation</module> <module>samples/server/petstore/springboot-beanvalidation</module>
<module>samples/server/petstore/jaxrs-cxf</module> <module>samples/server/petstore/jaxrs-cxf</module>
<module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module> <module>samples/server/petstore/jaxrs-cxf-annotated-base-path</module>
<module>samples/server/petstore/jaxrs-cxf-cdi</module> <module>samples/server/petstore/jaxrs-cxf-cdi</module>
<module>samples/server/petstore/jaxrs-cxf-non-spring-app</module> <module>samples/server/petstore/jaxrs-cxf-non-spring-app</module>
<!--<module>samples/server/petstore/java-msf4j</module> note: JDK8 only --> <!--<module>samples/server/petstore/java-msf4j</module> note: JDK8 only -->
</modules> </modules>
</profile> </profile>

View File

@ -31,7 +31,6 @@ public interface PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) @ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "/pet", @RequestMapping(value = "/pet",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -47,7 +46,6 @@ public interface PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
@RequestMapping(value = "/pet/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -64,12 +62,11 @@ public interface PetApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) })
@RequestMapping(value = "/pet/findByStatus", @RequestMapping(value = "/pet/findByStatus",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByStatus( @NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List<String> status) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByStatus( @NotNull@ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @RequestParam(value = "status", required = true) List<String> status);
@ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
@ -81,12 +78,11 @@ public interface PetApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) })
@RequestMapping(value = "/pet/findByTags", @RequestMapping(value = "/pet/findByTags",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<List<Pet>>> findPetsByTags( @NotNull@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
@ -96,12 +92,11 @@ public interface PetApi {
@ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
@ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
@RequestMapping(value = "/pet/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId);
@ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
@ -114,7 +109,6 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@ApiResponse(code = 404, message = "Pet not found", response = Void.class), @ApiResponse(code = 404, message = "Pet not found", response = Void.class),
@ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) @ApiResponse(code = 405, message = "Validation exception", response = Void.class) })
@RequestMapping(value = "/pet", @RequestMapping(value = "/pet",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -130,7 +124,6 @@ public interface PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) @ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "/pet/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = "application/json", produces = "application/json",
consumes = "application/x-www-form-urlencoded", consumes = "application/x-www-form-urlencoded",
@ -146,11 +139,10 @@ public interface PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
@RequestMapping(value = "/pet/{petId}/uploadImage", @RequestMapping(value = "/pet/{petId}/uploadImage",
produces = "application/json", produces = "application/json",
consumes = "multipart/form-data", consumes = "multipart/form-data",
method = RequestMethod.POST) method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<ModelApiResponse>> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<ModelApiResponse>> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file);
} }

View File

@ -26,7 +26,6 @@ public interface StoreApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@ApiResponse(code = 404, message = "Order not found", response = Void.class) }) @ApiResponse(code = 404, message = "Order not found", response = Void.class) })
@RequestMapping(value = "/store/order/{orderId}", @RequestMapping(value = "/store/order/{orderId}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -39,12 +38,11 @@ public interface StoreApi {
}, tags={ "store", }) }, tags={ "store", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) @ApiResponse(code = 200, message = "successful operation", response = Integer.class) })
@RequestMapping(value = "/store/inventory", @RequestMapping(value = "/store/inventory",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Map<String, Integer>>> getInventory() throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<Map<String, Integer>>> getInventory();
@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, tags={ "store", }) @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, tags={ "store", })
@ -52,23 +50,21 @@ public interface StoreApi {
@ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
@ApiResponse(code = 404, message = "Order not found", response = Order.class) }) @ApiResponse(code = 404, message = "Order not found", response = Order.class) })
@RequestMapping(value = "/store/order/{orderId}", @RequestMapping(value = "/store/order/{orderId}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", }) @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
@RequestMapping(value = "/store/order", @RequestMapping(value = "/store/order",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.POST) method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
} }

View File

@ -25,7 +25,6 @@ public interface UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", }) @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class, tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user", @RequestMapping(value = "/user",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -36,7 +35,6 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/createWithArray", @RequestMapping(value = "/user/createWithArray",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -47,7 +45,6 @@ public interface UserApi {
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", }) @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class, tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/createWithList", @RequestMapping(value = "/user/createWithList",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -59,7 +56,6 @@ public interface UserApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
@ApiResponse(code = 404, message = "User not found", response = Void.class) }) @ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/user/{username}", @RequestMapping(value = "/user/{username}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -72,30 +68,27 @@ public interface UserApi {
@ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 200, message = "successful operation", response = User.class),
@ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
@ApiResponse(code = 404, message = "User not found", response = User.class) }) @ApiResponse(code = 404, message = "User not found", response = User.class) })
@RequestMapping(value = "/user/{username}", @RequestMapping(value = "/user/{username}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<User>> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<User>> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username);
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) @ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
@RequestMapping(value = "/user/login", @RequestMapping(value = "/user/login",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
method = RequestMethod.GET) method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<String>> loginUser( @NotNull @ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) throws IOException; com.netflix.hystrix.HystrixCommand<ResponseEntity<String>> loginUser( @NotNull@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, @NotNull@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", }) @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class, tags={ "user", })
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/logout", @RequestMapping(value = "/user/logout",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",
@ -107,7 +100,6 @@ public interface UserApi {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
@ApiResponse(code = 404, message = "User not found", response = Void.class) }) @ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/user/{username}", @RequestMapping(value = "/user/{username}",
produces = "application/json", produces = "application/json",
consumes = "application/json", consumes = "application/json",

View File

@ -5,7 +5,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/** /**
* A category for a pet * A category for a pet
*/ */
@ -28,6 +30,8 @@ public class Category {
* @return id * @return id
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Long getId() { public Long getId() {
return id; return id;
} }
@ -46,6 +50,8 @@ public class Category {
* @return name * @return name
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -5,7 +5,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/** /**
* Describes the result of uploading an image resource * Describes the result of uploading an image resource
*/ */
@ -31,6 +33,8 @@ public class ModelApiResponse {
* @return code * @return code
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Integer getCode() { public Integer getCode() {
return code; return code;
} }
@ -49,6 +53,8 @@ public class ModelApiResponse {
* @return type * @return type
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getType() { public String getType() {
return type; return type;
} }
@ -67,6 +73,8 @@ public class ModelApiResponse {
* @return message * @return message
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getMessage() { public String getMessage() {
return message; return message;
} }

View File

@ -7,7 +7,9 @@ import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/** /**
* An order for a pets from the pet store * An order for a pets from the pet store
*/ */
@ -75,6 +77,8 @@ public class Order {
* @return id * @return id
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Long getId() { public Long getId() {
return id; return id;
} }
@ -93,6 +97,8 @@ public class Order {
* @return petId * @return petId
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Long getPetId() { public Long getPetId() {
return petId; return petId;
} }
@ -111,6 +117,8 @@ public class Order {
* @return quantity * @return quantity
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Integer getQuantity() { public Integer getQuantity() {
return quantity; return quantity;
} }
@ -129,6 +137,8 @@ public class Order {
* @return shipDate * @return shipDate
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public DateTime getShipDate() { public DateTime getShipDate() {
return shipDate; return shipDate;
} }
@ -147,6 +157,8 @@ public class Order {
* @return status * @return status
**/ **/
@ApiModelProperty(value = "Order Status") @ApiModelProperty(value = "Order Status")
@Valid
public StatusEnum getStatus() { public StatusEnum getStatus() {
return status; return status;
} }
@ -165,6 +177,8 @@ public class Order {
* @return complete * @return complete
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Boolean getComplete() { public Boolean getComplete() {
return complete; return complete;
} }

View File

@ -10,7 +10,9 @@ import io.swagger.model.Category;
import io.swagger.model.Tag; import io.swagger.model.Tag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/** /**
* A pet for sale in the pet store * A pet for sale in the pet store
*/ */
@ -78,6 +80,8 @@ public class Pet {
* @return id * @return id
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Long getId() { public Long getId() {
return id; return id;
} }
@ -96,6 +100,8 @@ public class Pet {
* @return category * @return category
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Category getCategory() { public Category getCategory() {
return category; return category;
} }
@ -115,6 +121,8 @@ public class Pet {
**/ **/
@ApiModelProperty(example = "doggie", required = true, value = "") @ApiModelProperty(example = "doggie", required = true, value = "")
@NotNull @NotNull
@Valid
public String getName() { public String getName() {
return name; return name;
} }
@ -139,6 +147,8 @@ public class Pet {
**/ **/
@ApiModelProperty(required = true, value = "") @ApiModelProperty(required = true, value = "")
@NotNull @NotNull
@Valid
public List<String> getPhotoUrls() { public List<String> getPhotoUrls() {
return photoUrls; return photoUrls;
} }
@ -165,6 +175,8 @@ public class Pet {
* @return tags * @return tags
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public List<Tag> getTags() { public List<Tag> getTags() {
return tags; return tags;
} }
@ -183,6 +195,8 @@ public class Pet {
* @return status * @return status
**/ **/
@ApiModelProperty(value = "pet status in the store") @ApiModelProperty(value = "pet status in the store")
@Valid
public StatusEnum getStatus() { public StatusEnum getStatus() {
return status; return status;
} }

View File

@ -5,7 +5,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/** /**
* A tag for a pet * A tag for a pet
*/ */
@ -28,6 +30,8 @@ public class Tag {
* @return id * @return id
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Long getId() { public Long getId() {
return id; return id;
} }
@ -46,6 +50,8 @@ public class Tag {
* @return name * @return name
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -5,7 +5,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import javax.validation.Valid;
import javax.validation.constraints.*; import javax.validation.constraints.*;
/** /**
* A User who is purchasing from the pet store * A User who is purchasing from the pet store
*/ */
@ -46,6 +48,8 @@ public class User {
* @return id * @return id
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public Long getId() { public Long getId() {
return id; return id;
} }
@ -64,6 +68,8 @@ public class User {
* @return username * @return username
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getUsername() { public String getUsername() {
return username; return username;
} }
@ -82,6 +88,8 @@ public class User {
* @return firstName * @return firstName
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getFirstName() { public String getFirstName() {
return firstName; return firstName;
} }
@ -100,6 +108,8 @@ public class User {
* @return lastName * @return lastName
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getLastName() { public String getLastName() {
return lastName; return lastName;
} }
@ -118,6 +128,8 @@ public class User {
* @return email * @return email
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getEmail() { public String getEmail() {
return email; return email;
} }
@ -136,6 +148,8 @@ public class User {
* @return password * @return password
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getPassword() { public String getPassword() {
return password; return password;
} }
@ -154,6 +168,8 @@ public class User {
* @return phone * @return phone
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid
public String getPhone() { public String getPhone() {
return phone; return phone;
} }
@ -172,6 +188,8 @@ public class User {
* @return userStatus * @return userStatus
**/ **/
@ApiModelProperty(value = "User Status") @ApiModelProperty(value = "User Status")
@Valid
public Integer getUserStatus() { public Integer getUserStatus() {
return userStatus; return userStatus;
} }