Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
anthony-foulfoin opened this issue May 23, 2018 · 15 comments
Closed

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

anthony-foulfoin opened this issue May 23, 2018 · 15 comments

Comments

@anthony-foulfoin
Copy link

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 !

@anthony-foulfoin
Copy link
Author

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 :)

@dilipkrish
Copy link
Member

Thanks for reporting. Will add this to the list of features

@elamparuthik1991
Copy link

better use @ApiIgnore in controller level.

@ihgann
Copy link

ihgann commented 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.

@xianlongbai
Copy link

@ApiIgnore very good

@javaHelper
Copy link

@ApiIgnore shows the entry of Controller. How to completely hide this?

@ohoroyoi
Copy link

ohoroyoi commented Dec 5, 2019

@javaHelper you can add "/test/" to @RequestMapping of controller

@stale
Copy link

stale bot commented Jun 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 24, 2020
@stale
Copy link

stale bot commented Jul 8, 2020

This issue has been automatically closed because it has not had recent activity. Please re-open a new issue if this is still an issue.

@stale stale bot closed this as completed Jul 8, 2020
@MVTalent
Copy link

@ApiIgnore shows the entry of Controller

@Deprecated
@RestController
@RequestMapping("/test/test-rest")
@Api(tags = "testRest", description = "test rest test rest", hidden = true)
@ApiIgnore
public class TestRest {
.....
}

@dilipkrish
Copy link
Member

@MVTalent What version are you using. This totally works, infact its used internally as well.

@MVTalent
Copy link

checked on versions 2.8.0 and 2.9.2

@dilipkrish
Copy link
Member

Not sure, it should work with 2.9.2

@kajh
Copy link

kajh commented May 4, 2021

It does not work with 3.0.0.

@elamparuthik1991
Copy link

Hide controller or method?

Please use @ApiIgnore for that controller or method...

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants