Skip to content

Commit

Permalink
fix: openapi 3.1 schemas with multiple types
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Butler committed Jan 22, 2024
1 parent 0af0ead commit 1ad79ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/getters/combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ export const combineSchemas = ({
acc.hasReadonlyProps ||= resolvedValue.hasReadonlyProps;

if (resolvedValue.type === 'object') {
acc.allProperties.push(
...Object.keys(resolvedValue.originalSchema.properties!),
);
if (resolvedValue.originalSchema.properties) {
acc.allProperties.push(
...Object.keys(resolvedValue.originalSchema.properties),
);
}
}

return acc;
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/getters/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export const getObject = ({

if (item.type instanceof Array) {
return combineSchemas({
schema: { anyOf: item.type.map((type) => ({ type })) },
schema: {
anyOf: item.type.map((type) => ({
...item,
type,
})),
},
name,
separator: 'anyOf',
context,
Expand Down

0 comments on commit 1ad79ab

Please sign in to comment.