You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When using the scala-sttp generator, any paths in the spec which have a default response result in generated API functions that always return Unit for a successful response(Unit in Scala is the equivalent of void in Java).
This is not an issue when the default response does not have a schema, but is incorrect when a default response schema is present, as it hides the response.
The problem is the use of asEither(asString, ignore) here when a spec has a default response on a path with a schema as the ignore portion on the right has the effect of ignoring whatever is on the Right of the Either (the success response).
Run openapi-generator-cli generate on the attached spec using the scala-sttp generator.
Check the showPetsById function in PetsApi.scala in the generated code.
Response type signature should be Request[Either[ResponseException[String, Exception], Pet], Any] as it returns a Pet response, but in fact it is Request[Either[Either[String, String], Unit], Any]
I believe I have a fix, and I'm happy to create a PR, but the contribution guidelines mention opening an Issue first.
Currently api.mustache checks for #defaultReturnType when it could check for ^returnType so that we're only returning unit when a return type is absent here:
Bug Report Checklist
Description
When using the scala-sttp generator, any paths in the spec which have a
default
response result in generated API functions that always returnUnit
for a successful response(Unit
in Scala is the equivalent ofvoid
in Java).This is not an issue when the default response does not have a schema, but is incorrect when a default response schema is present, as it hides the response.
The problem is the use of
asEither(asString, ignore)
here when a spec has a default response on a path with a schema as theignore
portion on the right has the effect of ignoring whatever is on the Right of the Either (the success response).openapi-generator version
6.4.0
OpenAPI declaration file content or url
https://gist.github.com/michaelmcguirk/0862f22cad0c8fafea9269cbe12ad3dc
Generation Details
Steps to reproduce
Request[Either[ResponseException[String, Exception], Pet], Any]
as it returns a Pet response, but in fact it isRequest[Either[Either[String, String], Unit], Any]
Related issues/PRs
#11949
Suggest a fix
I believe I have a fix, and I'm happy to create a PR, but the contribution guidelines mention opening an Issue first.
Currently api.mustache checks for
#defaultReturnType
when it could check for^returnType
so that we're only returning unit when a return type is absent here:openapi-generator/modules/openapi-generator/src/main/resources/scala-sttp/api.mustache
Line 39 in fbe768b
Updated api function response would be:
with the function signature being:
The text was updated successfully, but these errors were encountered: