Closed
Description
Hi all,
I encountered an issue when trying to generate documentation from a set of schemas that contain a circular reference.
{
"$id": "https://example.org/foo",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"foo": {
"$ref": "#/definitions/bar"
}
},
"definitions": {
"bar": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/bar"
}
}
]
}
}
}
I get the following exception...
(node:53742) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
at formatRaw (internal/util/inspect.js:1014:12)
at formatValue (internal/util/inspect.js:793:10)
at inspect (internal/util/inspect.js:326:10)
at formatWithOptionsInternal (internal/util/inspect.js:1994:40)
at formatWithOptions (internal/util/inspect.js:1878:10)
at Object.value (internal/console/constructor.js:306:14)
at Object.log (internal/console/constructor.js:341:61)
at reducer (/usr/local/lib/node_modules/@adobe/jsonschema2md/lib/traverseSchema.js:17:11)
at Array.reduce (<anonymous>)
at reducer (/usr/local/lib/node_modules/@adobe/jsonschema2md/lib/traverseSchema.js:29:39)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:53742) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:53742) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The schema seems to be valid. I can avoid the issue by rewriting the schemas as...
{
"$id": "https://example.org/foo",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"foo": {
"$ref": "#/definitions/bar"
}
},
"definitions": {
"bar": {
"$id": "https://example.org/bar",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"$ref": "https://example.org/bar"
}
}
]
}
}
}
It seems that the error surfaces only with relative references.
Activity