Skip to content

jsonref removes existing key-values if reference is present #60

@lucasrodes

Description

@lucasrodes

Given the schema:

{
  "foo": {
    "$ref": "#/def/url",
    "title": "something additional that should not be removed"
  },
  "def": {
      "url": {
        "pattern": "pattern",
        "type": "string"
      }
  }
}

When loading it with jsonref.loads, the key title is removed:

import jsonref

loaded = jsonref.loads('''
{
  "foo": {
    "$ref": "#/def/url",
    "title": "something additional that should not be removed"
  },
  "def": {
      "url": {
        "pattern": "pattern",
        "type": "string"
      }
  }
}
''')
loaded

Outputs:

{'foo': {'pattern': 'pattern', 'type': 'string'},
 'def': {'url': {'pattern': 'pattern', 'type': 'string'}}}

But I'd expect

{'foo': {'pattern': 'pattern', 'type': 'string', 'title': 'something additional that should not be removed'},
 'def': {'url': {'pattern': 'pattern', 'type': 'string'}}}

Is this expected?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions