-
Notifications
You must be signed in to change notification settings - Fork 64
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
external references with references are not fully resolved #80
Comments
How are you running this? Are you running it via the CLI or programmatically? |
CLI as |
Can you run |
similar to "actual" for full resolution. Still missing the merged definition for {
"top": {
"a": {
"basic": "object"
},
"b": {
"$ref": "#/definitions/second-ref"
},
"c": null
}
} |
I'll give it a peek. |
|
Here is how {
"definitions": {
"bottom-third": null
},
"some-other": "object-thingy"
} I'll check to see if there is some sort of configuration to be warned of cases like these but based on what js-yaml is providing, json-refs is doing the right thing. I'm still looking at |
The second issue, |
Ah...I see what is up. So since we aren't resolving local references, we don't actually attempt to find the |
So right now, json-refs is working as expected believe it or not. But it's still broken as you can end up with documents containing references that will not resolve. |
I'm just not sure how to handle it. If you say "don't resolve local references", local references are left as-is and so they won't be resolved. |
If you resolve all references, it works just fine once we fix the mixed tab/spaces issues with the files you provided:
I still need to figure out how best to handler |
re: tabs mixed w/ spaces doh Re other: resolving external references should merge internal references from the external files so that the |
So here's my thoughts:
Thus the example becomes: top:
a:
basic: object
b:
$ref: "#/definitions/middle.yaml/second-ref"
c:
$ref: "#/definitions/bottom.yaml/bottom-third"
definitions:
middle.yaml:
second-ref:
second-object: is-here
bottom.yaml:
bottom-third:
some-other: object-thingy Some alternates:
|
It becomes very much like a real compiliation where you keep a symbol table of references and resolve them only if they're not found in the symtab. This is what I was starting to do in python before you generously offered to update json-refs. :) |
The problem isn't that we're not keeping track of state, it's that we resolve state based on what is requested and if you don't ask json-refs to resolve local references, we don't do it. This means that if you have a remote reference to a path in a document that itself has local references within said document, we don't resolve them because you've asked us not to. Since full resolution works just fine, this isn't a state issue. This is a "we need to rethink how |
Maybe it's just what you consider internal vs. external references. An internal reference inside an external file ought to be considered an external reference because it's external in reference to the root. Thoughts? In other words, the state stack can promote from internal -> external -> remote, but it can never demote from e.g. external -> internal? |
Please review #94 |
The resolver was rewritten to fix numerous bugs and performance issues. The reason for this is over the years, bug fixes and features have been added on top of json-refs and its resolver logic has become crufty. The new rewrite is clean, does not reinvent the wheel and fixes many bugs. Fixes: #80, #87, #88, #89, #97, #100, #101, #103
Given
root.yaml
middle.yaml
bottom.yaml
When requesting a full resolution
Command:
json-refs resolve root.yaml
expected
actual
when requesting an external-only resolution
Command:
json-refs resolve -I external root.yaml
I expect the output of a resolution to be internally consistent.
expected
_actual
File set: oas-bork.zip
The text was updated successfully, but these errors were encountered: