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

json-schema-ref-loader can't handle circular references #2

Open
FabianFrank opened this issue Apr 24, 2018 · 5 comments
Open

json-schema-ref-loader can't handle circular references #2

FabianFrank opened this issue Apr 24, 2018 · 5 comments

Comments

@FabianFrank
Copy link

A simple JSON schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",

    "definitions": {
        "node": {
            "title": "a node",
            "type": "object",
            "properties": {
                "children": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/node"
                    }
                }
            }
        }
    }
}

causes json-schema-loader to fail with the following error:

ERROR in ../src/schema/node.json
Module build failed: TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at Object.handleResolveSuccess (/Users/fabian/projects/node-lib-spec/schema-doc/node_modules/json-schema-loader/lib/loader.js:19:21)
    at <anonymous>
@FabianFrank
Copy link
Author

I can fix it locally if I apply the change proposed in cloudflare/json-schema-loader#3

@handrews
Copy link
Contributor

@FabianFrank a PR would be most welcome! You will need to dig into @cloudflare/json-schema-transform as it wraps up the json-schema-ref-loader with some functionality to support a broader range of file formats. Let me know if you don't see what I mean.

@handrews
Copy link
Contributor

Oh and if you fix this please update the README in the json-schema-ref-loader workspace as it currently notes the cyclic references limitation.

@5amfung
Copy link

5amfung commented Feb 1, 2019

@handrews Do you know if a solution has been worked on since last update in April 2018? The project I'm working on uses getCollapseAllOfCallback for collapsing the allOf, but apparently, it won't work for circular reference although the RefParser was able to handle circular reference.

@handrews
Copy link
Contributor

handrews commented Feb 2, 2019

@5amfung I'm afraid I left the company not too long after my last comment above. @zackproser any idea if there's any active work here?

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