Philipp Munin
Philipp Munin

Reputation: 5903

Are circular references between JSON Schemas (different files) allowed?

I have two JSON schemas that link each other: schema.task.json and schema.dependency.json:

//file: schema.task.json
{
    "$schema": "http://json-schema.org/draft-04/schema",
    "type": "object",
    "properties": {
        "Dependencies": { "type": "array", "items": { "$ref": "schema.dependency.json#" } },
        "TaskName": { "type": "string" }
    }
}

//file: schema.dependency.json
{
    "$schema": "http://json-schema.org/draft-04/schema",
    "type": "object",
    "properties": {
        "StartAfterTask": { "$ref": "schema.task.json" },
        "DependencyName": {"type": "string"}
    }

}

When I try to edit json that use my Task schema, I see error in output window of visual studio:

Error loading schema ...\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\schema.dependency.json

Value cannot be null. Parameter name: uriString

If I'm doing circular reference within one file (in definitions section), it works fine.

I'm using Visual Studio 2013, Update 5, with schema http://json-schema.org/draft-04/schema

Does anyone know the right way to create JSON schemas with cross-files circular dependencies?

Upvotes: 1

Views: 1086

Answers (1)

cloudfeet
cloudfeet

Reputation: 12873

Yes, this is allowed - references between two different files are no different to reference within a file.

The syntax you've posted looks correct - have you tried raising an issue with the library you're using?

Upvotes: 0

Related Questions