Last active
August 29, 2015 14:20
-
-
Save InfoSec812/d09c9c3b543f8fc4d33b to your computer and use it in GitHub Desktop.
Showing how to use Swagger annotations to mark a parameter as required.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @PUT | |
| @Path("/{id}") | |
| @Produces(value = {"application/json", "application/xml"}) | |
| @ApiOperation(value = "Update/Modify ToDo entity specified by 'id'", produces = "application/json, application/xml", | |
| response = ToDo.class, consumes = "application/xml, application/json") | |
| @ApiResponses({ | |
| @ApiResponse(code = SC_INTERNAL_SERVER_ERROR, message = "SERVER ERROR"), | |
| @ApiResponse(code = SC_BAD_REQUEST, message = "Invalid ID value") | |
| }) | |
| public ToDo updateToDo(@ApiParam( value = "The unique ID of the ToDo entity", name = "id", required = true) @PathParam("id") Long id, | |
| ToDo item) { | |
| ToDo todo = dao.updateToDo(item); | |
| if (todo==null) { | |
| throw new WebApplicationException(String.format("Unable to update item with id '%d'", id), BAD_REQUEST); | |
| } | |
| return todo; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment