You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using $ref on the top-level to reference a defined type in $defs it wrongly results in a TypeError: Converting circular structure to JSON which is not a circular reference.
According to the JSON Schema Core Specification Draft 2020-12 (see 7.5. Applicators) it is valid to use $ref on the top-level.
Here's a example schema:
node test.js
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'| property 'TopLevelType' -> object with constructor 'Object'| property 'properties' -> object with constructor 'Object'| property 'prop1' -> object with constructor 'Object'
--- property '$defs' closes the circle
at JSON.stringify (<anonymous>)
at normalizeArgs (node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js:46:34)
at $RefParser.dereference (node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js:193:54)
at Object.dereference (node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js:190:37)
at file://test.js:6:41
It has been reproduced with version 12.0.1 of @apidevtools/json-schema-ref-parser.
When using
$ref
on the top-level to reference a defined type in$defs
it wrongly results in aTypeError: Converting circular structure to JSON
which is not a circular reference.According to the JSON Schema Core Specification Draft 2020-12 (see
7.5. Applicators
) it is valid to use$ref
on the top-level.Here's a example schema:
Trying to resolve this issue using the following test program:
Results in the following error:
It has been reproduced with version
12.0.1
of@apidevtools/json-schema-ref-parser
.The resolution of this issue is required for skriptfabrik/json-schema-bundler#28.
The text was updated successfully, but these errors were encountered: