-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Max call stack if schema already has circular references #23
Comments
I'm not sure what you're trying to accomplish here. The The idea is that you have an object like this: {
"y": 1,
"z": {
"x": {
"$ref": "#/" // <-- Reference to the document root
}
}
} You could then pass that object to the {
"y": 1,
"z": {
"x": {...} // <--- circular reference
}
}
obj.z.x === obj; // true
obj.z.x.z === obj.z; // true
obj.z.x.z.x === obj; // true |
So it may be out of scope but I'm using it in .js config files. These files are not guaranteed to be 'JSON' compatible but can have complex objects. I allow json refs to be used in the config and then the paths are resolved with dereference later. This allows the nested config to be really easy to swap some values without having to change multiple places (unless you want to). Example: Base config:
Override config:
Other app override config:
|
So how do you end up with circular references in the config object? Neither the base config, nor the override config, nor the 2nd override config contain any circular references, so they should all merge to produce |
Some implementations are out of my control and contain circular references. For example the |
ah, ok. I see. I could add circular-reference detection logic to JSON Schema $Ref Parser, but I would prefer to avoid adding that extra overhead, since the intended use-case is to process JSON data, not JavaScript object trees. Supporting JavaScript object trees adds other additional complications too, such as prototype chains, non-enumerable properties, symbols, proxies, and non-JSON data types (Date, RegExp, etc.). Perhaps an acceptable approach would be for you to convert your |
OK i'll try that approach. thanks |
If the schema includes circular references already a max call stack is hit.
The text was updated successfully, but these errors were encountered: