Skip to content

Commit

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

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

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 35e5074

Please sign in to comment.