swagger-api / swagger-api/swagger-core
[Feature]: Need since or reason field in @Hidden annotation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
Feature Description
Add reason and since fields to the @Hidden annotation in swagger-core.
Currently, the @Hidden annotation is a binary toggle that prevents an element from appearing in the OpenAPI definition. However, it provides no context as to why the element was hidden or when that decision was made. Adding these fields would allow developers to document the lifecycle and rationale of API elements directly in the code.
Use Case
Without a reason or since field, team members often have to dive into Git history to understand why something is hidden or added comments in code.
Having this metadata in the code improves maintainability and developer experience.
Similar approach is provided in java @Deprecated(since = "....")
Suggested Solution (optional)
Update the @Hidden annotation to include a reason string (or since like @Deprecated)
public @interface Hidden {
/**
* The reason why this element is hidden
*/
String reason() default "";
/**
* The version or date since this element was hidden.
*/
String since() default "";
}
Alternatives Considered
Using // or /** */ comments
Additional Context
Adding such metadata aligns with modern Java practices, similar to how the @Deprecated annotation was enhanced to provide more than just a binary state. It improves the self-documenting nature of the source code.
Checklist
- I have searched the existing issues to ensure this is not a duplicate.
- This feature would be useful to more than just my use case.
- I have provided enough detail for the maintainers to understand the scope of the request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the @Hidden annotation in swagger-core and check any existing annotation tests or usage sites. Add the requested reason and since metadata with empty defaults, then verify that existing hidden-element behavior remains unchanged and that the new fields are available to annotation users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100