• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 16531587208

25 Jul 2025 09:05PM UTC coverage: 0.0% (-22.1%) from 22.07%
16531587208

Pull #7225

github

web-flow
Merge 23f449a58 into 02a764950
Pull Request #7225: feat: json streamer

0 of 294 new or added lines in 31 files covered. (0.0%)

11514 existing lines in 375 files now uncovered.

0 of 51976 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/JsonSchema/SchemaFactory.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\JsonSchema;
15

16
use ApiPlatform\JsonSchema\Metadata\Property\Factory\SchemaPropertyMetadataFactory;
17
use ApiPlatform\Metadata\ApiProperty;
18
use ApiPlatform\Metadata\CollectionOperationInterface;
19
use ApiPlatform\Metadata\HttpOperation;
20
use ApiPlatform\Metadata\Operation;
21
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
22
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
23
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
24
use ApiPlatform\Metadata\ResourceClassResolverInterface;
25
use ApiPlatform\Metadata\Util\TypeHelper;
26
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
27
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
28
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
29
use Symfony\Component\TypeInfo\Type\BuiltinType;
30
use Symfony\Component\TypeInfo\Type\CollectionType;
31
use Symfony\Component\TypeInfo\Type\CompositeTypeInterface;
32
use Symfony\Component\TypeInfo\Type\ObjectType;
33
use Symfony\Component\TypeInfo\TypeIdentifier;
34

35
/**
36
 * {@inheritdoc}
37
 *
38
 * @author Kévin Dunglas <dunglas@gmail.com>
39
 */
40
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
41
{
42
    use ResourceMetadataTrait;
43
    use SchemaUriPrefixTrait;
44

45
    private ?SchemaFactoryInterface $schemaFactory = null;
46
    // Edge case where the related resource is not readable (for example: NotExposed) but we have groups to read the whole related object
47
    public const OPENAPI_DEFINITION_NAME = 'openapi_definition_name';
48

49
    public function __construct(ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, private readonly PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory, private readonly ?NameConverterInterface $nameConverter = null, ?ResourceClassResolverInterface $resourceClassResolver = null, ?array $distinctFormats = null, private ?DefinitionNameFactoryInterface $definitionNameFactory = null)
50
    {
UNCOV
51
        if (!$definitionNameFactory) {
×
52
            $this->definitionNameFactory = new DefinitionNameFactory($distinctFormats);
×
53
        }
54

UNCOV
55
        $this->resourceMetadataFactory = $resourceMetadataFactory;
×
UNCOV
56
        $this->resourceClassResolver = $resourceClassResolver;
×
57
    }
58

59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function buildSchema(string $className, string $format = 'json', string $type = Schema::TYPE_OUTPUT, ?Operation $operation = null, ?Schema $schema = null, ?array $serializerContext = null, bool $forceCollection = false): Schema
63
    {
UNCOV
64
        $schema = $schema ? clone $schema : new Schema();
×
65

UNCOV
66
        if (!$this->isResourceClass($className)) {
×
UNCOV
67
            $operation = null;
×
UNCOV
68
            $inputOrOutputClass = $className;
×
UNCOV
69
            $serializerContext ??= [];
×
70
        } else {
UNCOV
71
            $operation = $this->findOperation($className, $type, $operation, $serializerContext, $format);
×
UNCOV
72
            $inputOrOutputClass = $this->findOutputClass($className, $type, $operation, $serializerContext);
×
UNCOV
73
            $serializerContext ??= $this->getSerializerContext($operation, $type);
×
74
        }
75

UNCOV
76
        if (null === $inputOrOutputClass) {
×
77
            // input or output disabled
78
            return $schema;
×
79
        }
80

UNCOV
81
        $validationGroups = $operation ? $this->getValidationGroups($operation) : [];
×
UNCOV
82
        $version = $schema->getVersion();
×
UNCOV
83
        $definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext);
×
UNCOV
84
        $method = $operation instanceof HttpOperation ? $operation->getMethod() : 'GET';
×
UNCOV
85
        if (!$operation) {
×
UNCOV
86
            $method = Schema::TYPE_INPUT === $type ? 'POST' : 'GET';
×
87
        }
88

89
        // In case of FORCE_SUBSCHEMA an object can be writable through another class even though it has no POST operation
UNCOV
90
        if (!($serializerContext[self::FORCE_SUBSCHEMA] ?? false) && Schema::TYPE_OUTPUT !== $type && !\in_array($method, ['POST', 'PATCH', 'PUT'], true)) {
×
91
            return $schema;
×
92
        }
93

UNCOV
94
        if (!isset($schema['$ref']) && !isset($schema['type'])) {
×
UNCOV
95
            $ref = $this->getSchemaUriPrefix($version).$definitionName;
×
UNCOV
96
            if ($forceCollection || ('POST' !== $method && $operation instanceof CollectionOperationInterface)) {
×
UNCOV
97
                $schema['type'] = 'array';
×
UNCOV
98
                $schema['items'] = ['$ref' => $ref];
×
99
            } else {
UNCOV
100
                $schema['$ref'] = $ref;
×
101
            }
102
        }
103

UNCOV
104
        $definitions = $schema->getDefinitions();
×
UNCOV
105
        if (isset($definitions[$definitionName])) {
×
106
            // Already computed
UNCOV
107
            return $schema;
×
108
        }
109

110
        /** @var \ArrayObject<string, mixed> $definition */
UNCOV
111
        $definition = new \ArrayObject(['type' => 'object']);
×
UNCOV
112
        $definitions[$definitionName] = $definition;
×
UNCOV
113
        if ($description = $operation?->getDescription()) {
×
UNCOV
114
            $definition['description'] = $description;
×
115
        }
116

117
        // additionalProperties are allowed by default, so it does not need to be set explicitly, unless allow_extra_attributes is false
118
        // See https://json-schema.org/understanding-json-schema/reference/object.html#properties
UNCOV
119
        if (false === ($serializerContext[AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES] ?? true)) {
×
120
            $definition['additionalProperties'] = false;
×
121
        }
122

123
        // see https://github.com/json-schema-org/json-schema-spec/pull/737
UNCOV
124
        if (Schema::VERSION_SWAGGER !== $version && $operation && $operation->getDeprecationReason()) {
×
125
            $definition['deprecated'] = true;
×
126
        }
127

128
        // externalDocs is an OpenAPI specific extension, but JSON Schema allows additional keys, so we always add it
129
        // See https://json-schema.org/latest/json-schema-core.html#rfc.section.6.4
UNCOV
130
        if ($operation instanceof HttpOperation && ($operation->getTypes()[0] ?? null)) {
×
UNCOV
131
            $definition['externalDocs'] = ['url' => $operation->getTypes()[0]];
×
132
        }
133

UNCOV
134
        $options = ['schema_type' => $type] + $this->getFactoryOptions($serializerContext, $validationGroups, $operation instanceof HttpOperation ? $operation : null);
×
UNCOV
135
        foreach ($this->propertyNameCollectionFactory->create($inputOrOutputClass, $options) as $propertyName) {
×
UNCOV
136
            $propertyMetadata = $this->propertyMetadataFactory->create($inputOrOutputClass, $propertyName, $options);
×
137

UNCOV
138
            if (false === $propertyMetadata->isReadable() && false === $propertyMetadata->isWritable()) {
×
UNCOV
139
                continue;
×
140
            }
141

UNCOV
142
            $normalizedPropertyName = $this->nameConverter ? $this->nameConverter->normalize($propertyName, $inputOrOutputClass, $format, $serializerContext) : $propertyName;
×
UNCOV
143
            if ($propertyMetadata->isRequired()) {
×
UNCOV
144
                $definition['required'][] = $normalizedPropertyName;
×
145
            }
146

UNCOV
147
            if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
×
148
                $this->buildLegacyPropertySchema($schema, $definitionName, $normalizedPropertyName, $propertyMetadata, $serializerContext, $format, $type);
×
149
            } else {
UNCOV
150
                $this->buildPropertySchema($schema, $definitionName, $normalizedPropertyName, $propertyMetadata, $serializerContext, $format, $type);
×
151
            }
152
        }
153

UNCOV
154
        return $schema;
×
155
    }
156

157
    /**
158
     * Builds the JSON Schema for a property using the legacy PropertyInfo component.
159
     */
160
    private function buildLegacyPropertySchema(Schema $schema, string $definitionName, string $normalizedPropertyName, ApiProperty $propertyMetadata, array $serializerContext, string $format, string $parentType): void
161
    {
162
        $version = $schema->getVersion();
×
163
        if (Schema::VERSION_SWAGGER === $version || Schema::VERSION_OPENAPI === $version) {
×
164
            $additionalPropertySchema = $propertyMetadata->getOpenapiContext();
×
165
        } else {
166
            $additionalPropertySchema = $propertyMetadata->getJsonSchemaContext();
×
167
        }
168

169
        $propertySchema = array_merge(
×
170
            $propertyMetadata->getSchema() ?? [],
×
171
            $additionalPropertySchema ?? []
×
172
        );
×
173

174
        // @see https://github.com/api-platform/core/issues/6299
175
        if (Schema::UNKNOWN_TYPE === ($propertySchema['type'] ?? null) && isset($propertySchema['$ref'])) {
×
176
            unset($propertySchema['type']);
×
177
        }
178

179
        $extraProperties = $propertyMetadata->getExtraProperties();
×
180
        // see AttributePropertyMetadataFactory
181
        if (true === ($extraProperties[SchemaPropertyMetadataFactory::JSON_SCHEMA_USER_DEFINED] ?? false)) {
×
182
            // schema seems to have been declared by the user: do not override nor complete user value
183
            $schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);
×
184

185
            return;
×
186
        }
187

188
        $types = $propertyMetadata->getBuiltinTypes() ?? [];
×
189

190
        // never override the following keys if at least one is already set
191
        // or if property has no type(s) defined
192
        // or if property schema is already fully defined (type=string + format || enum)
193
        $propertySchemaType = $propertySchema['type'] ?? false;
×
194

195
        $isUnknown = Schema::UNKNOWN_TYPE === $propertySchemaType
×
196
            || ('array' === $propertySchemaType && Schema::UNKNOWN_TYPE === ($propertySchema['items']['type'] ?? null))
×
197
            || ('object' === $propertySchemaType && Schema::UNKNOWN_TYPE === ($propertySchema['additionalProperties']['type'] ?? null));
×
198

199
        // Scalar properties
200
        if (
201
            !$isUnknown && (
×
202
                [] === $types
×
203
                || ($propertySchema['$ref'] ?? $propertySchema['anyOf'] ?? $propertySchema['allOf'] ?? $propertySchema['oneOf'] ?? false)
×
204
                || (\is_array($propertySchemaType) ? \array_key_exists('string', $propertySchemaType) : 'string' !== $propertySchemaType)
×
205
                || ($propertySchema['format'] ?? $propertySchema['enum'] ?? false)
×
206
            )
207
        ) {
208
            if (isset($propertySchema['$ref'])) {
×
209
                unset($propertySchema['type']);
×
210
            }
211

212
            $schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);
×
213

214
            return;
×
215
        }
216

217
        // property schema is created in SchemaPropertyMetadataFactory, but it cannot build resource reference ($ref)
218
        // complete property schema with resource reference ($ref) only if it's related to an object
219
        $version = $schema->getVersion();
×
220
        $refs = [];
×
221
        $isNullable = null;
×
222

223
        foreach ($types as $type) {
×
224
            $subSchema = new Schema($version);
×
225
            $subSchema->setDefinitions($schema->getDefinitions()); // Populate definitions of the main schema
×
226

227
            $isCollection = $type->isCollection();
×
228
            if ($isCollection) {
×
229
                $valueType = $type->getCollectionValueTypes()[0] ?? null;
×
230
            } else {
231
                $valueType = $type;
×
232
            }
233

234
            $className = $valueType?->getClassName();
×
235
            if (null === $className) {
×
236
                continue;
×
237
            }
238

239
            $subSchemaFactory = $this->schemaFactory ?: $this;
×
240
            $subSchema = $subSchemaFactory->buildSchema($className, $format, $parentType, null, $subSchema, $serializerContext + [self::FORCE_SUBSCHEMA => true], false);
×
241
            if (!isset($subSchema['$ref'])) {
×
242
                continue;
×
243
            }
244

245
            if (false === $propertyMetadata->getGenId()) {
×
246
                $subDefinitionName = $this->definitionNameFactory->create($className, $format, $className, null, $serializerContext);
×
247

248
                if (isset($subSchema->getDefinitions()[$subDefinitionName])) {
×
249
                    // @see https://github.com/api-platform/core/issues/7162
250
                    // Need to rebuild the definition without @id property and set it back to the sub-schema
251
                    $subSchemaDefinition = $subSchema->getDefinitions()[$subDefinitionName]->getArrayCopy();
×
252
                    unset($subSchemaDefinition['properties']['@id']);
×
253
                    $subSchema->getDefinitions()[$subDefinitionName] = new \ArrayObject($subSchemaDefinition);
×
254
                }
255
            }
256

257
            if ($isCollection) {
×
258
                $key = ($propertySchema['type'] ?? null) === 'object' ? 'additionalProperties' : 'items';
×
259
                $propertySchema[$key]['$ref'] = $subSchema['$ref'];
×
260
                unset($propertySchema[$key]['type']);
×
261
                break;
×
262
            }
263

264
            $refs[] = ['$ref' => $subSchema['$ref']];
×
265
            $isNullable = $isNullable ?? $type->isNullable();
×
266
        }
267

268
        if ($isNullable) {
×
269
            $refs[] = ['type' => 'null'];
×
270
        }
271

272
        $c = \count($refs);
×
273
        if ($c > 1) {
×
274
            $propertySchema['anyOf'] = $refs;
×
275
            unset($propertySchema['type']);
×
276
        } elseif (1 === $c) {
×
277
            $propertySchema['$ref'] = $refs[0]['$ref'];
×
278
            unset($propertySchema['type']);
×
279
        }
280

281
        $schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);
×
282
    }
283

284
    private function buildPropertySchema(Schema $schema, string $definitionName, string $normalizedPropertyName, ApiProperty $propertyMetadata, array $serializerContext, string $format, string $parentType): void
285
    {
UNCOV
286
        $version = $schema->getVersion();
×
UNCOV
287
        if (Schema::VERSION_SWAGGER === $version || Schema::VERSION_OPENAPI === $version) {
×
UNCOV
288
            $additionalPropertySchema = $propertyMetadata->getOpenapiContext();
×
289
        } else {
UNCOV
290
            $additionalPropertySchema = $propertyMetadata->getJsonSchemaContext();
×
291
        }
292

UNCOV
293
        $propertySchema = array_merge(
×
UNCOV
294
            $propertyMetadata->getSchema() ?? [],
×
UNCOV
295
            $additionalPropertySchema ?? []
×
UNCOV
296
        );
×
297

UNCOV
298
        $extraProperties = $propertyMetadata->getExtraProperties();
×
299
        // see AttributePropertyMetadataFactory
UNCOV
300
        if (true === ($extraProperties[SchemaPropertyMetadataFactory::JSON_SCHEMA_USER_DEFINED] ?? false)) {
×
301
            // schema seems to have been declared by the user: do not override nor complete user value
UNCOV
302
            $schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);
×
303

UNCOV
304
            return;
×
305
        }
306

UNCOV
307
        $type = $propertyMetadata->getNativeType();
×
308

309
        // Type is defined in an allOf, anyOf, or oneOf
UNCOV
310
        $propertySchemaType = $this->getSchemaValue($propertySchema, 'type');
×
UNCOV
311
        $currentRef = $this->getSchemaValue($propertySchema, '$ref');
×
UNCOV
312
        $isSchemaDefined = null !== ($currentRef ?? $this->getSchemaValue($propertySchema, 'format') ?? $this->getSchemaValue($propertySchema, 'enum'));
×
UNCOV
313
        if (!$isSchemaDefined && Schema::UNKNOWN_TYPE !== $propertySchemaType) {
×
UNCOV
314
            $isSchemaDefined = true;
×
315
        }
316

317
        // Check if the type is considered "unknown" by SchemaPropertyMetadataFactory
UNCOV
318
        if (isset($propertySchema['additionalProperties']['type']) && Schema::UNKNOWN_TYPE === $propertySchema['additionalProperties']['type']) {
×
UNCOV
319
            $isSchemaDefined = false;
×
320
        }
321

UNCOV
322
        if ($isSchemaDefined && Schema::UNKNOWN_TYPE !== $propertySchemaType) {
×
323
            // If schema is defined and not marked as unknown, or if no type info exists, return early
UNCOV
324
            $schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);
×
325

UNCOV
326
            return;
×
327
        }
328

UNCOV
329
        if (Schema::UNKNOWN_TYPE === $propertySchemaType) {
×
UNCOV
330
            $propertySchema = [];
×
331
        }
332

333
        // property schema is created in SchemaPropertyMetadataFactory, but it cannot build resource reference ($ref)
334
        // complete property schema with resource reference ($ref) if it's related to an object/resource
UNCOV
335
        $refs = [];
×
UNCOV
336
        $isNullable = $type?->isNullable() ?? false;
×
337

338
        // TODO: refactor this with TypeInfo we shouldn't have to loop like this, the below code handles object refs
UNCOV
339
        if ($type) {
×
UNCOV
340
            foreach ($type instanceof CompositeTypeInterface ? $type->getTypes() : [$type] as $t) {
×
UNCOV
341
                if ($t instanceof BuiltinType && TypeIdentifier::NULL === $t->getTypeIdentifier()) {
×
UNCOV
342
                    continue;
×
343
                }
344

UNCOV
345
                $valueType = $t;
×
UNCOV
346
                $isCollection = $t instanceof CollectionType;
×
347

UNCOV
348
                if ($isCollection) {
×
UNCOV
349
                    $valueType = TypeHelper::getCollectionValueType($t);
×
350
                }
351

UNCOV
352
                if (!$valueType instanceof ObjectType) {
×
353
                    continue;
×
354
                }
355

UNCOV
356
                $className = $valueType->getClassName();
×
UNCOV
357
                $subSchemaInstance = new Schema($version);
×
UNCOV
358
                $subSchemaInstance->setDefinitions($schema->getDefinitions());
×
UNCOV
359
                $subSchemaFactory = $this->schemaFactory ?: $this;
×
UNCOV
360
                $subSchemaResult = $subSchemaFactory->buildSchema($className, $format, $parentType, null, $subSchemaInstance, $serializerContext + [self::FORCE_SUBSCHEMA => true], false);
×
UNCOV
361
                if (!isset($subSchemaResult['$ref'])) {
×
362
                    continue;
×
363
                }
364

UNCOV
365
                if (false === $propertyMetadata->getGenId()) {
×
UNCOV
366
                    $subDefinitionName = $this->definitionNameFactory->create($className, $format, $className, null, $serializerContext);
×
UNCOV
367
                    if (isset($subSchemaResult->getDefinitions()[$subDefinitionName]['properties']['@id'])) {
×
368
                        unset($subSchemaResult->getDefinitions()[$subDefinitionName]['properties']['@id']);
×
369
                    }
370
                }
371

UNCOV
372
                if ($isCollection) {
×
UNCOV
373
                    $key = ($propertySchema['type'] ?? null) === 'object' ? 'additionalProperties' : 'items';
×
UNCOV
374
                    if (!isset($propertySchema['type'])) {
×
UNCOV
375
                        $propertySchema['type'] = 'array';
×
376
                    }
377

UNCOV
378
                    if (!isset($propertySchema[$key]) || !\is_array($propertySchema[$key])) {
×
UNCOV
379
                        $propertySchema[$key] = [];
×
380
                    }
UNCOV
381
                    $propertySchema[$key] = ['$ref' => $subSchemaResult['$ref']];
×
UNCOV
382
                    $refs = [];
×
UNCOV
383
                    break;
×
384
                }
385

UNCOV
386
                $refs[] = ['$ref' => $subSchemaResult['$ref']];
×
387
            }
388
        }
389

UNCOV
390
        if (!empty($refs)) {
×
UNCOV
391
            if ($isNullable) {
×
UNCOV
392
                $refs[] = ['type' => 'null'];
×
393
            }
394

UNCOV
395
            if (($c = \count($refs)) > 1) {
×
UNCOV
396
                $propertySchema = ['anyOf' => $refs];
×
UNCOV
397
            } elseif (1 === $c) {
×
UNCOV
398
                $propertySchema = ['$ref' => $refs[0]['$ref']];
×
399
            }
400
        }
401

UNCOV
402
        if (null !== $propertyMetadata->getUriTemplate() || (!\array_key_exists('readOnly', $propertySchema) && false === $propertyMetadata->isWritable() && !$propertyMetadata->isInitializable()) && !isset($propertySchema['$ref'])) {
×
UNCOV
403
            $propertySchema['readOnly'] = true;
×
404
        }
405

UNCOV
406
        $schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);
×
407
    }
408

409
    private function getValidationGroups(Operation $operation): array
410
    {
UNCOV
411
        $groups = $operation->getValidationContext()['groups'] ?? [];
×
412

UNCOV
413
        return \is_array($groups) ? $groups : [$groups];
×
414
    }
415

416
    /**
417
     * Gets the options for the property name collection / property metadata factories.
418
     */
419
    private function getFactoryOptions(array $serializerContext, array $validationGroups, ?HttpOperation $operation = null): array
420
    {
UNCOV
421
        $options = [
×
422
            /* @see https://github.com/symfony/symfony/blob/v5.1.0/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php */
UNCOV
423
            'enable_getter_setter_extraction' => true,
×
UNCOV
424
        ];
×
425

UNCOV
426
        if (isset($serializerContext[AbstractNormalizer::GROUPS])) {
×
427
            /* @see https://github.com/symfony/symfony/blob/v4.2.6/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php */
UNCOV
428
            $options['serializer_groups'] = (array) $serializerContext[AbstractNormalizer::GROUPS];
×
429
        }
430

UNCOV
431
        if ($operation && ($normalizationGroups = $operation->getNormalizationContext()['groups'] ?? null)) {
×
UNCOV
432
            $options['normalization_groups'] = $normalizationGroups;
×
433
        }
434

UNCOV
435
        if ($operation && ($denormalizationGroups = $operation->getDenormalizationContext()['groups'] ?? null)) {
×
UNCOV
436
            $options['denormalization_groups'] = $denormalizationGroups;
×
437
        }
438

UNCOV
439
        if ($validationGroups) {
×
440
            $options['validation_groups'] = $validationGroups;
×
441
        }
442

UNCOV
443
        if ($operation && ($ignoredAttributes = $operation->getNormalizationContext()['ignored_attributes'] ?? null)) {
×
UNCOV
444
            $options['ignored_attributes'] = $ignoredAttributes;
×
445
        }
446

UNCOV
447
        return $options;
×
448
    }
449

450
    public function setSchemaFactory(SchemaFactoryInterface $schemaFactory): void
451
    {
UNCOV
452
        $this->schemaFactory = $schemaFactory;
×
453
    }
454

455
    private function getSchemaValue(array $schema, string $key): array|string|null
456
    {
UNCOV
457
        if (isset($schema['items'])) {
×
UNCOV
458
            $schema = $schema['items'];
×
459
        }
460

UNCOV
461
        return $schema[$key] ?? $schema['allOf'][0][$key] ?? $schema['anyOf'][0][$key] ?? $schema['oneOf'][0][$key] ?? null;
×
462
    }
463
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc