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

Root ref fails to parse #201

Closed
isaacl opened this issue Dec 17, 2020 · 3 comments
Closed

Root ref fails to parse #201

isaacl opened this issue Dec 17, 2020 · 3 comments

Comments

@isaacl
Copy link

isaacl commented Dec 17, 2020

{
  "$ref": "#/definitions/EmailConfig",
  "$schema": "http:https://json-schema.org/draft-07/schema#",
  "definitions": {
    "EmailConfig": {
      "additionalProperties": false,
      "properties": {
        "adminContact": {
          "type": "string"
        }
      }
    }
  }
}

is valid (in fact is part of the test suite here). But json-schema-to-typescript fails to resolve the ref using this library.


Originally filed at bcherny/json-schema-to-typescript#349

@vinyasns
Copy link

@isaacl Yes I faced the same issue, it gives 'Circular $ref pointer found ...' error even though this is a valid case.

@abrgr
Copy link

abrgr commented Jun 10, 2022

This also fails for me but just incorrectly resolves the reference instead of failing with a circular ref pointer error. I believe that my issue is due to this check in Pointer::resolve:

if (typeof this.value === "object" && this.value !== null && "$ref" in this.value) {
  return this;
}

This causes any reference at the top level to resolve to a pointer to the root instead of falling through to resolve the reference properly.

Is this check necessary? It seems that this will prevent correct pointer resolution for any schema with a top-level reference.

@philsturgeon
Copy link
Member

If this is still an issue please can somebody send a pull request.

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 a pull request may close this issue.

4 participants