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

Annotation @Hidden on rest controller class level doesn't work due to spring default proxying mechanism CGLIB #2709

Closed
alla-gofman opened this issue Sep 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@alla-gofman
Copy link

alla-gofman commented Sep 15, 2024

I mark a rest controller class as hidden (with @hidden annotation) to skip it while reading, but this have no affect.

This behavior is due to original class name wrapped into proxy by Spring boot default proxying mechanism CGLIB, so class name followed by "$$SpringCGLIB$$0" suffix.
See code:
https://github.com/springdoc/springdoc-openapi/blob/71a0684dc0eea2504f570aad90f5069319dfa061/springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java#L303

public static boolean isHiddenRestControllers(Class<?> rawClass) { return HIDDEN_REST_CONTROLLERS.stream().anyMatch(clazz -> clazz.isAssignableFrom(rawClass)); }

The Solution is to get real class name, for example:
org.springframework.util.ClassUtils.getUserClass(clazz).isAssignableFrom(rawClass)

  • spring-boot 3.2.4
  • springdoc-openapi-starter-common 2.6.0
  • The expected result is not to have controller with @hidden annotation in the openapi documentation.

image

image

bnasslahsen added a commit that referenced this issue Sep 24, 2024
… spring default proxying mechanism CGLIB. Fxies #2709
@bnasslahsen
Copy link
Contributor

@alla-gofman,

Added the fix you are requesting.
Can you validate it, at your end ?

@bnasslahsen bnasslahsen added the enhancement New feature or request label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants