quarkus-openapi-generator
quarkus-openapi-generator copied to clipboard
Server stubs that return jakarta.ws.rs.core.Response
I have several methods that just return jakarta.ws.rs.core.Response. Is it possible for the with the server-extension generated stubs to return jakarta.ws.rs.core.Response?
@ricardozanini @hbelmiro This is being labeled as Stale.
@carlesarnal can you please take a look?
Hi @DAAKNI, sorry for the delay. Do you mean to have Response for all generated methods?
It turns out that we already have this feature:
https://github.com/Apicurio/apicurio-codegen/blob/main/core/src/test/resources/OpenApi2JaxRsTest/custom-response-type.json#L64
There are actually a bunch of vendor extensions that can be used to customize the output of the generator. This is one of them.
Sorry, only managed now to look into the issue again.
@mcruzdev Yes, I wanted jakarta.ws.rs.core.Response as a return type for generated methods.
Turns out the following :
responses:
"200":
description: OK
produces void as return type where as specifiyng content application/json produces the desired jakarta.ws.rs.core.Response
responses:
"200":
description: OK
content:
application/json:
schema: {}
Thank you @EricWittmann for looking into this as well.
Ah yes - that makes sense too. Without the content section, it will think you don't want to return anything (which is weird for a 200 response, but it figures you know what you're doing). :)
Side note: I believe that lacking a content in a 200 response is not a violation of the OpenAPI spec. So probably most tools by default won't even warn you about that. If I had more time to work on this area, it would be interesting to have a set of rules (e.g. Spectral rules or something) that would identify stuff like this.