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
I have a few oneOf declaration. Array of strings never go through, so I have to bypass or edit the generated code that creates the objects. Here is a simplified example:
The above generates the following code inside the BookAuthor.js class. The condition under "validate array of strings" will never succeed with an array of strings!
try{// validate array data typeif(!Array.isArray(instance)){thrownewError("Invalid data type. Expecting array. Input: "+instance);}// validate array of stringfor(constitemofinstance){if(!(typeofitem==='number'&&item%1===0)){thrownewError("Invalid array items. Must be string. Input: "+instance);}}this.actualInstance=instance;match++;}catch(err){// json data failed to deserialize into [String]errorMessages.push("Failed to construct [String]: "+err)}
If the condition would read as if (!(typeof item === "string")) {, it would solve the issue.
jmlord
changed the title
[BUG][Javascript client] OneOf including array of string conditions always fails
[BUG][Javascript client] oneOf including array of string conditions always fails
Aug 22, 2023
jmlord
changed the title
[BUG][Javascript client] oneOf including array of string conditions always fails
[BUG][Javascript client] array of string conditions always fails
Aug 24, 2023
jmlord
changed the title
[BUG][Javascript client] array of string conditions always fails
[BUG][Javascript client] oneOf including array of string conditions always fails
Aug 24, 2023
Description
I have a few oneOf declaration. Array of strings never go through, so I have to bypass or edit the generated code that creates the objects. Here is a simplified example:
The above generates the following code inside the
BookAuthor.js
class. The condition under "validate array of strings" will never succeed with an array of strings!If the condition would read as
if (!(typeof item === "string")) {
, it would solve the issue.openapi-generator version
7.0.0-SNAPSHOT
Generation Details
docker pull openapitools/openapi-generator-cli:latest docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ -i /local/openapi.yaml \ -g javascript \ -o /local/
Steps to reproduce
Related issues/PRs
#10514
#13539
Suggest a fix
If the condition would read as
if (!(typeof item === "string")) {
, it would solve the issue.The text was updated successfully, but these errors were encountered: