Reputation: 1471
I included swagger-springmvc
in my project and managed to get the Swagger UI working, but right now there's very little information about the APIs in the UI. All I see is information extracted through reflection.
This is what a controller method looks like:
/**
* Read all users matching given filter
* @param String filter The text by which to filter the usernames
* @return User[] Array of users matching given filter
* @throws Exception
*/
@RequestMapping(value = "/users/{filter}", method = RequestMethod.GET)
public
@ResponseBody
Collection<User> getUsers(@PathVariable("filter") String filter) throws Exception {
return domain.getUsersFilteredBy(filter);
}
And on the right side of each method Swagger documents the method's name, in this case:
get Users
but I was expecting to see this:
Read all users matching given filter
In the example on helloreverb.com, I see the description of each of those methods. How can I get swagger to add the descriptions of my controller methods to the UI like so?
Upvotes: 5
Views: 4576
Reputation: 21
Use @Operation from package io.swagger.v3.oas.annotations;
@GetMapping
@Operation(summary = "My Summary", description = "My Description")
public Object getSomeObject(){..}
Upvotes: 2
Reputation: 121
@ApiOperation(value = "Read all users matching given filter", notes = "Will get all the users for the given filter")
Upvotes: 5