function SchematicNormalizerTrait::getNormalizationSchema

Same name and namespace in other branches
  1. 11.x core/modules/serialization/src/Normalizer/SchematicNormalizerTrait.php \Drupal\serialization\Normalizer\SchematicNormalizerTrait::getNormalizationSchema()

Retrieve JSON Schema for the normalization.

Parameters

mixed $object: Supported object or class/interface name being normalized.

array $context: Context options. Well-defined keys include:

  • dialect: Used to specify a dialect for the desired schema being generated. The dialect meta-schema MUST extend JSON Schema draft 2020-12 or later. Normalizers MAY choose to return a schema with keywords supported by a dialect it supports, but only when they are supported by the dialect specified in this key. For instance, normalizers may return a schema with a 'discriminator' as supported by OpenAPI if that dialect is passed, but return a more permissive but less specific schema when it is not.

Return value

array JSON Schema for the normalization, conforming to version draft 2020-12.

Overrides SchematicNormalizerHelperTrait::getNormalizationSchema

1 call to SchematicNormalizerTrait::getNormalizationSchema()
SchematicNormalizerTrait::normalize in core/modules/serialization/src/Normalizer/SchematicNormalizerTrait.php
9 methods override SchematicNormalizerTrait::getNormalizationSchema()
FieldItemNormalizer::getNormalizationSchema in core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php
Retrieve JSON Schema for the normalization.
FieldNormalizer::getNormalizationSchema in core/modules/jsonapi/src/Normalizer/FieldNormalizer.php
Retrieve JSON Schema for the normalization.
JsonApiDocumentTopLevelNormalizer::getNormalizationSchema in core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
Retrieve JSON Schema for the normalization.
MarkupNormalizer::getNormalizationSchema in core/modules/serialization/src/Normalizer/MarkupNormalizer.php
Retrieve JSON Schema for the normalization.
NullNormalizer::getNormalizationSchema in core/modules/serialization/src/Normalizer/NullNormalizer.php
Retrieve JSON Schema for the normalization.

... See full list

File

core/modules/serialization/src/Normalizer/SchematicNormalizerTrait.php, line 53

Class

SchematicNormalizerTrait
Trait for normalizers which can also provide JSON Schema.

Namespace

Drupal\serialization\Normalizer

Code

protected function getNormalizationSchema(mixed $object, array $context = []) : array {
  return $this->getJsonSchemaForMethod($this, 'doNormalize', [
    '$comment' => static::generateNoSchemaAvailableMessage($object),
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.