swagger-combine
swagger-combine copied to clipboard
recursive model definitions causes crash
version 0.18.1
If you have a model with a recursive property like:
"Person": {
"required": ["id", "persons"],
"type": "object",
"properties": {
"id": {
"format": "int64",
"minimum": 0,
"exclusiveMinimum": true,
"minLength": 1,
"type": "integer",
"readOnly": true
},
"persons": {
"uniqueItems": false,
"type": "array",
"items": {
"$ref": "#/definitions/Person"
},
"readOnly": true
}
}
}
then the code generation will crash with:
Failed to find schema example for Person
RangeError: Maximum call stack size exceeded
at String.replace (<anonymous>)
at Function.Pointer.join (/app-run/node_modules/json-schema-ref-parser/lib/pointer.js:198:44)
at /app-run/node_modules/json-schema-ref-parser/lib/resolve-external.js:63:31
at Array.forEach (<anonymous>)
at crawl (/app-run/node_modules/json-schema-ref-parser/lib/resolve-external.js:62:24)
at /app-run/node_modules/json-schema-ref-parser/lib/resolve-external.js:70:38
at Array.forEach (<anonymous>)
at crawl (/app-run/node_modules/json-schema-ref-parser/lib/resolve-external.js:62:24)
at /app-run/node_modules/json-schema-ref-parser/lib/resolve-external.js:70:38
at Array.forEach (<anonymous>)
@SevastianGioanca I'm getting the same failure.
{ RangeError: Maximum call stack size exceeded
at Array.forEach (native)
at crawl (~/.nvm/versions/node/v8.1.4/lib/node_modules/swagger-combine/node_modules/json-schema-ref-parser/lib/resolve-external.js:61:24)
at ~/.nvm/versions/node/v8.1.4/lib/node_modules/swagger-combine/node_modules/json-schema-ref-parser/lib/resolve-external.js:69:38
at Array.forEach (native)
at crawl (~/.nvm/versions/node/v8.1.4/lib/node_modules/swagger-combine/node_modules/json-schema-ref-parser/lib/resolve-external.js:61:24)
at ~/.nvm/versions/node/v8.1.4/lib/node_modules/swagger-combine/node_modules/json-schema-ref-parser/lib/resolve-external.js:69:38
at Array.forEach (native)
at crawl (~/.nvm/versions/node/v8.1.4/lib/node_modules/swagger-combine/node_modules/json-schema-ref-parser/lib/resolve-external.js:61:24)
at ~/.nvm/versions/node/v8.1.4/lib/node_modules/swagger-combine/node_modules/json-schema-ref-parser/lib/resolve-external.js:69:38
at Array.forEach (native)
api: 'https://some.domain/swagger.yaml' }
likely to be caused by https://github.com/APIDevTools/json-schema-ref-parser/issues/36 or https://github.com/APIDevTools/json-schema-ref-parser/issues/40
In my scenario I wasn't purposefully making an infinite nesting behavior... so I've now split the swagger data types to prevent an indefinite nesting and instead just a 2 layer nesting
got the same, with four huge swagger definition files
The exception should be avoided now with #110 . Please see the description in the PR for how to set up to ignore circular references.