Skip to content

Dereferencing a Object deletes all other parts of that Object #11

@SKreileder

Description

@SKreileder

I have a schema

{
  "$schema" : "http://json-schema.org/draft-07/schema#",
  "type" : "object",
  "properties" : {
    "referingProperty" : {
      "$ref" : "https://json.schemastore.org/base.json#/definitions/nullable-boolean",
      "title" : "referingProperty",
      "description" : "A property that is refering to the base.json of json.schemastore.org"
    }
  }
}

When I try to dereference that schema using:

String schema = """
                {
                  "$schema" : "http://json-schema.org/draft-07/schema#",
                  "type" : "object",
                  "properties" : {
                    "referingProperty" : {
                      "$ref" : "https://json.schemastore.org/base.json#/definitions/nullable-boolean",
                      "title" : "referingProperty",
                      "description" : "A property that is refering to the base.json of json.schemastore.org"
                    }
                  }
                }
                """;

$RefParser parser = new $RefParser(schema)
        .withOptions(new $RefParserOptions().withOnCircular(SKIP));
$Refs refs = parser.parse().dereference().getRefs();
Map<String, Object> properties = (Map<String, Object>) refs.get("properties");
Map<String, Object>referingProperty = (Map<String, Object>) properties.get("referingProperty");
for(var value : referingProperty.entrySet()){
   System.out.println(value);
}

It returns:

type=[boolean, null]

Which is exactly what was supposed to be dereferenced, what is missing is the rest of "referingProperty".

For comparison, this is the return if you remove ".dereference()":

$ref=https://json.schemastore.org/base.json#/definitions/nullable-boolean
title=referingProperty
description=A property that is refering to the base.json of json.schemastore.org

I'd expect the result of ".dereference()" to be a mix of the two:

type=[boolean, null]
title=referingProperty
description=A property that is refering to the base.json of json.schemastore.org

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