Skip to content

Commit 69280a3

Browse files
authoredOct 19, 2023
fix(core): fix ref import file (#955)
1 parent a4cca88 commit 69280a3

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎packages/core/src/resolvers/ref.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ function getSchema<Schema extends ComponentObject = ComponentObject>(
6969
} {
7070
const refInfo = getRefInfo(schema.$ref, context);
7171

72-
const { specKey, refPaths } = refInfo;
72+
const { specKey, refPaths = [] } = refInfo;
7373

74-
const schemaByRefPaths: Schema | undefined =
75-
refPaths && get(context.specs[specKey || context.specKey], refPaths);
74+
let schemaByRefPaths: Schema | undefined = get(
75+
context.specs[context.specKey],
76+
refPaths,
77+
);
78+
if (!schemaByRefPaths) {
79+
schemaByRefPaths = context.specs?.[
80+
specKey || context.specKey
81+
] as unknown as Schema;
82+
}
7683
if (isReference(schemaByRefPaths)) {
7784
return getSchema(schemaByRefPaths, context);
7885
}

‎packages/core/src/utils/assertion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { extname } from './path';
99
* @param property
1010
*/
1111
export const isReference = (property: any): property is ReferenceObject => {
12-
return Boolean(property.$ref);
12+
return Boolean(property?.$ref);
1313
};
1414

1515
export const isDirectory = (path: string) => {

1 commit comments

Comments
 (1)

vercel[bot] commented on Oct 19, 2023

@vercel[bot]
Please sign in to comment.