ZenWave360/json-schema-ref-parser-jvm

Dereferencing a Object deletes all other parts of that Object

Closed this issue · 2 comments

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

Hi @SKreileder , thanks for this... I was offline for a couple of weeks
I will take care of this next week

This has been release as v0.8.8. Thanks for taking the time reporting it. 🙏