问题
Is there a way in swagger to show example data for; model, both input & output, query parameters, headers, etc? I have been unable to find anything related to this in the annotations documentation; https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X
回答1:
If you look at the documentation for some of the annotations mentioned in the wiki you will see they have among their optional parameters one called example or examples. You can use this parameter to add a single example or more than one (if it's allowed).
For example for a query parameter you can do it like this using the @ApiParam annotation:
@Path("/{username}")
@ApiOperation(value = "Updated user")
public Response updateUser(
@ApiParam(example = "moondaisy") @QueryParam("username") String username
) {
...
}
来源:https://stackoverflow.com/questions/43544259/swagger-ui-example-data