Streamline annotating a method's @Response when using JAX-RS Response object
See original GitHub issueOriginally posted in SmallRye here: https://github.com/smallrye/smallrye-open-api/issues/76
Content copy/pasted from source:
OpenApi has an ApiResponse annotation which, via its nested Content, can provide the information about the JAX-RS Response entity class.
While this annotation covers well for a case where Response dynamically sets different entity types per the current response media type, it is too complex for a typical case of Response returning a known single entity type only, with @Produces already typing a response media type.
One proposal is to have something like this:
@Produces("application/json")
@ApiResponseType(MyType.class)
@GET
public Response get() { return Response.ok(new MyType()).build(); }
but other options should also be considered
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Writing REST Services with RESTEasy Reactive
If you want to stream JSON objects in your response, you can use Server-Sent Events by just annotating your endpoint method with ......
Read more >Response (Java(TM) EE 7 Specification APIs)
The method may be annotated as @Deprecated in a future release of JAX-RS API. Returns: response headers as a multivalued map. getHeaders. public...
Read more >Developing a JAX-RS RESTful Service - dennis-xlc
The method returns a complex response to the client using the javax.ws.rs.core.Response class. The static Response.created() method creates a Response object ...
Read more >Chapter 8. JAX-RS Entity Providers
The last parameter of the isWriteable method is the mediaType which is the media type attached to the response entity by annotating the...
Read more >Response.ResponseBuilder (RESTEasy JAX-RS 3.0.9. ...
Several methods have parameters of type URI, UriBuilder provides convenient methods to create such values as does URI.create() . Where multiple variants of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Assuming everyone agrees this should be a new annotation and not a modification to
ApiResponse
and@RequestBody
, how about the following (to keep the naming in alignment with existing objects). Whether or not there are additional attributes besidesvalue
(status code?), also needs to be determined.I like those names @MikeEdgar, +1
My suggestion is to keep these new annotations very simple, with just the single field (Pojo ref). For anything else, such as setting multiple responses based on status code, the user would then utilize
@APIResponses
&@APIResponse
.