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
is an array of non-primitive elements (e.g. array of objects) and
is serialized to JSON (e.g. when used in a request body) and
is not set/set to undefined (i.e. omitted)
... then the generated {{classname}}ToJSON function will produce a TypeError on run-time because Array.prototype.map() is called on the undefined property.
Runtime Error Message
TypeError: value.replacements is undefined
openapi-generator version
Tested on v4.0.0-beta2. No relevant changes have been made since then.
Use the object as the schema for a JSON request body.
Generate client code with typescript-fetch.
Call the API method with the property in question left undefined.
Related issues/PRs
This bug was introduced with the refactoring in #569.
I'm aware that #802 will probably deprecate this eventually.
Suggest a fix
A PR will follow soon.
Idea: The call to Array.prototype.map() needs to be guarded against undefined.
This is already done on other optional properties such as Dates, as well as on JSON deserialization.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
[Optional] Bounty to sponsor the fix (example)Description
When an object property ...
undefined
(i.e. omitted)... then the generated
{{classname}}ToJSON
function will produce a TypeError on run-time becauseArray.prototype.map()
is called on the undefined property.Runtime Error Message
openapi-generator version
Tested on v4.0.0-beta2. No relevant changes have been made since then.
OpenAPI declaration file content or url
Command line used for generation
openapi-generator-cli -g typescript-fetch -i openapi.yml -o src/api/
Steps to reproduce
typescript-fetch
.undefined
.Related issues/PRs
This bug was introduced with the refactoring in #569.
I'm aware that #802 will probably deprecate this eventually.
Suggest a fix
A PR will follow soon.
Idea: The call to
Array.prototype.map()
needs to be guarded againstundefined
.This is already done on other optional properties such as
Date
s, as well as on JSON deserialization.The text was updated successfully, but these errors were encountered: