swagger-api / swagger-api/swagger-core
Can't reference javax.ws.rs.core.Response.Status enum in @ApiResponse.responseCode
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
@ApiResponse.responseCode is a String. It seems like I am supposed to write a string literal containing the response code, such as "400", "402" etc.
I can't remember the numeric status codes. The implementation of the method references the Jax-RS javax.ws.rs.core.Response.Status when it needs a response code. It seems a shame that I either have to use a string literal magic constant or define my own set of constants somewhere.
I can't use the constants on HttpServletResponse, as they are defined as ints. I need a constant expression so I can't call Integer.toString etc on anything.
Whilst the spec defines this as a string, so responseCode needs to be a string, providing a second property that you can set to a Status value would seem sensible?
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
Locate the @ApiResponse annotation definition and the code that consumes responseCode; first inspect how annotation properties are represented and validated. Determine whether a typed Status-valued property can coexist with the specification’s string response code, then check the relevant annotation or API tests. Done means the requested constant-based usage is supported without breaking the existing responseCode behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100