JsonSchemaProviderSerializerTrait.php

Namespace

Drupal\serialization\Serializer

File

core/modules/serialization/src/Serializer/JsonSchemaProviderSerializerTrait.php

View source
<?php

declare (strict_types=1);
namespace Drupal\serialization\Serializer;

use Drupal\serialization\Normalizer\SchematicNormalizerFallbackTrait;
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
trait JsonSchemaProviderSerializerTrait {
    use SchematicNormalizerFallbackTrait;
    
    /**
     * {@inheritdoc}
     */
    public function getJsonSchema(mixed $object, array $context) : array {
        try {
            $normalizer_schema = $this->normalize($object, 'json_schema', $context);
        } catch (NotNormalizableValueException) {
            $normalizer_schema = [
                '$comment' => static::generateNoSchemaAvailableMessage($object),
            ];
        }
        return $normalizer_schema;
    }

}

Traits

Title Deprecated Summary
JsonSchemaProviderSerializerTrait

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