-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[BUG][typescript-fetch] Typescript error in generated code for endpoint returning type boolean #2870
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@matthewbpt is this issue still present? |
Hi @macjohnny , the issue is still present as far as I can see. I was thinking of implementing a fix when I reported the issue, but did not find the time, and we decided to use the typescript-axios generator instead as it does not have this issue. |
cc @TiFu |
I think the issue is probably in this line: The fix could be as simple as adding additional conditions here and adding a new response type to https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache Unfortunately I don't have time to implement this as I will be moving to another country next week. |
@matthewbpt would you give us a hand and try to fix it with @TiFu's suggestion? |
This is still present today on the latest version. |
The ironic part is that if you look at Should be relatively simple to fix, but I don't have much time. |
We have fixed this for our project by dropping primitive return values altogether in favour of objects with a single value of the primitive type. It can even be considered "better design" (i.e. consistent JSON) but not applicable for every one and every project out there. |
* Update apis.mustache Fixes OpenAPITools#3709 and OpenAPITools#2870. * Update apis.mustache * added new petstore code.
Typings are fixed, but serialization of the responses is still incorrect with |
I think the root cause is the CodeGen uses |
This is still an issue - 6.2.0 @pavel-zdenek |
Confirmed still an issue in 6.2.1 |
Bug Report Checklist
Description
When generating the typescript api client, the generated client has type errors for any methods returning a boolean.
The return statement from
userEmailExistsRaw
has error:openapi-generator version
4.0.0-beta3 from npm
OpenAPI declaration file content or url
Command line used for generation
openapi-generator generate --additional-properties supportsES6=true -i ./openapi.yaml -g typescript-fetch -o out/typescript-fetch
Steps to reproduce
Save yaml to
openapi.yaml
in current directory and run the command above.Suggest a fix
Since
true
andfalse
are both valid json responses, should the return statement simple bereturn new runtime.JSONApiResponse(response);
(This also satisfies the typechecker)The text was updated successfully, but these errors were encountered: