jsf
jsf copied to clipboard
Handle self references
Seems to fail on all use of references including self references
Take a look at the 2 schemas attached
Not sure if that attachment worked.
BROKEN { "$schema": "http://json-schema.org/draft-04/schema#", "$ref": "#/definitions/Task", "type": "object", "description": "Schema description", "definitions": { "Task": { "type": "object", "properties": { "version": { "type": "string" }, "taskDuration": { "description": "Task duration in ms", "type": "string", "pattern": "^[0-9]+$" }, "taskResult": { "description": "Task result", "type": "string", "pattern": "^(success|(error(_([a-zA-Z][a-zA-Z0-9]+|[0-9]+))?))$" } }, "required": [ "taskDuration", "taskResult" ] } }, "additionalProperties": false }
WORKING { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "description": "Schema description", "properties": { "version": { "type": "string" }, "taskDuration": { "description": "Task duration in ms", "type": "string", "pattern": "^[0-9]+$" }, "taskResult": { "description": "Task result", "type": "string", "pattern": "^(success|(error(_([a-zA-Z][a-zA-Z0-9]+|[0-9]+))?))$" } }, "required": [ "taskDuration", "taskResult" ], "additionalProperties": false }
Reformatting here for contributors
Not functional - returns list of empty dicts
{
"$ref": "#/definitions/Task",
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"definitions": {
"Task": {
"properties": {
"taskDuration": {
"description": "Task duration in ms",
"pattern": "^[0-9]+$",
"type": "string"
},
"taskResult": {
"description": "Task result",
"pattern": "^(success|(error(_([a-zA-Z][a-zA-Z0-9]+|[0-9]+))?))$",
"type": "string"
},
"version": {
"type": "string"
}
},
"required": [
"taskDuration",
"taskResult"
],
"type": "object"
}
},
"description": "Schema description",
"type": "object"
}
Functional - without self reference
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Schema description",
"properties": {
"version": {
"type": "string"
},
"taskDuration": {
"description": "Task duration in ms",
"type": "string",
"pattern": "^[0-9]+$"
},
"taskResult": {
"description": "Task result",
"type": "string",
"pattern": "^(success|(error(_([a-zA-Z][a-zA-Z0-9]+|[0-9]+))?))$"
}
},
"required": [
"taskDuration",
"taskResult"
],
"additionalProperties": false
}
JSON diff
This is expected to work based on the JSON schema definitions so considered a BUG and a good first issue.