Data Resource JSON schema definition for `schema` seems to contradict specification
See original GitHub issueOverview
Problem description
Caution: there’s a lot of different uses of “schema” coming, so bear with me…
In the JSON schema definition file for a resource, data-resource.json, the formal definition for a schema
property of a Resource is:
"schema": {
"propertyOrder": 40,
"title": "Schema",
"description": "A schema for this resource.",
"type": "object"
},
This allows only JSON-objects as schema
definitions, essentially JSON-Strings. It disallows URLs or file paths.
This seemingly contradicts the human-readable specification of a schema
property:
The value for the schema property on a resource MUST be an object representing the schema OR a string that identifies the location of the schema.
(Emphasis mine).
Proposed fix
I believe the section should read:
"oneOf": [
{
"title": "Schema path",
"description": "A fully qualified URL, or a POSIX file path..",
"type": "string"
},
{
"title": "Schema as JSON",
"description": "A schema encoded as a JSON object",
"type": "object"
}
]
I am no specialist for JSON schema, but if I change it, the Java implementation works with schema
properties that are URLs and file paths.
How to reproduce
Reproduce the buggy behavior
-
copy the JSON content from https://frictionlessdata.io/schemas/data-resource.json into the “Schema” field on the left
-
Copy into “Input JSON” on the right the following JSON:
{ "name": "test", "schema": "https://raw.githubusercontent.com/frictionlessdata/datapackage-java/master/src/test/resources/fixtures/schema/population_schema.json", "path": "https://raw.githubusercontent.com/frictionlessdata/datapackage-java/master/src/test/resources/fixtures/data/cities.csv" }
Result: validation will fail with the following error:
Found 1 error(s) Message: Invalid type. Expected Object but got String. Schema path: #/properties/schema/type
Reproduce the proposed fix
- Insert the proposed fix into the schema JSON
- Run validation against the same JSON snippet
Result: no validation error will be shown.
Fix to YAML source
Created a pull request, please check and if working, merge
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
Thanks @iSnow! @rufuspollock + @pwalsh what do you think?
Does the path need to be to a JSON file with schema, or schema in a yaml file is good too?