Issue #3032451 was merged and released in 8.x-3.4. It introduces a new normaliser ResourceObjectNormalizer to apply field enhancers to config entities. However, after applying the enhancers to fields of $normalization['attributes'], it adds the fields to $normalization instead of replacing the fields in $normalization['attributes'].
protected static function enhanceConfigFields(array $normalization, ConfigurableResourceType $resource_type) {
if (!empty($normalization['attributes'])) {
foreach ($normalization['attributes'] as $field_name => $field_value) {
$enhancer = $resource_type->getFieldEnhancer($field_name);
if (!$enhancer) {
continue;
}
$normalization[$field_name] = $enhancer->undoTransform($field_value);
}
}
return $normalization;
}

It results in changes in JSONAPI response for config entities. For example, below is JSONAPI response for webform in 8.x-3.3 with a YAML field enhancer to the attributes.elements:
"attributes": {
"langcode": "en",
"status": "open",
"dependencies": [],
"open": null,
"close": null,
"weight": 0,
"uid": 200,
"template": false,
"archive": false,
"entity_id": "pso",
"title": "PSO",
"description": "Checkbox form for PSO",
"category": "form-redirect",
"elements": {
"pso_recruitment_process": {
"#type": "checkbox",
"#title": "I UNDERSTAND THE RECRUITMENT PROCESS",
"#required": true
}
}
"css": "",
"javascript": "",
"settings": { ... }
},
On 8.x-3.4:
"attributes": {
"langcode": "en",
"status": "open",
"dependencies": [],
"open": null,
"close": null,
"weight": 0,
"uid": 200,
"template": false,
"archive": false,
"entity_id": "pso",
"title": "PSO",
"description": "Checkbox form for PSO",
"category": "form-redirect",
"elements": "pso_recruitment_process:\n \u0027#type\u0027: checkbox\n \u0027#title\u0027: \u0027I UNDERSTAND THE RECRUITMENT PROCESS\u0027\n \u0027#required\u0027: true",
"css": "",
"javascript": "",
"settings": { ... }
},
"elements": {
"pso_recruitment_process": {
"#type": "checkbox",
"#title": "I UNDERSTAND THE RECRUITMENT PROCESS",
"#required": true
}
}
Is this change on purpose or a mistake?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | jsonapi_extras-config_entities_enhancer-3037833-4.patch | 590 bytes | sonnykt |
Comments
Comment #2
sonnyktComment #3
sonnyktComment #4
sonnyktIf it's a bug, here is the patch.
Comment #5
e0ipsoThis looks good!
Comment #7
e0ipsoThanks for the fix!
Comment #8
e0ipsoRetitling to add test coverage. It's worrisome that no tests went red with this bug.
Comment #9
wim leers