Open WonderCsabo opened 1 year ago
@jimschubert @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m
In case you accept this feature, i would gladly contribute this.
Hi, thanks for taking the time to improve openapi-generator. We try to avoid creating CLI options, because when we have lots of them, it's hard to maintain all the possible configurations. I'm not sure, I think we could add this option to have direct access to the response, although that way we lose some information from the response.
I understand your point about the CLI option. I suggested one to retain the option for having more information about the response if users want that.
I also looked into the retrofit2/api.mustache template in mode detail, and the useRxJavaX
options also omit this Response<>
wrapper, only useCoroutines
adds it.
Are you suggesting to introduce a CLI option to enable/disable Response<>
on all response types?
I understand the code which is generated is opinionated. But it should be consistent (currently Rx and coroutines are different on this matter).
For my use case, i would prefer without the wrapper of course. But i see there are other users of this tool.
I think introducing a CLI option to enable/disable Response<>
on all response types would fix the consistent.
What do you think?
Yes, that would work for me. BTW, this CLI option would only apply to the retrofit2
library.
It would be nice to apply to all configurations, but we can expand it in the future
To be honest i do not even know if this is applicable to the other libraries.
Me neither because I'm not in front of a pc. Can you please open a PR with it?
Currently if you use Coroutines (
suspend
modifier), your generated API functions will look like this:However there is another way to define the return type of the endpoint. You can omit the
Response<>
wrapper, and just return theUser
, like this:This is described here in the Retrofit documentation.
It would be great if OpenAPI generator offer this as well. It could be controlled by a CLI option, and it could generated the current
Response<User>
form by default.