Problem/Motivation
#3620922 lets data definitions declare example values through getExamples() and setExamples(). The values are descriptive metadata. The json_schema serialization format does not read them, so generated schemas omit the standard examples keyword.
Steps to reproduce
N/A
Proposed resolution
Extend the annotation helper added in #3623431. PrimitiveDataNormalizer and TypedDataNormalizer emit the examples keyword. These normalizers output the value in the format setValue() accepts, so the annotation matches the declared schema type.
- Examples which cannot be represented in JSON are dropped individually. The keyword is emitted when at least one example remains.
\Stringableexamples are cast to strings. A NULL example is kept.- JSON:API's
FieldNormalizerremoves item-levelexamplesfrom the array schema of a multi-value field.
Remaining tasks
Review. Postponed on #3620922 and #3623431.
User interface changes
None
API changes
SchematicNormalizerHelperTrait's protected casting method is renamed to serve both keywords. No other changes to existing methods.
Data model changes
None
Generated with the help of an LLM.
Issue fork drupal-3623432
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 #2
michaellander commentedPostponed on #3620922: Allow data definitions to declare example values and #3623431: Emit data definition default values as the JSON Schema "default" keyword.
Comment #3
michaellander commentedComment #5
michaellander commentedComment #6
mglaman