diff --git a/packages/core/src/resolvers/ref.ts b/packages/core/src/resolvers/ref.ts index 52514ebe0..c6b28ae8c 100644 --- a/packages/core/src/resolvers/ref.ts +++ b/packages/core/src/resolvers/ref.ts @@ -69,10 +69,17 @@ function getSchema( } { const refInfo = getRefInfo(schema.$ref, context); - const { specKey, refPaths } = refInfo; + const { specKey, refPaths = [] } = refInfo; - const schemaByRefPaths: Schema | undefined = - refPaths && get(context.specs[specKey || context.specKey], refPaths); + let schemaByRefPaths: Schema | undefined = get( + context.specs[context.specKey], + refPaths, + ); + if (!schemaByRefPaths) { + schemaByRefPaths = context.specs?.[ + specKey || context.specKey + ] as unknown as Schema; + } if (isReference(schemaByRefPaths)) { return getSchema(schemaByRefPaths, context); } diff --git a/packages/core/src/utils/assertion.ts b/packages/core/src/utils/assertion.ts index 316afdadc..2e4f8efc6 100644 --- a/packages/core/src/utils/assertion.ts +++ b/packages/core/src/utils/assertion.ts @@ -9,7 +9,7 @@ import { extname } from './path'; * @param property */ export const isReference = (property: any): property is ReferenceObject => { - return Boolean(property.$ref); + return Boolean(property?.$ref); }; export const isDirectory = (path: string) => {