quarkus-openapi-generator icon indicating copy to clipboard operation
quarkus-openapi-generator copied to clipboard

Server stubs that return jakarta.ws.rs.core.Response

Open DAAKNI opened this issue 1 year ago • 2 comments

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?

DAAKNI avatar Oct 30 '24 14:10 DAAKNI

@ricardozanini @hbelmiro This is being labeled as Stale.

github-actions[bot] avatar Dec 31 '24 12:12 github-actions[bot]

@carlesarnal can you please take a look?

ricardozanini avatar Jan 06 '25 17:01 ricardozanini

Hi @DAAKNI, sorry for the delay. Do you mean to have Response for all generated methods?

mcruzdev avatar Feb 28 '25 05:02 mcruzdev

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.

EricWittmann avatar Feb 28 '25 14:02 EricWittmann

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.

DAAKNI avatar Mar 18 '25 10:03 DAAKNI

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.

EricWittmann avatar Mar 18 '25 14:03 EricWittmann