Skip to content

Instantly share code, notes, and snippets.

@InfoSec812
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save InfoSec812/d09c9c3b543f8fc4d33b to your computer and use it in GitHub Desktop.

Select an option

Save InfoSec812/d09c9c3b543f8fc4d33b to your computer and use it in GitHub Desktop.
Showing how to use Swagger annotations to mark a parameter as required.
@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