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

api-platform / core / 14008635868

22 Mar 2025 12:39PM UTC coverage: 8.52% (+0.005%) from 8.515%
14008635868

Pull #7042

github

web-flow
Merge fdd88ef56 into 47a6dffbb
Pull Request #7042: Purge parent collections in inheritance cases

4 of 9 new or added lines in 1 file covered. (44.44%)

540 existing lines in 57 files now uncovered.

13394 of 157210 relevant lines covered (8.52%)

22.93 hits per line

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

80.67
/src/OpenApi/Factory/OpenApiFactory.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\OpenApi\Factory;
15

16
use ApiPlatform\Doctrine\Odm\State\Options as DoctrineODMOptions;
17
use ApiPlatform\Doctrine\Orm\State\Options as DoctrineOptions;
18
use ApiPlatform\JsonSchema\Schema;
19
use ApiPlatform\JsonSchema\SchemaFactoryInterface;
20
use ApiPlatform\Metadata\ApiResource;
21
use ApiPlatform\Metadata\CollectionOperationInterface;
22
use ApiPlatform\Metadata\Error;
23
use ApiPlatform\Metadata\ErrorResource;
24
use ApiPlatform\Metadata\Exception\OperationNotFoundException;
25
use ApiPlatform\Metadata\Exception\ProblemExceptionInterface;
26
use ApiPlatform\Metadata\Exception\ResourceClassNotFoundException;
27
use ApiPlatform\Metadata\Exception\RuntimeException;
28
use ApiPlatform\Metadata\HeaderParameterInterface;
29
use ApiPlatform\Metadata\HttpOperation;
30
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
31
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
32
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
33
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
34
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
35
use ApiPlatform\OpenApi\Attributes\Webhook;
36
use ApiPlatform\OpenApi\Model\Components;
37
use ApiPlatform\OpenApi\Model\Contact;
38
use ApiPlatform\OpenApi\Model\Info;
39
use ApiPlatform\OpenApi\Model\License;
40
use ApiPlatform\OpenApi\Model\Link;
41
use ApiPlatform\OpenApi\Model\MediaType;
42
use ApiPlatform\OpenApi\Model\OAuthFlow;
43
use ApiPlatform\OpenApi\Model\OAuthFlows;
44
use ApiPlatform\OpenApi\Model\Operation;
45
use ApiPlatform\OpenApi\Model\Parameter;
46
use ApiPlatform\OpenApi\Model\PathItem;
47
use ApiPlatform\OpenApi\Model\Paths;
48
use ApiPlatform\OpenApi\Model\RequestBody;
49
use ApiPlatform\OpenApi\Model\Response;
50
use ApiPlatform\OpenApi\Model\SecurityScheme;
51
use ApiPlatform\OpenApi\Model\Server;
52
use ApiPlatform\OpenApi\Model\Tag;
53
use ApiPlatform\OpenApi\OpenApi;
54
use ApiPlatform\OpenApi\Options;
55
use ApiPlatform\OpenApi\Serializer\NormalizeOperationNameTrait;
56
use ApiPlatform\State\ApiResource\Error as ApiResourceError;
57
use ApiPlatform\State\Pagination\PaginationOptions;
58
use ApiPlatform\Validator\Exception\ValidationException;
59
use Psr\Container\ContainerInterface;
60
use Symfony\Component\PropertyInfo\Type;
61
use Symfony\Component\Routing\RouteCollection;
62
use Symfony\Component\Routing\RouterInterface;
63

64
/**
65
 * Generates an Open API v3 specification.
66
 */
67
final class OpenApiFactory implements OpenApiFactoryInterface
68
{
69
    use NormalizeOperationNameTrait;
70
    use TypeFactoryTrait;
71

72
    public const BASE_URL = 'base_url';
73
    public const API_PLATFORM_TAG = 'x-apiplatform-tag';
74
    public const OVERRIDE_OPENAPI_RESPONSES = 'open_api_override_responses';
75
    private readonly Options $openApiOptions;
76
    private readonly PaginationOptions $paginationOptions;
77
    private ?RouteCollection $routeCollection = null;
78
    private ?ContainerInterface $filterLocator = null;
79
    /**
80
     * @var array<string|class-string, ErrorResource>
81
     */
82
    private array $localErrorResourceCache = [];
83

84
    /**
85
     * @param array<string, string[]> $formats
86
     */
87
    public function __construct(
88
        private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
89
        private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory,
90
        private readonly PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory,
91
        private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory,
92
        private readonly SchemaFactoryInterface $jsonSchemaFactory,
93
        ?ContainerInterface $filterLocator = null,
94
        private readonly array $formats = [],
95
        ?Options $openApiOptions = null,
96
        ?PaginationOptions $paginationOptions = null,
97
        private readonly ?RouterInterface $router = null,
98
        private readonly array $errorFormats = [],
99
    ) {
100
        $this->filterLocator = $filterLocator;
1,721✔
101
        $this->openApiOptions = $openApiOptions ?: new Options('API Platform');
1,721✔
102
        $this->paginationOptions = $paginationOptions ?: new PaginationOptions();
1,721✔
103
    }
104

105
    /**
106
     * {@inheritdoc}
107
     *
108
     * You can filter openapi operations with the `x-apiplatform-tag` on an OpenApi Operation using the `filter_tags`.
109
     *
110
     * @param array{base_url?: string, filter_tags?: string[]}&array<string, mixed> $context
111
     */
112
    public function __invoke(array $context = []): OpenApi
113
    {
114
        $baseUrl = $context[self::BASE_URL] ?? '/';
47✔
115
        $contact = null === $this->openApiOptions->getContactUrl() || null === $this->openApiOptions->getContactEmail() ? null : new Contact($this->openApiOptions->getContactName(), $this->openApiOptions->getContactUrl(), $this->openApiOptions->getContactEmail());
47✔
116
        $license = null === $this->openApiOptions->getLicenseName() ? null : new License($this->openApiOptions->getLicenseName(), $this->openApiOptions->getLicenseUrl());
47✔
117
        $info = new Info($this->openApiOptions->getTitle(), $this->openApiOptions->getVersion(), trim($this->openApiOptions->getDescription()), $this->openApiOptions->getTermsOfService(), $contact, $license);
47✔
118
        $servers = '/' === $baseUrl || '' === $baseUrl ? [new Server('/')] : [new Server($baseUrl)];
47✔
119
        $paths = new Paths();
47✔
120
        $schemas = new \ArrayObject();
47✔
121
        $webhooks = new \ArrayObject();
47✔
122
        $tags = [];
47✔
123

124
        foreach ($this->resourceNameCollectionFactory->create() as $resourceClass) {
47✔
125
            $resourceMetadataCollection = $this->resourceMetadataFactory->create($resourceClass);
47✔
126
            foreach ($resourceMetadataCollection as $resourceMetadata) {
47✔
127
                $this->collectPaths($resourceMetadata, $resourceMetadataCollection, $paths, $schemas, $webhooks, $tags, $context);
47✔
128
            }
129
        }
130

131
        $securitySchemes = $this->getSecuritySchemes();
47✔
132
        $securityRequirements = [];
47✔
133

134
        foreach (array_keys($securitySchemes) as $key) {
47✔
135
            $securityRequirements[] = [$key => []];
47✔
136
        }
137

138
        $globalTags = $this->openApiOptions->getTags() ?: array_values($tags) ?: [];
47✔
139

140
        return new OpenApi(
47✔
141
            $info,
47✔
142
            $servers,
47✔
143
            $paths,
47✔
144
            new Components(
47✔
145
                $schemas,
47✔
146
                new \ArrayObject(),
47✔
147
                new \ArrayObject(),
47✔
148
                new \ArrayObject(),
47✔
149
                new \ArrayObject(),
47✔
150
                new \ArrayObject(),
47✔
151
                new \ArrayObject($securitySchemes)
47✔
152
            ),
47✔
153
            $securityRequirements,
47✔
154
            $globalTags,
47✔
155
            null,
47✔
156
            null,
47✔
157
            $webhooks
47✔
158
        );
47✔
159
    }
160

161
    private function collectPaths(ApiResource $resource, ResourceMetadataCollection $resourceMetadataCollection, Paths $paths, \ArrayObject $schemas, \ArrayObject $webhooks, array &$tags, array $context = []): void
162
    {
163
        if (0 === $resource->getOperations()->count()) {
47✔
164
            return;
×
165
        }
166

167
        $defaultError = $this->getErrorResource($this->openApiOptions->getErrorResourceClass() ?? ApiResourceError::class);
47✔
168
        $defaultValidationError = $this->getErrorResource($this->openApiOptions->getValidationErrorResourceClass() ?? ValidationException::class, 422, 'Unprocessable entity');
47✔
169

170
        // This filters on our extension x-apiplatform-tag as the openapi operation tag is used for ordering operations
171
        $filteredTags = $context['filter_tags'] ?? [];
47✔
172
        if (!\is_array($filteredTags)) {
47✔
173
            $filteredTags = [$filteredTags];
2✔
174
        }
175

176
        foreach ($resource->getOperations() as $operationName => $operation) {
47✔
177
            $resourceShortName = $operation->getShortName() ?? $operation;
47✔
178
            // No path to return
179
            if (null === $operation->getUriTemplate() && null === $operation->getRouteName()) {
47✔
180
                continue;
×
181
            }
182

183
            $openapiAttribute = $operation->getOpenapi();
47✔
184

185
            // Operation ignored from OpenApi
186
            if ($operation instanceof HttpOperation && false === $openapiAttribute) {
47✔
187
                continue;
47✔
188
            }
189

190
            // See https://github.com/api-platform/core/issues/6993 we would like to allow only `false` but as we typed `bool` we have this check
191
            $operationTag = !\is_object($openapiAttribute) ? [] : ($openapiAttribute->getExtensionProperties()[self::API_PLATFORM_TAG] ?? []);
47✔
192
            if (!\is_array($operationTag)) {
47✔
193
                $operationTag = [$operationTag];
41✔
194
            }
195

196
            if ($filteredTags && $filteredTags !== array_intersect($filteredTags, $operationTag)) {
47✔
197
                continue;
4✔
198
            }
199

200
            $resourceClass = $operation->getClass() ?? $resource->getClass();
47✔
201
            $routeName = $operation->getRouteName() ?? $operation->getName();
47✔
202

203
            if (!$this->routeCollection && $this->router) {
47✔
204
                $this->routeCollection = $this->router->getRouteCollection();
47✔
205
            }
206

207
            if ($this->routeCollection && $routeName && $route = $this->routeCollection->get($routeName)) {
47✔
208
                $path = $route->getPath();
47✔
209
            } else {
210
                $path = rtrim($operation->getRoutePrefix() ?? '', '/').'/'.ltrim($operation->getUriTemplate() ?? '', '/');
×
211
            }
212

213
            $path = $this->getPath($path);
47✔
214
            $method = $operation->getMethod() ?? 'GET';
47✔
215

216
            if (!\in_array($method, PathItem::$methods, true)) {
47✔
217
                continue;
×
218
            }
219

220
            $pathItem = null;
47✔
221

222
            if ($openapiAttribute instanceof Webhook) {
47✔
223
                $pathItem = $openapiAttribute->getPathItem() ?: new PathItem();
27✔
224
                $openapiOperation = $pathItem->{'get'.ucfirst(strtolower($method))}() ?: new Operation();
27✔
225
            } elseif (!\is_object($openapiAttribute)) {
47✔
226
                $openapiOperation = new Operation();
43✔
227
            } else {
228
                $openapiOperation = $openapiAttribute;
41✔
229
            }
230

231
            // Complete with defaults
232
            $openapiOperation = new Operation(
47✔
233
                operationId: null !== $openapiOperation->getOperationId() ? $openapiOperation->getOperationId() : $this->normalizeOperationName($operationName),
47✔
234
                tags: null !== $openapiOperation->getTags() ? $openapiOperation->getTags() : [$operation->getShortName() ?: $resourceShortName],
47✔
235
                responses: null !== $openapiOperation->getResponses() ? $openapiOperation->getResponses() : [],
47✔
236
                summary: null !== $openapiOperation->getSummary() ? $openapiOperation->getSummary() : $this->getPathDescription($resourceShortName, $method, $operation instanceof CollectionOperationInterface),
47✔
237
                description: null !== $openapiOperation->getDescription() ? $openapiOperation->getDescription() : $this->getPathDescription($resourceShortName, $method, $operation instanceof CollectionOperationInterface),
47✔
238
                externalDocs: $openapiOperation->getExternalDocs(),
47✔
239
                parameters: null !== $openapiOperation->getParameters() ? $openapiOperation->getParameters() : [],
47✔
240
                requestBody: $openapiOperation->getRequestBody(),
47✔
241
                callbacks: $openapiOperation->getCallbacks(),
47✔
242
                deprecated: null !== $openapiOperation->getDeprecated() ? $openapiOperation->getDeprecated() : (bool) $operation->getDeprecationReason(),
47✔
243
                security: null !== $openapiOperation->getSecurity() ? $openapiOperation->getSecurity() : null,
47✔
244
                servers: null !== $openapiOperation->getServers() ? $openapiOperation->getServers() : null,
47✔
245
                extensionProperties: $openapiOperation->getExtensionProperties(),
47✔
246
            );
47✔
247

248
            foreach ($openapiOperation->getTags() as $v) {
47✔
249
                $tags[$v] = new Tag(name: $v, description: $resource->getDescription());
47✔
250
            }
251

252
            [$requestMimeTypes, $responseMimeTypes] = $this->getMimeTypes($operation);
47✔
253

254
            if ($path) {
47✔
255
                $pathItem = $paths->getPath($path) ?: new PathItem();
47✔
256
            } elseif (!$pathItem) {
×
257
                $pathItem = new PathItem();
×
258
            }
259

260
            $forceSchemaCollection = $operation instanceof CollectionOperationInterface && 'GET' === $method;
47✔
261
            $schema = new Schema('openapi');
47✔
262
            $schema->setDefinitions($schemas);
47✔
263

264
            $operationOutputSchemas = [];
47✔
265

266
            foreach ($responseMimeTypes as $operationFormat) {
47✔
267
                $operationOutputSchema = $this->jsonSchemaFactory->buildSchema($resourceClass, $operationFormat, Schema::TYPE_OUTPUT, $operation, $schema, null, $forceSchemaCollection);
47✔
268
                $operationOutputSchemas[$operationFormat] = $operationOutputSchema;
47✔
269
                $this->appendSchemaDefinitions($schemas, $operationOutputSchema->getDefinitions());
47✔
270
            }
271

272
            // Set up parameters
273
            $openapiParameters = $openapiOperation->getParameters();
47✔
274
            foreach ($operation->getUriVariables() ?? [] as $parameterName => $uriVariable) {
47✔
275
                if ($uriVariable->getExpandedValue() ?? false) {
45✔
276
                    continue;
31✔
277
                }
278

279
                $parameter = new Parameter($parameterName, 'path', $uriVariable->getDescription() ?? "$resourceShortName identifier", $uriVariable->getRequired() ?? true, false, false, $uriVariable->getSchema() ?? ['type' => 'string']);
45✔
280

281
                if ($linkParameter = $uriVariable->getOpenApi()) {
45✔
282
                    $parameter = $this->mergeParameter($parameter, $linkParameter);
×
283
                }
284

285
                if ([$i, $operationParameter] = $this->hasParameter($openapiOperation, $parameter)) {
45✔
286
                    $openapiParameters[$i] = $this->mergeParameter($parameter, $operationParameter);
×
287
                    continue;
×
288
                }
289

290
                $openapiParameters[] = $parameter;
45✔
291
            }
292

293
            $openapiOperation = $openapiOperation->withParameters($openapiParameters);
47✔
294

295
            if ($operation instanceof CollectionOperationInterface && 'POST' !== $method) {
47✔
296
                foreach (array_merge($this->getPaginationParameters($operation), $this->getFiltersParameters($operation)) as $parameter) {
47✔
297
                    if ($operationParameter = $this->hasParameter($openapiOperation, $parameter)) {
47✔
298
                        continue;
×
299
                    }
300

301
                    $openapiOperation = $openapiOperation->withParameter($parameter);
47✔
302
                }
303
            }
304

305
            $entityClass = $this->getFilterClass($operation);
47✔
306
            $openapiParameters = $openapiOperation->getParameters();
47✔
307
            foreach ($operation->getParameters() ?? [] as $key => $p) {
47✔
308
                if (false === $p->getOpenApi()) {
33✔
309
                    continue;
33✔
310
                }
311

312
                if (($f = $p->getFilter()) && \is_string($f) && $this->filterLocator && $this->filterLocator->has($f)) {
29✔
313
                    $filter = $this->filterLocator->get($f);
29✔
314

315
                    if ($d = $filter->getDescription($entityClass)) {
29✔
316
                        foreach ($d as $name => $description) {
29✔
317
                            if ($prop = $p->getProperty()) {
29✔
318
                                $name = str_replace($prop, $key, $name);
27✔
319
                            }
320

321
                            $openapiParameters[] = $this->getFilterParameter($name, $description, $operation->getShortName(), $f);
29✔
322
                        }
323

324
                        continue;
29✔
325
                    }
326
                }
327

328
                $in = $p instanceof HeaderParameterInterface ? 'header' : 'query';
29✔
329
                $defaultParameter = new Parameter($key, $in, $p->getDescription() ?? "$resourceShortName $key", $p->getRequired() ?? false, false, false, $p->getSchema() ?? ['type' => 'string']);
29✔
330

331
                $linkParameter = $p->getOpenApi();
29✔
332
                if (null === $linkParameter) {
29✔
333
                    if ([$i, $operationParameter] = $this->hasParameter($openapiOperation, $defaultParameter)) {
29✔
334
                        $openapiParameters[$i] = $this->mergeParameter($defaultParameter, $operationParameter);
×
335
                    } else {
336
                        $openapiParameters[] = $defaultParameter;
29✔
337
                    }
338

339
                    continue;
29✔
340
                }
341

342
                if (\is_array($linkParameter)) {
29✔
343
                    foreach ($linkParameter as $lp) {
27✔
344
                        $parameter = $this->mergeParameter($defaultParameter, $lp);
27✔
345
                        if ([$i, $operationParameter] = $this->hasParameter($openapiOperation, $parameter)) {
27✔
346
                            $openapiParameters[$i] = $this->mergeParameter($parameter, $operationParameter);
×
347
                            continue;
×
348
                        }
349

350
                        $openapiParameters[] = $parameter;
27✔
351
                    }
352
                    continue;
27✔
353
                }
354

355
                $parameter = $this->mergeParameter($defaultParameter, $linkParameter);
29✔
356
                if ([$i, $operationParameter] = $this->hasParameter($openapiOperation, $parameter)) {
29✔
357
                    $openapiParameters[$i] = $this->mergeParameter($parameter, $operationParameter);
×
358
                    continue;
×
359
                }
360
                $openapiParameters[] = $parameter;
29✔
361
            }
362

363
            $openapiOperation = $openapiOperation->withParameters($openapiParameters);
47✔
364
            $existingResponses = $openapiOperation->getResponses() ?: [];
47✔
365
            $overrideResponses = $operation->getExtraProperties()[self::OVERRIDE_OPENAPI_RESPONSES] ?? $this->openApiOptions->getOverrideResponses();
47✔
366
            $errors = null;
47✔
367
            if ($operation instanceof HttpOperation && null !== ($errors = $operation->getErrors())) {
47✔
368
                /** @var array<class-string|string, Error> */
369
                $errorOperations = [];
27✔
370
                foreach ($errors as $error) {
27✔
371
                    $errorOperations[$error] = $this->getErrorResource($error);
27✔
372
                }
373

374
                $openapiOperation = $this->addOperationErrors($openapiOperation, $errorOperations, $resourceMetadataCollection, $schema, $schemas, $operation);
27✔
375
            }
376

377
            if ($overrideResponses || !$existingResponses) {
47✔
378
                // Create responses
379
                switch ($method) {
380
                    case 'GET':
47✔
381
                        $successStatus = (string) $operation->getStatus() ?: 200;
47✔
382
                        $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s %s', $resourceShortName, $operation instanceof CollectionOperationInterface ? 'collection' : 'resource'), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas);
47✔
383
                        break;
47✔
384
                    case 'POST':
43✔
385
                        $successStatus = (string) $operation->getStatus() ?: 201;
43✔
386
                        $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s resource created', $resourceShortName), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas, $resourceMetadataCollection);
43✔
387

388
                        if (null === $errors) {
43✔
389
                            $openapiOperation = $this->addOperationErrors($openapiOperation, [
43✔
390
                                $defaultError->withStatus(400)->withDescription('Invalid input'),
43✔
391
                                $defaultValidationError,
43✔
392
                            ], $resourceMetadataCollection, $schema, $schemas, $operation);
43✔
393
                        }
394
                        break;
43✔
395
                    case 'PATCH':
41✔
396
                    case 'PUT':
41✔
397
                        $successStatus = (string) $operation->getStatus() ?: 200;
41✔
398
                        $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s resource updated', $resourceShortName), $openapiOperation, $operation, $responseMimeTypes, $operationOutputSchemas, $resourceMetadataCollection);
41✔
399

400
                        if (null === $errors) {
41✔
401
                            $openapiOperation = $this->addOperationErrors($openapiOperation, [
41✔
402
                                $defaultError->withStatus(400)->withDescription('Invalid input'),
41✔
403
                                $defaultValidationError,
41✔
404
                            ], $resourceMetadataCollection, $schema, $schemas, $operation);
41✔
405
                        }
406
                        break;
41✔
407
                    case 'DELETE':
41✔
408
                        $successStatus = (string) $operation->getStatus() ?: 204;
41✔
409
                        $openapiOperation = $this->buildOpenApiResponse($existingResponses, $successStatus, \sprintf('%s resource deleted', $resourceShortName), $openapiOperation);
41✔
410
                        break;
41✔
411
                }
412
            }
413

414
            if ($overrideResponses && !isset($existingResponses[403]) && $operation->getSecurity()) {
47✔
415
                $openapiOperation = $this->addOperationErrors($openapiOperation, [
27✔
416
                    $defaultError->withStatus(403)->withDescription('Forbidden'),
27✔
417
                ], $resourceMetadataCollection, $schema, $schemas, $operation);
27✔
418
            }
419

420
            if ($overrideResponses && !$operation instanceof CollectionOperationInterface && 'POST' !== $operation->getMethod() && !isset($existingResponses[404]) && null === $errors) {
47✔
421
                $openapiOperation = $this->addOperationErrors($openapiOperation, [
45✔
422
                    $defaultError->withStatus(404)->withDescription('Not found'),
45✔
423
                ], $resourceMetadataCollection, $schema, $schemas, $operation);
45✔
424
            }
425

426
            if (!$openapiOperation->getResponses()) {
47✔
427
                $openapiOperation = $openapiOperation->withResponse('default', new Response('Unexpected error'));
×
428
            }
429

430
            if (
431
                \in_array($method, ['PATCH', 'PUT', 'POST'], true)
47✔
432
                && !(false === ($input = $operation->getInput()) || (\is_array($input) && null === $input['class']))
47✔
433
            ) {
434
                $content = $openapiOperation->getRequestBody()?->getContent();
43✔
435
                if (null === $content) {
43✔
436
                    $operationInputSchemas = [];
43✔
437
                    foreach ($requestMimeTypes as $operationFormat) {
43✔
438
                        $operationInputSchema = $this->jsonSchemaFactory->buildSchema($resourceClass, $operationFormat, Schema::TYPE_INPUT, $operation, $schema, null, $forceSchemaCollection);
43✔
439
                        $operationInputSchemas[$operationFormat] = $operationInputSchema;
43✔
440
                        $this->appendSchemaDefinitions($schemas, $operationInputSchema->getDefinitions());
43✔
441
                    }
442
                    $content = $this->buildContent($requestMimeTypes, $operationInputSchemas);
43✔
443
                }
444

445
                $openapiOperation = $openapiOperation->withRequestBody(new RequestBody(
43✔
446
                    description: $openapiOperation->getRequestBody()?->getDescription() ?? \sprintf('The %s %s resource', 'POST' === $method ? 'new' : 'updated', $resourceShortName),
43✔
447
                    content: $content,
43✔
448
                    required: $openapiOperation->getRequestBody()?->getRequired() ?? true,
43✔
449
                ));
43✔
450
            }
451

452
            if ($openapiAttribute instanceof Webhook) {
47✔
453
                $webhooks[$openapiAttribute->getName()] = $pathItem->{'with'.ucfirst($method)}($openapiOperation);
27✔
454
                continue;
27✔
455
            }
456

457
            // We merge content types for errors, maybe that this logic could be applied to every resources at some point
458
            if ($operation instanceof Error && ($existingPathItem = $paths->getPath($path)) && ($existingOperation = $existingPathItem->getGet()) && ($currentResponse = $openapiOperation->getResponses()[200] ?? null)) {
47✔
459
                $errorResponse = $existingOperation->getResponses()[200];
×
460
                $currentResponseContent = $currentResponse->getContent();
×
461

462
                foreach ($errorResponse->getContent() as $mime => $content) {
×
463
                    $currentResponseContent[$mime] = $content;
×
464
                }
465

466
                $openapiOperation = $existingOperation->withResponse(200, $currentResponse->withContent($currentResponseContent));
×
467
            }
468

469
            $paths->addPath($path, $pathItem->{'with'.ucfirst($method)}($openapiOperation));
47✔
470
        }
471
    }
472

473
    private function buildOpenApiResponse(array $existingResponses, int|string $status, string $description, ?Operation $openapiOperation = null, ?HttpOperation $operation = null, ?array $responseMimeTypes = null, ?array $operationOutputSchemas = null, ?ResourceMetadataCollection $resourceMetadataCollection = null): Operation
474
    {
475
        if (isset($existingResponses[$status])) {
47✔
476
            return $openapiOperation;
×
477
        }
478
        $responseLinks = $responseContent = null;
47✔
479
        if ($responseMimeTypes && $operationOutputSchemas) {
47✔
480
            $responseContent = $this->buildContent($responseMimeTypes, $operationOutputSchemas);
47✔
481
        }
482
        if ($resourceMetadataCollection && $operation) {
47✔
483
            $responseLinks = $this->getLinks($resourceMetadataCollection, $operation);
45✔
484
        }
485

486
        return $openapiOperation->withResponse($status, new Response($description, $responseContent, null, $responseLinks));
47✔
487
    }
488

489
    /**
490
     * @param array<string, string> $responseMimeTypes
491
     * @param array<string, Schema> $operationSchemas
492
     *
493
     * @return \ArrayObject<MediaType>
494
     */
495
    private function buildContent(array $responseMimeTypes, array $operationSchemas): \ArrayObject
496
    {
497
        /** @var \ArrayObject<MediaType> $content */
498
        $content = new \ArrayObject();
47✔
499

500
        foreach ($responseMimeTypes as $mimeType => $format) {
47✔
501
            $content[$mimeType] = new MediaType(new \ArrayObject($operationSchemas[$format]->getArrayCopy(false)));
47✔
502
        }
503

504
        return $content;
47✔
505
    }
506

507
    /**
508
     * @return array[array<string, string>, array<string, string>]
509
     */
510
    private function getMimeTypes(HttpOperation $operation): array
511
    {
512
        $requestFormats = $operation->getInputFormats() ?: [];
47✔
513
        $responseFormats = $operation->getOutputFormats() ?: [];
47✔
514

515
        $requestMimeTypes = $this->flattenMimeTypes($requestFormats);
47✔
516
        $responseMimeTypes = $this->flattenMimeTypes($responseFormats);
47✔
517

518
        return [$requestMimeTypes, $responseMimeTypes];
47✔
519
    }
520

521
    /**
522
     * @param array<string, string[]> $responseFormats
523
     *
524
     * @return array<string, string>
525
     */
526
    private function flattenMimeTypes(array $responseFormats): array
527
    {
528
        $responseMimeTypes = [];
47✔
529
        foreach ($responseFormats as $responseFormat => $mimeTypes) {
47✔
530
            foreach ($mimeTypes as $mimeType) {
47✔
531
                $responseMimeTypes[$mimeType] = $responseFormat;
47✔
532
            }
533
        }
534

535
        return $responseMimeTypes;
47✔
536
    }
537

538
    /**
539
     * Gets the path for an operation.
540
     *
541
     * If the path ends with the optional _format parameter, it is removed
542
     * as optional path parameters are not yet supported.
543
     *
544
     * @see https://github.com/OAI/OpenAPI-Specification/issues/93
545
     */
546
    private function getPath(string $path): string
547
    {
548
        // Handle either API Platform's URI Template (rfc6570) or Symfony's route
549
        if (str_ends_with($path, '{._format}') || str_ends_with($path, '.{_format}')) {
47✔
550
            $path = substr($path, 0, -10);
47✔
551
        }
552

553
        return str_starts_with($path, '/') ? $path : '/'.$path;
47✔
554
    }
555

556
    private function getPathDescription(string $resourceShortName, string $method, bool $isCollection): string
557
    {
558
        switch ($method) {
559
            case 'GET':
47✔
560
                $pathSummary = $isCollection ? 'Retrieves the collection of %s resources.' : 'Retrieves a %s resource.';
47✔
561
                break;
47✔
562
            case 'POST':
43✔
563
                $pathSummary = 'Creates a %s resource.';
43✔
564
                break;
43✔
565
            case 'PATCH':
41✔
566
                $pathSummary = 'Updates the %s resource.';
41✔
567
                break;
41✔
568
            case 'PUT':
41✔
569
                $pathSummary = 'Replaces the %s resource.';
39✔
570
                break;
39✔
571
            case 'DELETE':
41✔
572
                $pathSummary = 'Removes the %s resource.';
41✔
573
                break;
41✔
574
            default:
575
                return $resourceShortName;
×
576
        }
577

578
        return \sprintf($pathSummary, $resourceShortName);
47✔
579
    }
580

581
    /**
582
     * @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#linkObject.
583
     *
584
     * @return \ArrayObject<Link>
585
     */
586
    private function getLinks(ResourceMetadataCollection $resourceMetadataCollection, HttpOperation $currentOperation): \ArrayObject
587
    {
588
        /** @var \ArrayObject<Link> $links */
589
        $links = new \ArrayObject();
45✔
590

591
        // Only compute get links for now
592
        foreach ($resourceMetadataCollection as $resource) {
45✔
593
            foreach ($resource->getOperations() as $operationName => $operation) {
45✔
594
                $parameters = [];
45✔
595
                $method = $operation instanceof HttpOperation ? $operation->getMethod() : 'GET';
45✔
596
                if (
597
                    $operationName === $operation->getName()
45✔
598
                    || isset($links[$operationName])
45✔
599
                    || $operation instanceof CollectionOperationInterface
45✔
600
                    || 'GET' !== $method
45✔
601
                ) {
602
                    continue;
45✔
603
                }
604

605
                // Operation ignored from OpenApi
606
                if ($operation instanceof HttpOperation && (false === $operation->getOpenapi() || $operation->getOpenapi() instanceof Webhook)) {
×
607
                    continue;
×
608
                }
609

610
                $operationUriVariables = $operation->getUriVariables();
×
611
                foreach ($currentOperation->getUriVariables() ?? [] as $parameterName => $uriVariableDefinition) {
×
612
                    if (!isset($operationUriVariables[$parameterName])) {
×
613
                        continue;
×
614
                    }
615

616
                    if ($operationUriVariables[$parameterName]->getIdentifiers() === $uriVariableDefinition->getIdentifiers() && $operationUriVariables[$parameterName]->getFromClass() === $uriVariableDefinition->getFromClass()) {
×
617
                        $parameters[$parameterName] = '$request.path.'.($uriVariableDefinition->getIdentifiers()[0] ?? 'id');
×
618
                    }
619
                }
620

621
                foreach ($operationUriVariables ?? [] as $parameterName => $uriVariableDefinition) {
×
622
                    if (isset($parameters[$parameterName])) {
×
623
                        continue;
×
624
                    }
625

626
                    if ($uriVariableDefinition->getFromClass() === $currentOperation->getClass()) {
×
627
                        $parameters[$parameterName] = '$response.body#/'.($uriVariableDefinition->getIdentifiers()[0] ?? 'id');
×
628
                    }
629
                }
630

631
                $links[$operationName] = new Link(
×
632
                    $operationName,
×
633
                    new \ArrayObject($parameters),
×
634
                    null,
×
635
                    $operation->getDescription() ?? ''
×
636
                );
×
637
            }
638
        }
639

640
        return $links;
45✔
641
    }
642

643
    /**
644
     * Gets parameters corresponding to enabled filters.
645
     */
646
    private function getFiltersParameters(CollectionOperationInterface|HttpOperation $operation): array
647
    {
648
        $parameters = [];
47✔
649
        $resourceFilters = $operation->getFilters();
47✔
650
        $entityClass = $this->getFilterClass($operation);
47✔
651

652
        foreach ($resourceFilters ?? [] as $filterId) {
47✔
653
            if (!$this->filterLocator->has($filterId)) {
31✔
654
                continue;
×
655
            }
656

657
            $filter = $this->filterLocator->get($filterId);
31✔
658
            foreach ($filter->getDescription($entityClass) as $name => $description) {
31✔
659
                $parameters[] = $this->getFilterParameter($name, $description, $operation->getShortName(), $filterId);
31✔
660
            }
661
        }
662

663
        return $parameters;
47✔
664
    }
665

666
    private function getFilterClass(HttpOperation $operation): ?string
667
    {
668
        $entityClass = $operation->getClass();
47✔
669
        if ($options = $operation->getStateOptions()) {
47✔
670
            if ($options instanceof DoctrineOptions && $options->getEntityClass()) {
31✔
671
                return $options->getEntityClass();
27✔
672
            }
673

674
            if ($options instanceof DoctrineODMOptions && $options->getDocumentClass()) {
31✔
675
                return $options->getDocumentClass();
27✔
676
            }
677
        }
678

679
        return $entityClass;
47✔
680
    }
681

682
    /**
683
     * @param array<string, mixed> $description
684
     */
685
    private function getFilterParameter(string $name, array $description, string $shortName, string $filter): Parameter
686
    {
687
        if (isset($description['swagger'])) {
33✔
688
            trigger_deprecation('api-platform/core', '4.0', \sprintf('Using the "swagger" field of the %s::getDescription() (%s) is deprecated.', $filter, $shortName));
×
689
        }
690

691
        if (!isset($description['openapi']) || $description['openapi'] instanceof Parameter) {
33✔
692
            $schema = $description['schema'] ?? [];
33✔
693

694
            if (isset($description['type']) && \in_array($description['type'], Type::$builtinTypes, true) && !isset($schema['type'])) {
33✔
695
                $schema += $this->getType(new Type($description['type'], false, null, $description['is_collection'] ?? false));
33✔
696
            }
697

698
            if (!isset($schema['type'])) {
33✔
699
                $schema['type'] = 'string';
31✔
700
            }
701

702
            $style = 'array' === ($schema['type'] ?? null) && \in_array(
33✔
703
                $description['type'],
33✔
704
                [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_OBJECT],
33✔
705
                true
33✔
706
            ) ? 'deepObject' : 'form';
33✔
707

708
            $parameter = isset($description['openapi']) && $description['openapi'] instanceof Parameter ? $description['openapi'] : new Parameter(in: 'query', name: $name, style: $style, explode: $description['is_collection'] ?? false);
33✔
709

710
            if ('' === $parameter->getDescription() && ($str = $description['description'] ?? '')) {
33✔
711
                $parameter = $parameter->withDescription($str);
×
712
            }
713

714
            if (false === $parameter->getRequired() && false !== ($required = $description['required'] ?? false)) {
33✔
715
                $parameter = $parameter->withRequired($required);
27✔
716
            }
717

718
            return $parameter->withSchema($schema);
33✔
719
        }
720

721
        trigger_deprecation('api-platform/core', '4.0', \sprintf('Not using "%s" on the "openapi" field of the %s::getDescription() (%s) is deprecated.', Parameter::class, $filter, $shortName));
×
722
        $schema = $description['schema'] ?? (\in_array($description['type'], Type::$builtinTypes, true) ? $this->getType(new Type($description['type'], false, null, $description['is_collection'] ?? false)) : ['type' => 'string']);
×
723

724
        return new Parameter(
×
725
            $name,
×
726
            'query',
×
727
            $description['description'] ?? '',
×
728
            $description['required'] ?? false,
×
729
            $description['openapi']['deprecated'] ?? false,
×
730
            $description['openapi']['allowEmptyValue'] ?? true,
×
731
            $schema,
×
732
            'array' === $schema['type'] && \in_array(
×
733
                $description['type'],
×
734
                [Type::BUILTIN_TYPE_ARRAY, Type::BUILTIN_TYPE_OBJECT],
×
735
                true
×
736
            ) ? 'deepObject' : 'form',
×
737
            $description['openapi']['explode'] ?? ('array' === $schema['type']),
×
738
            $description['openapi']['allowReserved'] ?? false,
×
739
            $description['openapi']['example'] ?? null,
×
740
            isset(
×
741
                $description['openapi']['examples']
×
742
            ) ? new \ArrayObject($description['openapi']['examples']) : null
×
743
        );
×
744
    }
745

746
    private function getPaginationParameters(CollectionOperationInterface|HttpOperation $operation): array
747
    {
748
        if (!$this->paginationOptions->isPaginationEnabled()) {
47✔
749
            return [];
×
750
        }
751

752
        $parameters = [];
47✔
753

754
        if ($operation->getPaginationEnabled() ?? $this->paginationOptions->isPaginationEnabled()) {
47✔
755
            $parameters[] = new Parameter($this->paginationOptions->getPaginationPageParameterName(), 'query', 'The collection page number', false, false, true, ['type' => 'integer', 'default' => 1]);
47✔
756

757
            if ($operation->getPaginationClientItemsPerPage() ?? $this->paginationOptions->getClientItemsPerPage()) {
47✔
758
                $schema = [
47✔
759
                    'type' => 'integer',
47✔
760
                    'default' => $operation->getPaginationItemsPerPage() ?? $this->paginationOptions->getItemsPerPage(),
47✔
761
                    'minimum' => 0,
47✔
762
                ];
47✔
763

764
                if (null !== $maxItemsPerPage = ($operation->getPaginationMaximumItemsPerPage() ?? $this->paginationOptions->getMaximumItemsPerPage())) {
47✔
UNCOV
765
                    $schema['maximum'] = $maxItemsPerPage;
15✔
766
                }
767

768
                $parameters[] = new Parameter($this->paginationOptions->getItemsPerPageParameterName(), 'query', 'The number of items per page', false, false, true, $schema);
47✔
769
            }
770
        }
771

772
        if ($operation->getPaginationClientEnabled() ?? $this->paginationOptions->isPaginationClientEnabled()) {
47✔
773
            $parameters[] = new Parameter($this->paginationOptions->getPaginationClientEnabledParameterName(), 'query', 'Enable or disable pagination', false, false, true, ['type' => 'boolean']);
47✔
774
        }
775

776
        return $parameters;
47✔
777
    }
778

779
    private function getOauthSecurityScheme(): SecurityScheme
780
    {
781
        $oauthFlow = new OAuthFlow($this->openApiOptions->getOAuthAuthorizationUrl(), $this->openApiOptions->getOAuthTokenUrl() ?: null, $this->openApiOptions->getOAuthRefreshUrl() ?: null, new \ArrayObject($this->openApiOptions->getOAuthScopes()));
47✔
782
        $description = \sprintf(
47✔
783
            'OAuth 2.0 %s Grant',
47✔
784
            strtolower(preg_replace('/[A-Z]/', ' \\0', lcfirst($this->openApiOptions->getOAuthFlow())))
47✔
785
        );
47✔
786
        $implicit = $password = $clientCredentials = $authorizationCode = null;
47✔
787

788
        switch ($this->openApiOptions->getOAuthFlow()) {
47✔
789
            case 'implicit':
47✔
790
                $implicit = $oauthFlow;
47✔
791
                break;
47✔
792
            case 'password':
×
793
                $password = $oauthFlow;
×
794
                break;
×
795
            case 'application':
×
796
            case 'clientCredentials':
×
797
                $clientCredentials = $oauthFlow;
×
798
                break;
×
799
            case 'accessCode':
×
800
            case 'authorizationCode':
×
801
                $authorizationCode = $oauthFlow;
×
802
                break;
×
803
            default:
804
                throw new \LogicException('OAuth flow must be one of: implicit, password, clientCredentials, authorizationCode');
×
805
        }
806

807
        return new SecurityScheme($this->openApiOptions->getOAuthType(), $description, null, null, null, null, new OAuthFlows($implicit, $password, $clientCredentials, $authorizationCode), null);
47✔
808
    }
809

810
    private function getSecuritySchemes(): array
811
    {
812
        $securitySchemes = [];
47✔
813

814
        if ($this->openApiOptions->getOAuthEnabled()) {
47✔
815
            $securitySchemes['oauth'] = $this->getOauthSecurityScheme();
47✔
816
        }
817

818
        foreach ($this->openApiOptions->getApiKeys() as $key => $apiKey) {
47✔
819
            $description = \sprintf('Value for the %s %s parameter.', $apiKey['name'], $apiKey['type']);
47✔
820
            $securitySchemes[$key] = new SecurityScheme('apiKey', $description, $apiKey['name'], $apiKey['type']);
47✔
821
        }
822

823
        foreach ($this->openApiOptions->getHttpAuth() as $key => $httpAuth) {
47✔
824
            $description = \sprintf('Value for the http %s parameter.', $httpAuth['scheme']);
×
825
            $securitySchemes[$key] = new SecurityScheme('http', $description, null, null, $httpAuth['scheme'], $httpAuth['bearerFormat'] ?? null);
×
826
        }
827

828
        return $securitySchemes;
47✔
829
    }
830

831
    /**
832
     * @param \ArrayObject<string, mixed> $schemas
833
     * @param \ArrayObject<string, mixed> $definitions
834
     */
835
    private function appendSchemaDefinitions(\ArrayObject $schemas, \ArrayObject $definitions): void
836
    {
837
        foreach ($definitions as $key => $value) {
47✔
838
            $schemas[$key] = $value;
47✔
839
        }
840
    }
841

842
    /**
843
     * @return array{0: int, 1: Parameter}|null
844
     */
845
    private function hasParameter(Operation $operation, Parameter $parameter): ?array
846
    {
847
        foreach ($operation->getParameters() as $key => $existingParameter) {
47✔
848
            if ($existingParameter->getName() === $parameter->getName() && $existingParameter->getIn() === $parameter->getIn()) {
47✔
849
                return [$key, $existingParameter];
×
850
            }
851
        }
852

853
        return null;
47✔
854
    }
855

856
    private function mergeParameter(Parameter $actual, Parameter $defined): Parameter
857
    {
858
        foreach (
859
            [
29✔
860
                'name',
29✔
861
                'in',
29✔
862
                'description',
29✔
863
                'required',
29✔
864
                'deprecated',
29✔
865
                'allowEmptyValue',
29✔
866
                'style',
29✔
867
                'explode',
29✔
868
                'allowReserved',
29✔
869
                'example',
29✔
870
            ] as $method
29✔
871
        ) {
872
            $newValue = $defined->{"get$method"}();
29✔
873
            if (null !== $newValue && $actual->{"get$method"}() !== $newValue) {
29✔
874
                $actual = $actual->{"with$method"}($newValue);
29✔
875
            }
876
        }
877

878
        foreach (['examples', 'content', 'schema'] as $method) {
29✔
879
            $newValue = $defined->{"get$method"}();
29✔
880
            if ($newValue && \count($newValue) > 0 && $actual->{"get$method"}() !== $newValue) {
29✔
881
                $actual = $actual->{"with$method"}($newValue);
×
882
            }
883
        }
884

885
        return $actual;
29✔
886
    }
887

888
    /**
889
     * @param ErrorResource[]              $errors
890
     * @param \ArrayObject<string, Schema> $schemas
891
     */
892
    private function addOperationErrors(
893
        Operation $operation,
894
        array $errors,
895
        ResourceMetadataCollection $resourceMetadataCollection,
896
        Schema $schema,
897
        \ArrayObject $schemas,
898
        HttpOperation $originalOperation,
899
    ): Operation {
900
        foreach ($errors as $errorResource) {
45✔
901
            $responseMimeTypes = $this->flattenMimeTypes($errorResource->getOutputFormats() ?: $this->errorFormats);
45✔
902
            foreach ($errorResource->getOperations() as $errorOperation) {
45✔
903
                if (false === $errorOperation->getOpenApi()) {
45✔
904
                    continue;
45✔
905
                }
906

907
                $responseMimeTypes += $this->flattenMimeTypes($errorOperation->getOutputFormats() ?: $this->errorFormats);
27✔
908
            }
909

910
            foreach ($responseMimeTypes as $mime => $format) {
45✔
911
                if (!isset($this->errorFormats[$format])) {
45✔
912
                    unset($responseMimeTypes[$mime]);
×
913
                }
914
            }
915

916
            $operationErrorSchemas = [];
45✔
917
            foreach ($responseMimeTypes as $operationFormat) {
45✔
918
                $operationErrorSchema = $this->jsonSchemaFactory->buildSchema($errorResource->getClass(), $operationFormat, Schema::TYPE_OUTPUT, null, $schema);
45✔
919
                $operationErrorSchemas[$operationFormat] = $operationErrorSchema;
45✔
920
                $this->appendSchemaDefinitions($schemas, $operationErrorSchema->getDefinitions());
45✔
921
            }
922

923
            if (!$status = $errorResource->getStatus()) {
45✔
924
                throw new RuntimeException(\sprintf('The error class "%s" has no status defined, please either implement ProblemExceptionInterface, or make it an ErrorResource with a status', $errorResource->getClass()));
×
925
            }
926

927
            $operation = $this->buildOpenApiResponse($operation->getResponses() ?: [], $status, $errorResource->getDescription() ?? '', $operation, $originalOperation, $responseMimeTypes, $operationErrorSchemas, $resourceMetadataCollection);
45✔
928
        }
929

930
        return $operation;
45✔
931
    }
932

933
    /**
934
     * @param string|class-string $error
935
     */
936
    private function getErrorResource(string $error, ?int $status = null, ?string $description = null): ErrorResource
937
    {
938
        if ($this->localErrorResourceCache[$error] ?? null) {
47✔
939
            return $this->localErrorResourceCache[$error];
47✔
940
        }
941

942
        if (is_a($error, ProblemExceptionInterface::class, true)) {
47✔
943
            try {
944
                /** @var ProblemExceptionInterface $exception */
945
                $exception = new $error();
47✔
946
                $status = $exception->getStatus();
47✔
947
                $description = $exception->getTitle();
47✔
948
            } catch (\TypeError) {
47✔
949
            }
950
        } elseif (class_exists($error)) {
×
951
            throw new RuntimeException(\sprintf('The error class "%s" does not implement "%s". Did you forget a use statement?', $error, ProblemExceptionInterface::class));
×
952
        }
953

954
        $defaultErrorResourceClass = $this->openApiOptions->getErrorResourceClass() ?? ApiResourceError::class;
47✔
955

956
        try {
957
            $errorResource = $this->resourceMetadataFactory->create($error)[0] ?? new ErrorResource(status: $status, description: $description, class: $defaultErrorResourceClass);
47✔
958
            if (!($errorResource instanceof ErrorResource)) {
47✔
959
                throw new RuntimeException(\sprintf('The error class %s is not an ErrorResource', $error));
×
960
            }
961

962
            // Here we want the exception status and expression to override the resource one when available
963
            if ($status) {
47✔
964
                $errorResource = $errorResource->withStatus($status);
47✔
965
            }
966

967
            if ($description) {
47✔
968
                $errorResource = $errorResource->withDescription($description);
47✔
969
            }
970
        } catch (ResourceClassNotFoundException|OperationNotFoundException) {
×
971
            $errorResource = new ErrorResource(status: $status, description: $description, class: $defaultErrorResourceClass);
×
972
        }
973

974
        if (!$errorResource->getClass()) {
47✔
975
            $errorResource = $errorResource->withClass($error);
×
976
        }
977

978
        return $this->localErrorResourceCache[$error] = $errorResource;
47✔
979
    }
980
}
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