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

Resolution does not work when first level properties contain circular references. #180

Open
tjainesri opened this issue Jun 14, 2020 · 1 comment

Comments

@tjainesri
Copy link

I have read the 3 cases where the library treats references as circular. As far as I can tell only rule 1 pertains to local references and it makes sense. A/b -> B/c -> C/a is obviously circular but what I am confused about is references at the root level properties? A -> B -> A. Shouldn't these be treated as circular as well?

Here is a simple example to reproduce what I think is an error:

{
"param1": {
"$ref": "#/param2"
},
"param2": {
"$ref": "#/param1"
}
}

Calling resolveRefs on the object above results in the following resolution result:
{
"refs": {
"#/param1": {
"def": { "$ref": "#/param2" },
"uri": "#/param2",
"uriDetails": { "path": "", "fragment": "/param2", "reference": "same-document" },
"type": "local",
"fqURI": "#/param2",
"value": { "$ref": "#/param1" }
},
"#/param2": {
"def": { "$ref": "#/param1" },
"uri": "#/param1",
"uriDetails": { "path": "", "fragment": "/param1", "reference": "same-document" },
"type": "local",
"fqURI": "#/param1",
"value": { "$ref": "#/param1" }
}
},
"resolved": {
"param1": {
"$ref": "#/param1"
},
"param2": {
"$ref": "#/param1"
}
}
}

Expected behavior: The circular flag for the two references should have been set to true.

@whitlockjc
Copy link
Owner

This is indeed a bug, I apologize. I agree that the reference details for both should have circular: true.

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

2 participants