What Data Package version are you using?
v2
Describe the Issue
The JSON Data Resources recipe states:
The Data Resource schema property 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.json with "$schema": "https://datapackage.org/profiles/2.0/datapackage.json"
- Add a resource following the JSON Data Resources recipe, with a
schema property containing a valid JSON Schema object (no fields property)
- 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
What Data Package version are you using?
v2
Describe the Issue
The JSON Data Resources recipe states:
However, the Data Resource validation schema unconditionally requires a
fieldsproperty when aschemaobject is present:The
fieldsproperty 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
$schemaproperty 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
datapackage.jsonwith"$schema": "https://datapackage.org/profiles/2.0/datapackage.json"schemaproperty containing a valid JSON Schema object (nofieldsproperty)Missing property "fields"Expected Behavior
Resources using JSON Schema (per the JSON Data Resources recipe) should validate without requiring a
fieldsproperty.Current Workaround
There is no clean workaround. Removing the
profileproperty from resources does not help — therequired: ["fields"]constraint is on theschemaobject itself, not conditional onprofile. The only way to suppress the error is to remove the top-level$schemareference fromdatapackage.json, which disables all editor validation.Suggested Fix
Update the Data Resource validation schema so that
fieldsis only required when the schema is a Table Schema (e.g. usingif/thenbased on the inner$schemavalue, or by makingfieldsoptional and relying on the Table Schema profile to enforce it).Participation