Skip to content

Commit 1d3300a

Browse files
committed
fix: slight change in allOf merging
1 parent 69d64ff commit 1d3300a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tree/utils/mergeAllOf.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { pathToPointer } from '@stoplight/json';
1+
import { pathToPointer, safeStringify } from '@stoplight/json';
22
import { JsonPath } from '@stoplight/types';
33
import { JSONSchema4 } from 'json-schema';
4-
import { cloneDeep } from 'lodash';
54
import { ResolvingError } from '../../errors';
65
import { WalkingOptions } from './populateTree';
76

@@ -10,7 +9,7 @@ const resolveAllOf = require('@stoplight/json-schema-merge-allof');
109
const store = new WeakMap<WalkingOptions, WeakMap<JSONSchema4, string[]>>();
1110

1211
function _mergeAllOf(schema: JSONSchema4, path: JsonPath, opts: WalkingOptions) {
13-
return resolveAllOf(cloneDeep(schema), {
12+
return resolveAllOf(schema, {
1413
deep: false,
1514
resolvers: resolveAllOf.stoplightResolvers,
1615
$refResolver($ref: unknown) {
@@ -28,7 +27,8 @@ function _mergeAllOf(schema: JSONSchema4, path: JsonPath, opts: WalkingOptions)
2827
if (schemaRefs === void 0) {
2928
allRefs.set(schema, [$ref]);
3029
} else if (schemaRefs.includes($ref)) {
31-
throw new ResolvingError('Circular reference detected');
30+
const resolved = JSON.parse(safeStringify(opts.resolveRef(null, $ref)));
31+
return 'allOf' in resolved ? _mergeAllOf(resolved, path, opts) : resolved;
3232
} else {
3333
schemaRefs.push($ref);
3434
}

0 commit comments

Comments
 (0)