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 the request body is directly a set of strings (NOT wrapped in an object), the application crashes at runtime because the Set<string> is not converted to an Array first, thus it generates the JSON {}.
If the request body is wrapped in an object, then it works fine.
openapi-generator version
I am using the openapitools/openapi-generator-cli:latest Docker image.
I think the fix is partial, and does not support request bodies that are not wrapped in an object
Note that using the workaround --type-mappings='set=Array' as suggested in some related issues does NOT work, it results in a type-checking error.
The workaround I have to use for now is to wrap the request body in an object.
Then Array.from is used in the generated code.
But it adds an unnecessary layer in the model.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When the request body is directly a set of strings (NOT wrapped in an object), the application crashes at runtime because the
Set<string>
is not converted to anArray
first, thus it generates the JSON{}
.If the request body is wrapped in an object, then it works fine.
openapi-generator version
I am using the
openapitools/openapi-generator-cli:latest
Docker image.OpenAPI declaration file content or url
The generated Typescript file is:
requestParameters['requestBody']
I think it should actually be something like (I'm no Typescript expert so maybe it should be slightly different):
Generation Details
Steps to reproduce
addPet({requestBody: new Set<string>(["a"])})
(it typechecks){}
instead of["a"]
Related issues/PRs
typescript-angular
, nottypescript-fetch
typescript-rxjs
Note that using the workaround
--type-mappings='set=Array'
as suggested in some related issues does NOT work, it results in a type-checking error.The workaround I have to use for now is to wrap the request body in an object.
Then
Array.from
is used in the generated code.But it adds an unnecessary layer in the model.
The text was updated successfully, but these errors were encountered: