Skip to content

Commit

Permalink
fix(core): resolve value avoid infinite loop on multi files refs by a…
Browse files Browse the repository at this point in the history
…dding a parents relation
  • Loading branch information
anymaniax committed Apr 12, 2023
1 parent b2fc79d commit 9707881
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/core/src/resolvers/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@ export const resolveValue = ({

let hasReadonlyProps = false;

const spec = context.specs[context.specKey];

// Avoid infinite loop
if (
name &&
!name.startsWith(resolvedImport.name) &&
!spec?.components?.schemas?.[name]
) {
if (!name || !context.parents?.includes(name)) {
const scalar = getScalar({
item: schemaObject,
name: resolvedImport.name,
context: {
...context,
specKey: importSpecKey || context.specKey,
...(name ? { parents: [...(context.parents || []), name] } : {}),
},
});

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export interface ContextSpecs {
override: NormalizedOverrideOutput;
tsconfig?: Tsconfig;
packageJson?: PackageJson;
parents?: string[];
}

export interface GlobalOptions {
Expand Down

1 comment on commit 9707881

@vercel
Copy link

@vercel vercel bot commented on 9707881 Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.