-
Notifications
You must be signed in to change notification settings - Fork 123
Description
What Data Package version are you using?
v2
Describe the Issue
The JSON Data Resources recipe states:
The Data Resource
schemaproperty MUST follow the JSON Schema specification
However, the Data Resource validation schema unconditionally requires a fields property when a schema object is present:
"schema": {
"title": "Table Schema",
"type": ["string", "object"],
"required": ["fields"],
"properties": {
"$schema": {
"default": "https://datapackage.org/profiles/1.0/tableschema.json"
},
"fields": {
"type": "array",
"minItems": 1
}
}
}The fields property is a Table Schema concept and does not exist in JSON Schema. This means it's impossible to follow the JSON Data Resources recipe and pass validation against the Data Resource schema at the same time.
I noticed that the inner $schema property uses "default" (not "const" or "enum"), which suggests Table Schema is intended to be the default schema format, not the only one. But the hard "required": ["fields"] constraint makes it the only format that validates.
Steps to Reproduce
- Create a
datapackage.jsonwith"$schema": "https://datapackage.org/profiles/2.0/datapackage.json" - Add a resource following the JSON Data Resources recipe, with a
schemaproperty containing a valid JSON Schema object (nofieldsproperty) - Validate the file (e.g. VS Code's built-in JSON schema validation, or any JSON Schema validator)
- You should see
Missing property "fields"
Expected Behavior
Resources using JSON Schema (per the JSON Data Resources recipe) should validate without requiring a fields property.
Current Workaround
There is no clean workaround. Removing the profile property from resources does not help — the required: ["fields"] constraint is on the schema object itself, not conditional on profile. The only way to suppress the error is to remove the top-level $schema reference from datapackage.json, which disables all editor validation.
Suggested Fix
Update the Data Resource validation schema so that fields is only required when the schema is a Table Schema (e.g. using if/then based on the inner $schema value, or by making fields optional and relying on the Table Schema profile to enforce it).
Participation
- I am willing to submit a pull request for this issue.