Skip to content

$id field is not being preserved #327

@snaum

Description

@snaum

"$id" field in the schema is being converted to "id".
This is a side effect that is not expected and not documented.

IMO, schema.toString() should use the version to determine whether to print "id" or "$id"
Please see the below unit test to reproduce.

`

public void testPreserveID(){
final JSONObject validSchema1JSON = new JSONObject(validSchema1);
SchemaLoader loader = SchemaLoader.builder().schemaJson(validSchema1JSON).draftV7Support().build();
Schema schema = loader.load().build();

	JSONObject resultSchemaJSON = new JSONObject(schema.toString());
	JSONObject originalSchemaJSON = new JSONObject(validSchema1);

	assertEquals(originalSchemaJSON.get("$id"),resultSchemaJSON.get("id"));
} 

`

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