Skip to content

Conversation

jonaslagoni
Copy link

This PR addresses the issue where root level references to internal schema definitions are not resolved accurately.

Fixes #201

@jonaslagoni jonaslagoni changed the title fix: root level reference internally do not resolved fix: internal root level reference do not resolve Sep 23, 2021
@jonaslagoni
Copy link
Author

So, I am not quite sure of the best cause of action to solve this issue, so might need some pointers from someone who knows the code more in-depth 😄

Trying to dereference the input in the tests the following happens:

  1. First pass, the reference is being dereferenced -
    dereferenced = dereference$Ref(obj, path, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options);
  2. Then the pointer is resolved, it says it is a circular reference (and I cant figure out whether that is incorrect behavior) and the resolved value is the root schema when I believe it should be the resolved definition schema name. -
    let pointer = $refs._resolve($refPath, path, options);
pointer = { ..., path: "/Users/lagoni/Documents/AsyncAPI/json-schema-ref-parser/test/specs/root-internal/root-internal.yaml#/definitions/name", originalPath: "/Users/lagoni/Documents/AsyncAPI/json-schema-ref-parser/test/specs/root-internal/root-internal.yaml#/definitions/name", value: { definitions: { name: { title: "name", type: "object", required: [ "first", "last", ], properties: { first: { type: "string", }, last: { $ref: "#/definitions/name/properties/first", }, }, }, }, $ref: "#/definitions/name", }, circular: true, indirections: 0, } 
  1. Since the pointer is marked as circular, this means that the rest of the references are not crawled, which then means the $ref within the definition is not iterated, which to me indicate that there are multiple places that need to change, but I might be wrong 😅 -
    if (!circular) {

But from this point on, I do not know where or what to try and poke at...

Any suggestions?

cc @philsturgeon (as you are the most recently pushed changed, feel free to re-tag someone else 😄)

@jonaslagoni
Copy link
Author

With no interest, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant