Skip to content

Commit

Permalink
fix: do not crash handling Workday Open API (#105)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman authored May 8, 2024
1 parent 2e1403c commit c8c2de8
Show file tree
Hide file tree
Showing 5 changed files with 6,622 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/codegen/fromJsonSchema/cto/jsonSchemaVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class JsonSchemaVisitor {
* @private
*/
doesObjectContainAlternation(property) {
return !!(property.body?.anyOf || property.body?.oneOf);
return !!(property.body?.anyOf || property.body?.oneOf || property.body?.allOf);
}
/**
* Process a JSON Schema alternation object containing "anyOf" or a "oneOf"
Expand All @@ -86,15 +86,16 @@ class JsonSchemaVisitor {
// eslint-disable-next-line no-console
console.warn(
`Keyword '${
alternation.body.anyOf ? 'anyOf' : 'oneOf'
alternation.body.anyOf ? 'anyOf' : 'oneOf/allOf'
}' in definition '${
alternation.path[alternation.path.length - 1]
}' is not fully supported. Defaulting to first alternative.`
);

return (
alternation.body.anyOf ||
alternation.body.oneOf
alternation.body.oneOf ||
alternation.body.allOf
)[0];
}
/**
Expand Down Expand Up @@ -903,7 +904,7 @@ class JsonSchemaVisitor {
)
) {
throw new Error(
`Type keyword '${nonEnumDefinition.body.type}' in definition '${nameOfDefinition}' is not supported.`
`Type keyword '${nonEnumDefinition.body.type}' in definition '${nameOfDefinition}' is not supported. ${JSON.stringify(nonEnumDefinition, null, 2)}`
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/codegen/fromOpenApi/cto/openApiVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class OpenApiVisitor {
.filter(
restVerbEntry => requestBodyVerbs
.includes(restVerbEntry[0].toLowerCase()) &&
restVerbEntry[1]?.requestBody?.content &&
typeof Object.entries(
restVerbEntry[1].requestBody.content
).find(([k]) => requestBodyContentType.includes(k))
Expand Down
Loading

0 comments on commit c8c2de8

Please sign in to comment.