Skip to content

fix: resolve @Hidden through the class hierarchy in Reader - #5342

Open
shamsManna wants to merge 1 commit into
swagger-api:masterfrom
shamsManna:hidden-annotation-inheritance
Open

shamsManna wants to merge 1 commit into
swagger-api:masterfrom
shamsManna:hidden-annotation-inheritance

Conversation

@shamsManna

Copy link
Copy Markdown

Description

Reader reads @Hidden with the raw cls.getAnnotation(Hidden.class) and method.getAnnotation(Hidden.class), while every other annotation at those same two sites goes through ReflectionUtils.getAnnotation, which also walks superclasses, implemented interfaces and meta-annotations. So with the usual JAX-RS layout of an annotated API interface plus an implementation class, a resource or operation marked @Hidden on the interface still ends up in the generated document that OpenApiResource/OpenApiServlet serve, exposing the path, its parameters and its request/response schemas. @Operation(hidden = true) on that same interface method is honoured, and @Hidden lists ANNOTATION_TYPE among its targets but is never resolved as a meta-annotation either, so both reads now go through ReflectionUtils.getAnnotation like their neighbours.

Fixes:

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

HiddenInheritedUserResource covers the three cases: @Hidden on an interface method, on an interface type, and through a meta-annotation. On master all three resources are emitted (/user/internal, /admin, /metrics); with this change only /user/public remains. Full ./mvnw install is green, including the swagger-jaxrs2 suite.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant