Skip to content

Internal $id reference not derefernced #136

Closed

Description

@zuker

STR:

  1. Create file schema.json
{
  "$schema": "http://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://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

Activity

  1. zuker commented on Sep 10, 2019

    @zuker
    Author
  2. philsturgeon commented on Nov 26, 2022

    @philsturgeon
    Member

    Duplicate of #145.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions