Issue
I understand that when documenting an API with Swagger in Spring, I can change the description for the API by adding @Api
annotation, but when I add it as follows
@Api(value= "NEW_NAME", description="NEW_DESCRIPTION")
Only the description is changed, not the name.
as seen here
Further, I'm not sure where the default name and description are coming from, before adding the API, the name seems to be derived from the controller name, but the description; which to me looks natural and human like almost like hard coded String with capitalization and all. I ran a search on the code, and I wasn't able to find those Strings. Where's Swagger getting those values from?
thanks
Solution
The attribute you are looking for is: tags
. So you can avoid grouping by controller name.
From Javadoc of @Api
tags
:
Tags can be used for logical grouping of operations by resources or any other qualifier.
For example:
@Api(value = "/customers", tags = "customers", description = "Manage Customer")
By default Springfox creates API with name as {controller-name}-controller
and description as {Controller Name} Controller
(cf. How to change the default Controller Name in Swagger Spring ).
Answered By - Vladas Maier
Answer Checked By - David Marino (JavaFixing Volunteer)