Springfox name @RestController

I get some minor issues using Springfox. I cannot set the name for the @RestController classes.

I am using Spring boot and Swagger2.

The following code will create a controller named "rest-status-controller" in springfox ui. I was expecting "Application Status". Is there any other configuration that I don't know about?

@Api("Application Status") @RestController @RequestMapping("/rest/status") public class RestStatusController { @ApiOperation(value="Get components current status") @RequestMapping(method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON) public String global() { //... } @ApiOperation(value="Get mysql current status") @RequestMapping(value="/mysql" method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON) public String mysql() { //... } } 
+5
source share
1 answer

Try using the @Api annotation tags parameter to change the name of the RestController method grouping. Excerpt from the corresponding Java Doc (abbreviated):

 /** * A list of tags for API documentation control. * Tags can be used for logical grouping of operations by resources or any other qualifier. */ String[] tags() default ""; 

In your case, just use:

 @Api(tags = "Application Status") @RestController @RequestMapping("/rest/status") public class RestStatusController { ... } 

This should group all documented operations from RestStatusController with the "Application Status" tag.

+15
source

All Articles