Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive model definitions causes crash #63

Open
sev-g opened this issue Jan 29, 2019 · 5 comments
Open

recursive model definitions causes crash #63

sev-g opened this issue Jan 29, 2019 · 5 comments

Comments

@sev-g
Copy link

sev-g commented Jan 29, 2019

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>) 
@tmack8001
Copy link
Contributor

@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' }

@tmack8001
Copy link
Contributor

@tmack8001
Copy link
Contributor

tmack8001 commented Feb 28, 2019

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

@glebmachine
Copy link

got the same, with four huge swagger definition files

@ELymar
Copy link

ELymar commented Aug 18, 2020

The exception should be avoided now with #110 . Please see the description in the PR for how to set up to ignore circular references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants