From 16d252256479ee314200b0fb3809e9764141d815 Mon Sep 17 00:00:00 2001 From: Eric Butler Date: Mon, 22 Jan 2024 14:49:29 -0500 Subject: [PATCH] fix: openapi 3.1 schemas with multiple types --- packages/core/src/getters/combine.ts | 7 +++++-- packages/core/src/getters/object.ts | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/src/getters/combine.ts b/packages/core/src/getters/combine.ts index c3dff71de..17a31e814 100644 --- a/packages/core/src/getters/combine.ts +++ b/packages/core/src/getters/combine.ts @@ -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), ); } diff --git a/packages/core/src/getters/object.ts b/packages/core/src/getters/object.ts index d8066d801..bb4b9bdce 100644 --- a/packages/core/src/getters/object.ts +++ b/packages/core/src/getters/object.ts @@ -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,