springfox: @Api(hidden = true) does not hide controller operations

Using springfox-swagger2:2.8.0 and springfox-swagger-ui:2.8.0 (same issue with 2.9.0):

When I set the hidden=true property on the @Api annotation, the controller and all its endpoints are still appearing on swagger-ui

@RestController
@Api(tags="Accounts", hidden=true)
@RequestMapping(value="/v2/accounts")
public class AccountsController {

    @ApiOperation(value = "Get account")
    @GetMapping(value = "/{reference}")
    public Account getAccount(@PathVariable String reference) {
        ....
    }
}

If I specifically set the hidden property directly on the @ApiOperation, it works correctly. But sometimes I want to hide all the endpoints of a controller. For now, I need to add a hidden=true on all the @ApiOperation of the controller, and that can be boilerplate.

The hidden=true property on the @Api annotation was working on old versions of springfox, like the 2.3.0 I think, so it might be a regression.

Thanks !

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (3 by maintainers)

Most upvoted comments

After digging a bit it appears that it works if I put a @ApiIgnore on the controller. But I don’t know it is the intented way to do it because it is a Springfox specific annotation while @Api is a swagger annotation. Any guidance for doing this ?

Thanks 😃

Seems related to #1731, which was marked as closed. I can confirm as well the same functionality expectation is failing for us, but using @ApiIgnore alleviates the problem. If we can automate this functionality for @Api(hidden = true) -> @ApiIgnore, that would be extremely nice, but it’s nice to know there’s at least an alternative for now.