Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any centralized way to limit the exposure of api's to swagger ui in regarding openAPI?

I have just migrated to spring-doc openAPI from springfox, right now it's exposing all our api's present in my spring-boot projects for documentation. Is there any centralized way to govern that thing because using @Hidden annotation will not be feasible in our case for that we have to amend our all controllers.

Any suggestions will be appreciated.

like image 613
krishna Avatar asked Dec 03 '25 04:12

krishna


1 Answers

You can use:

springdoc.paths-to-exclude property with List of Strings.The list of paths to exclude (comma separated)

Or springdoc.packages-to-exclude property with List of Strings.The list of packages to exclude (comma separated).

Or you can load groups dynamically using spring-boot configuration files. Note that, for this usage, you don’t have to declare the GroupedOpenApi Bean. You need to declare the following properties, under the prefix springdoc.group-configs.

springdoc.group-configs[0].group=users
springdoc.group-configs[0].paths-to-match=/user/**
springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!