We are using OpenAPI via gradle (i.e. openapi-generator-gradle-plugin) for generating Jersey resources. Generally speaking this works fine.
The generated methods look like this:
public Response getSomeFoo(@ApiParam(...) String someParam, ...) { ...
But we would also like to support methods that use the Asynchronous Server API.
In theory we could change all the generated synchronous methods to asynchronous ones, namely adapting the template files api.mustache
and apiService.mustache
where we replace the Response
by void
and adding the @Suspended final AsyncResponse asyncResponse
as first parameter (plus adding the imports etc.).
But it does not make sense for us to convert all the requests from being processed synchronously to asynchronously.
So my question is: How can we achieve some kind of "switch" to indicate in the input file already what kind of implementation we want to generate (synchronously/asynchronously) for each method?
I was thinking of writing a new generator that reads in a e.g. a tag from the input spec file and puts this into a boolean variable which is evaluated in the template files. Is this feasible? Is there any similar issue solved already? Or do you have any other ideas for me?
Thanks!