Problem/Motivation
Discovered while working on https://www.drupal.org/project/field_ui_modern.
For example:
{
"$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
"$id": "http://core.test/jsonapi/field_storage_config/field_storage_config/resource/schema",
"title": "Field storage",
"allOf": [
{
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/type"
},
"attributes": {
"$ref": "#/definitions/attributes"
}
}
},
{
"$ref": "https://jsonapi.org/schema#/definitions/resource"
}
],
"definitions": {
"type": {
"const": "field_storage_config--field_storage_config"
},
"attributes": {
"properties": {
"drupal_internal__id": {
"type": "string",
"title": "drupal_internal__id"
},
"langcode": {
"type": "string",
"title": "langcode"
},
"status": {
"type": "boolean",
"title": "status"
},
"dependencies": {
"title": "dependencies"
},
"third_party_settings": {
"type": "array",
"items": {
"properties": {
"third_party_settings": {
"title": "third_party_settings"
}
}
}
},
"field_name": {
"type": "string",
"title": "field_name"
},
"entity_type": {
"type": "string",
"title": "entity_type"
},
"field_storage_config_type": {
"type": "string",
"title": "field_storage_config_type"
},
"settings": {
"title": "settings"
},
"module": {
"type": "string",
"title": "module"
},
"locked": {
"type": "boolean",
"title": "locked"
},
"cardinality": {
"type": "integer",
"title": "cardinality"
},
"translatable": {
"type": "boolean",
"title": "translatable"
},
"indexes": {
"type": "array",
"items": {
"properties": {
"indexes": {
"title": "indexes"
}
}
}
},
"persist_with_no_fields": {
"type": "boolean",
"title": "persist_with_no_fields"
},
"custom_storage": {
"type": "boolean",
"title": "custom_storage"
}
},
"description": "Entity attributes",
"type": "object",
"additionalProperties": false
}
}
}
→ note how
"dependencies": {
"title": "dependencies"
},
does not specify any type — it should be a type: object, with the potential keys being module, theme, config and content.
Same for other "fields" (top-level properties) like settings — although that one is field-type-specific, which I'm not sure how we can express in JSON Schema.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | config_entity_mappings_sequences-3324824-2.patch | 2.09 KB | wim leers |
| #2 | jsonapi_schema_multipart_id_config_entity_types-3324769-2.patch | 1.94 KB | wim leers |
Comments
Comment #2
wim leersIgnore: wrong patch.
Comment #3
wim leers→ better, but not quite there yet: now the top-level
dependenciesis gone 😬 Stay tuned…Comment #4
wim leersI've narrowed the problem down to
ComplexDataDefinitionNormalizer's use ofNestedArray::mergeDeep()+\Drupal\jsonapi_schema\Normalizer\DataDefinitionNormalizer::normalizeProperties()'s use ofNestedArray::mergeDeep().Comment #5
wim leers#4 actually reminds me of #3058850: Config entities carry invalid object definitions — I bet they are related 🤓
Comment #6
m.stentaWe have automated tests now (#3257911: Add basic test coverage) so it would be good to include a test to demonstrate this issue and prevent regressions.