Problem/Motivation
#3620920 lets data definitions declare a default value through getDefault() and setDefault(). The value is descriptive metadata. The json_schema serialization format does not read it, so generated schemas omit the standard default keyword.
Steps to reproduce
N/A
Proposed resolution
Add an annotation helper to SchematicNormalizerHelperTrait. Call it from PrimitiveDataNormalizer and TypedDataNormalizer. These normalizers output the value in the format setValue() accepts, so the annotation matches the declared schema type. Normalizers which transform the value, such as the timestamp and datetime normalizers, do not annotate.
- Values which cannot be represented in JSON are skipped, at any array depth.
\Stringabledefaults are cast to strings.- JSON:API's
FieldNormalizerremoves an item-leveldefaultfrom the array schema of a multi-value field.
Remaining tasks
Review. Postponed on #3620920.
User interface changes
None
API changes
Two new protected methods on SchematicNormalizerHelperTrait. No changes to existing methods.
Data model changes
None
Generated with the help of an LLM.
Issue fork drupal-3623431
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
michaellander commentedPostponed until #3620920: Allow data definitions to declare a default value
Comment #5
michaellander commented