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
Asked
Active
Viewed 618 times
1 Answers
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
) {
...
}

moondaisy
- 4,303
- 6
- 41
- 70
-
Thanks for the reply, yeah example parameters for query params or header are pretty straight forward. I have not been able to figure out how to do body examples. A PATCH method would be especially hard because you wouldn't always want to annotate the model as it is reused for multiple endpoitns. – user2524908 Apr 24 '17 at 12:42