question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 !

Issue Analytics

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

github_iconTop GitHub Comments

16reactions
anthonyfoulfoincommented, May 23, 2018

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 😃

2reactions
ihganncommented, Nov 30, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - How to hide endpoints from Swagger documentation ...
One more way is to use @ApiOperation(hidden = true) This can be used at controller/ ...
Read more >
Hiding Endpoints From Swagger Documentation in Spring Boot
The @ApiIgnore annotation allows us to hide an endpoint. Let's add this annotation for an endpoint in our controller:
Read more >
Hide actions from Swagger / OpenAPI documentation in ASP ...
By adding this attribute on a controller or action and specifying IgnoreApi = true , it gets hidden from auto-generated documentation. However, ...
Read more >
Using OpenAPI and Swagger UI - Quarkus
This guide explains how your Quarkus application can expose its API description through an OpenAPI ... Now you do not need to use...
Read more >
springdoc-openapi v2.0.0
This is a community-based project, not maintained by the Spring Framework ... springdoc.api-docs.enabled. true. Boolean . To disable the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found