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

Doesn't work with schemas that have cyclical references #36

Open
ryanackley opened this issue Nov 10, 2022 · 2 comments
Open

Doesn't work with schemas that have cyclical references #36

ryanackley opened this issue Nov 10, 2022 · 2 comments

Comments

@ryanackley
Copy link

Some schemas have cyclical references. For example, a definition in the schema tree references a parent or ancestor

For an example in the wild see the bitbucket API swagger definition. https://api.bitbucket.org/swagger.json. The schema definition for "repository" in the definitions section has a reference to a parent repository.

Trying to use json-schema-merge-allof on this schema will cause Exception: Maximum call stack size exceeded because of infinite recursion.

For now, I can set deep: false but it would be nice if the library could detect that it is in an infinite recursion or alternatively, I could set a depth that would set the maximum recursions on a schema.

@mokkabonna
Copy link
Owner

mokkabonna commented Feb 25, 2023

Yeah I could maybe support that in the future.

I assume you use something like json-schema-ref-parser parser to dereference the schema? If you use the bundle function instead of dereference it will create a schema without circular references, but still dereference all into one schema.

@udamir
Copy link

udamir commented Jun 19, 2023

Hi, I had the same problem with cyclical references, so I wrote my own implementation, which solves this problem. You can try it: https://github.com/udamir/allof-merge

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

No branches or pull requests

3 participants