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

fix: internal root level reference do not resolve #246

Closed

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Root ref fails to parse
1 participant