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

Internal $id reference not derefernced #136

Closed
zuker opened this issue Sep 10, 2019 · 2 comments
Closed

Internal $id reference not derefernced #136

zuker opened this issue Sep 10, 2019 · 2 comments

Comments

@zuker
Copy link

zuker commented Sep 10, 2019

STR:

  1. Create file schema.json
{
  "$schema": "http:https://json-schema.org/draft-07/schema#",

  "definitions": {
    "address": {
      "$id": "#address",
      "type": "object",
      "properties": {
        "street_address": { "type": "string" },
        "city":           { "type": "string" },
        "state":          { "type": "string" }
      },
      "required": ["street_address", "city", "state"]
    }
  },

  "type": "object",

  "properties": {
    "billing_address": { "$ref": "#address" },
    "shipping_address": { "$ref": "#address" }
  }
}

this actually example from https://json-schema.org/understanding-json-schema/structuring.html#using-id-with-ref

  1. npm i json-schema-ref-parser
  2. node -e "(async () => { console.log(JSON.stringify(await require('json-schema-ref-parser').dereference(require('./schema.json')), null, 2))})()"

Actual result:

{
  "$schema": "http:https://json-schema.org/draft-07/schema#",
  "definitions": {
    "address": {
      "$id": "#address",
      "type": "object",
      "properties": {
        "street_address": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        }
      },
      "required": [
        "street_address",
        "city",
        "state"
      ]
    }
  },
  "type": "object",
  "properties": {
    "billing_address": {
      "$ref": "#address"
    },
    "shipping_address": {
      "$ref": "#address"
    }
  }
}

Expected result:
properties.billing_address and properties.shipping_address are dereferenced

@zuker
Copy link
Author

zuker commented Sep 10, 2019

Seems this test https://github.com/APIDevTools/json-schema-ref-parser/blob/v7.1.1/test/specs/internal/bundled.js#L7
actualy not testing the case since #fragment has no other props

@philsturgeon
Copy link
Member

Duplicate of #145.

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.

2 participants