Open markuszoeller opened 4 months ago
Hello @markuszoeller, I'm not sure what's your expectation here. If it's for the extension to add the @ApiResponse annotation then that is simply not possible since that annotation is coming from swagger, not from JAX-RS, thus why we're not adding it.
Hello @markuszoeller, I'm not sure what's your expectation here.
Hi @carlesarnal I'd like to have a different HTTP status code for responses to a POST request. Right now the status code in a response to a POST request will be 200, but I'd like to have 201.
Maybe, instead of the currently generated code which returns the bean, here Pet
:
@Path("/pet")
public interface PetResource {
// [...]
/**
* <p>
* Add a new pet to the store
* </p>
*
*/
@POST
@Produces({"application/xml", "application/json"})
@Consumes({"application/xml", "application/json", "application/x-www-form-urlencoded"})
Pet addPet(@NotNull Pet data);
it could be
RestResponse<Pet> addPet(@NotNull Pet data);
Does that make any sense? I'm still new to the framework.
Hello @markuszoeller, I'm not sure what's your expectation here.
Hi @carlesarnal I'd like to have a different HTTP status code for responses to a POST request. Right now the status code in a response to a POST request will be 200, but I'd like to have 201.
Maybe, instead of the currently generated code which returns the bean, here
Pet
:@Path("/pet") public interface PetResource { // [...] /** * <p> * Add a new pet to the store * </p> * */ @POST @Produces({"application/xml", "application/json"}) @Consumes({"application/xml", "application/json", "application/x-www-form-urlencoded"}) Pet addPet(@NotNull Pet data);
it could be
RestResponse<Pet> addPet(@NotNull Pet data);
Does that make any sense? I'm still new to the framework.
The generated code is just a stub, so it doesn't return a 200 or a 201, that's up to your implementation. The only way to do that at the interface level is what I shared, using swagger specific annotations, and that is a no-go since it would imply adding another external dependency to the generator. If you're aware of any other way, I would be more than happy to explore it.
@ricardozanini @hbelmiro This is being labeled as Stale.
I'm using a locally built jar for the server generation: https://github.com/quarkiverse/quarkus-openapi-generator/pull/482#issuecomment-1964132436 and use the example of
POST /pet
defined in https://github.com/quarkiverse/quarkus-openapi-generator/blob/a8e255cb480b3cb3ea24e1079725a48ff81d3958/server/deployment/src/test/resources/openapi/petstore-openapi.json#L112-L155I'd rather have a HTTP status code of "201 Created" instead of "200 OK" for when the resource got created but it seems I cannot influence that. The generated code looks like this:
Even when I change it in the spec to
"201"
like this:the swagger UI still says it returns a 200 (same if I try it with
curl
):In the quarkus docs (https://quarkus.io/guides/resteasy-reactive), the
ResponseBuilder
is shown to set all kinds of details, including HTTP status code and for a POST, the location: https://javadoc.io/doc/io.quarkus.resteasy.reactive/resteasy-reactive-common/2.16.0.CR1/org/jboss/resteasy/reactive/RestResponse.html#created(java.net.URI)How can I change the HTTP response for the generated code?