I am working with a Spring Data MongoDB project which exports its endpoints via Spring Data REST. It uses the springdoc-openapi-data-rest module of the springdoc-openapi library to generate an OpenAPI interface description for the Spring Data REST endpoints in project.
I have a repository endpoint that I would like to exclude from the generated OpenAPI document.
@Repository
public interface ExcludeMeRepository extends
PagingAndSortingRepository<ExcludeMe, Integer> {}
If this were a Spring MVC controller being included via springdoc-openapi-ui, I could use the @Hidden annotation from the Swagger Annotations library on the controller. However, this does not appear to work when put on a @Repository class.
@Hidden // Does not appear to have an effect
@Repository
public interface ExcludeMeRepository extends
PagingAndSortingRepository<ExcludeMe, Integer> {}
I have tried out a few things, but haven't found anything that works that doesn't also feel like a hacky workaround.
How can a respository be excluded from the generated OpenAPI document?
The @Hidden annotation is now supported as of the v2.0.0 version of springdoc-openapi. This change was added per springdoc-openapi#1881.
@Hidden // Works as of v2.0.0
@Repository
public interface ExcludeMeRepository extends
PagingAndSortingRepository<ExcludeMe, Integer> {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With