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

$ref at root level is not omitted #174

Closed
dibericky opened this issue May 12, 2020 · 2 comments
Closed

$ref at root level is not omitted #174

dibericky opened this issue May 12, 2020 · 2 comments

Comments

@dibericky
Copy link

Steps to reproduce

With a jsonSchema like:

{
  components: {
    schemas: {
      Pet: {
        type: "string"
      }
    }
  },
  $ref: "#/components/schemas/Pet"
};

the $ref is correctly resolved, but is kept a "$ref: "#" in the result.
Example

+ expected - actual ... Lines skipped

  {
-   '$ref': '#',
    components: {
...
    type: 'string'
  }

What is expected?
I expect that the $ref is omitted from the result:

{
      components: {
        schemas: {
          Pet: {
            type: "string"
          }
        }
      },
      type: "string"
    }

Other info

  • node version: v10.20.1
  • json-schema-ref-parser version: 9.0.1
@Danielecina
Copy link

Danielecina commented May 13, 2020

I have the same problem.
This $ref left in the root, blocks the recursive resolution of the $ref

How to use example:

  • Fork example
  • Open new terminal panel
  • run yarn test
  • Example

@philsturgeon
Copy link
Member

Can you put the content in the root instead of defining it inside then hosting it with a $ref? This is known to work, and what you've got in this example isn't adding any benefit over it.

Also what is components, thats commonly used in OpenAPI v3.x which is a whole other thing.

Having siblings is not valid JSON Schema 07, it was added in JSON Schema 2019-09, which is being addressed in #145. Let's cover this there.

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

3 participants