Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods return void instead of CompletionStage<Void> when reactive is enabled and OpenAPI operation has 204 return code #149

Closed
ppatierno opened this issue May 11, 2023 · 1 comment · Fixed by #161

Comments

@ppatierno
Copy link

ppatierno commented May 11, 2023

While using the apicurio-codegen with the reactive flag enabled, I have noticed that if an OpenAPI operation returns a 204 No Content as HTTP response code, the generator will generate a resource method returning just void.
Let's take the following operation as an example ...

https://github.com/strimzi/strimzi-kafka-bridge/blob/main/src/main/resources/openapi.json#L287

apicurio-codegen will generate a method like this ...

@Path("/{groupid}/instances/{name}/subscription")
@POST
@Consumes("application/vnd.kafka.v2+json")
void subscribe(@PathParam("groupid") String groupid, @PathParam("name") String name, Topics data);

Thinking about using this together with Quarkus RESTeasy Reactive, it sounds to me that if the method starts an async operation, the Quarkus framework responds to the HTTP client immediately with a 204 even if the async operation is not finished yet. At least this is my understanding.
Isn't it better to have apicurio-codegen generating methods returning CompletionStage<Void> in such a case?
This way, if an async operation starts, it has to complete the future before Quarkus can return the response to the HTTP client.

In our specific case, for example, the subscribe operation could take some time because it involves a Kafka consumer client to subscribe to topics in Kafka and it could even return an error.

Wdyt?

@MikeEdgar
Copy link
Contributor

This seems reasonable to me, and I wouldn't limit it to just void methods probably. If the Quarkus extension detects Resteasy Reactive, all of the return types would be CompletionStage<T> rather than T.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants