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

api-platform / core / 13200284839

07 Feb 2025 12:56PM UTC coverage: 0.0% (-8.2%) from 8.164%
13200284839

Pull #6952

github

web-flow
Merge 519fbf8cc into 62377f880
Pull Request #6952: fix: errors retrieval and documentation

0 of 206 new or added lines in 17 files covered. (0.0%)

10757 existing lines in 366 files now uncovered.

0 of 47781 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/Metadata/Extractor/YamlResourceExtractor.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\Metadata\Extractor;
15

16
use ApiPlatform\Elasticsearch\State\Options;
17
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
18
use ApiPlatform\Metadata\GetCollection;
19
use ApiPlatform\Metadata\HeaderParameter;
20
use ApiPlatform\Metadata\Post;
21
use ApiPlatform\Metadata\QueryParameter;
22
use ApiPlatform\OpenApi\Model\ExternalDocumentation;
23
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
24
use ApiPlatform\OpenApi\Model\Parameter;
25
use ApiPlatform\OpenApi\Model\RequestBody;
26
use ApiPlatform\State\OptionsInterface;
27
use Symfony\Component\WebLink\Link;
28
use Symfony\Component\Yaml\Exception\ParseException;
29
use Symfony\Component\Yaml\Yaml;
30

31
/**
32
 * Extracts an array of metadata from a list of YAML files.
33
 *
34
 * @author Antoine Bluchet <soyuka@gmail.com>
35
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
36
 * @author Kévin Dunglas <dunglas@gmail.com>
37
 * @author Vincent Chalamon <vincentchalamon@gmail.com>
38
 */
39
final class YamlResourceExtractor extends AbstractResourceExtractor
40
{
41
    use ResourceExtractorTrait;
42

43
    /**
44
     * {@inheritdoc}
45
     */
46
    protected function extractPath(string $path): void
47
    {
48
        try {
UNCOV
49
            $resourcesYaml = Yaml::parse((string) file_get_contents($path), Yaml::PARSE_CONSTANT);
×
50
        } catch (ParseException $e) {
×
51
            $e->setParsedFile($path);
×
52

53
            throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
×
54
        }
55

UNCOV
56
        if (null === $resourcesYaml = $resourcesYaml['resources'] ?? $resourcesYaml) {
×
57
            return;
×
58
        }
59

UNCOV
60
        if (!\is_array($resourcesYaml)) {
×
61
            throw new InvalidArgumentException(\sprintf('"resources" setting is expected to be null or an array, %s given in "%s".', \gettype($resourcesYaml), $path));
×
62
        }
63

UNCOV
64
        $this->buildResources($resourcesYaml, $path);
×
65
    }
66

67
    private function buildResources(array $resourcesYaml, string $path): void
68
    {
UNCOV
69
        foreach ($resourcesYaml as $resourceName => $resourceYaml) {
×
UNCOV
70
            $resourceName = $this->resolve($resourceName);
×
71

UNCOV
72
            if (null === $resourceYaml) {
×
UNCOV
73
                $resourceYaml = [[]];
×
74
            }
75

UNCOV
76
            if (!\array_key_exists(0, $resourceYaml)) {
×
UNCOV
77
                $resourceYaml = [$resourceYaml];
×
78
            }
79

UNCOV
80
            foreach ($resourceYaml as $key => $resourceYamlDatum) {
×
UNCOV
81
                if (null === $resourceYamlDatum) {
×
UNCOV
82
                    $resourceYamlDatum = [];
×
83
                }
84

85
                try {
UNCOV
86
                    $base = $this->buildExtendedBase($resourceYamlDatum);
×
UNCOV
87
                    $this->resources[$resourceName][$key] = array_merge($base, [
×
UNCOV
88
                        'operations' => $this->buildOperations($resourceYamlDatum, $base),
×
UNCOV
89
                        'graphQlOperations' => $this->buildGraphQlOperations($resourceYamlDatum, $base),
×
UNCOV
90
                    ]);
×
91
                } catch (InvalidArgumentException $exception) {
×
92
                    throw new InvalidArgumentException(\sprintf('%s in "%s" (%s).', $exception->getMessage(), $resourceName, $path));
×
93
                }
94
            }
95
        }
96
    }
97

98
    private function buildExtendedBase(array $resource): array
99
    {
UNCOV
100
        return array_merge($this->buildBase($resource), [
×
UNCOV
101
            'uriTemplate' => $this->phpize($resource, 'uriTemplate', 'string'),
×
UNCOV
102
            'routePrefix' => $this->phpize($resource, 'routePrefix', 'string'),
×
UNCOV
103
            'stateless' => $this->phpize($resource, 'stateless', 'bool'),
×
UNCOV
104
            'sunset' => $this->phpize($resource, 'sunset', 'string'),
×
UNCOV
105
            'acceptPatch' => $this->phpize($resource, 'acceptPatch', 'string'),
×
UNCOV
106
            'host' => $this->phpize($resource, 'host', 'string'),
×
UNCOV
107
            'condition' => $this->phpize($resource, 'condition', 'string'),
×
UNCOV
108
            'controller' => $this->phpize($resource, 'controller', 'string'),
×
UNCOV
109
            'queryParameterValidationEnabled' => $this->phpize($resource, 'queryParameterValidationEnabled', 'bool'),
×
UNCOV
110
            'types' => $this->buildArrayValue($resource, 'types'),
×
UNCOV
111
            'cacheHeaders' => $this->buildArrayValue($resource, 'cacheHeaders'),
×
UNCOV
112
            'hydraContext' => $this->buildArrayValue($resource, 'hydraContext'),
×
UNCOV
113
            'openapi' => $this->buildOpenapi($resource),
×
UNCOV
114
            'paginationViaCursor' => $this->buildArrayValue($resource, 'paginationViaCursor'),
×
UNCOV
115
            'exceptionToStatus' => $this->buildArrayValue($resource, 'exceptionToStatus'),
×
UNCOV
116
            'defaults' => $this->buildArrayValue($resource, 'defaults'),
×
UNCOV
117
            'requirements' => $this->buildArrayValue($resource, 'requirements'),
×
UNCOV
118
            'options' => $this->buildArrayValue($resource, 'options'),
×
UNCOV
119
            'status' => $this->phpize($resource, 'status', 'integer'),
×
UNCOV
120
            'schemes' => $this->buildArrayValue($resource, 'schemes'),
×
UNCOV
121
            'formats' => $this->buildArrayValue($resource, 'formats'),
×
UNCOV
122
            'uriVariables' => $this->buildUriVariables($resource),
×
UNCOV
123
            'inputFormats' => $this->buildArrayValue($resource, 'inputFormats'),
×
UNCOV
124
            'outputFormats' => $this->buildArrayValue($resource, 'outputFormats'),
×
UNCOV
125
            'stateOptions' => $this->buildStateOptions($resource),
×
UNCOV
126
            'links' => $this->buildLinks($resource),
×
UNCOV
127
            'headers' => $this->buildHeaders($resource),
×
UNCOV
128
            'parameters' => $this->buildParameters($resource),
×
UNCOV
129
        ]);
×
130
    }
131

132
    private function buildBase(array $resource): array
133
    {
UNCOV
134
        return [
×
UNCOV
135
            'shortName' => $this->phpize($resource, 'shortName', 'string'),
×
UNCOV
136
            'description' => $this->phpize($resource, 'description', 'string'),
×
UNCOV
137
            'urlGenerationStrategy' => $this->phpize($resource, 'urlGenerationStrategy', 'integer'),
×
UNCOV
138
            'deprecationReason' => $this->phpize($resource, 'deprecationReason', 'string'),
×
UNCOV
139
            'elasticsearch' => $this->phpize($resource, 'elasticsearch', 'bool'),
×
UNCOV
140
            'fetchPartial' => $this->phpize($resource, 'fetchPartial', 'bool'),
×
UNCOV
141
            'forceEager' => $this->phpize($resource, 'forceEager', 'bool'),
×
UNCOV
142
            'paginationClientEnabled' => $this->phpize($resource, 'paginationClientEnabled', 'bool'),
×
UNCOV
143
            'paginationClientItemsPerPage' => $this->phpize($resource, 'paginationClientItemsPerPage', 'bool'),
×
UNCOV
144
            'paginationClientPartial' => $this->phpize($resource, 'paginationClientPartial', 'bool'),
×
UNCOV
145
            'paginationEnabled' => $this->phpize($resource, 'paginationEnabled', 'bool'),
×
UNCOV
146
            'paginationFetchJoinCollection' => $this->phpize($resource, 'paginationFetchJoinCollection', 'bool'),
×
UNCOV
147
            'paginationUseOutputWalkers' => $this->phpize($resource, 'paginationUseOutputWalkers', 'bool'),
×
UNCOV
148
            'paginationItemsPerPage' => $this->phpize($resource, 'paginationItemsPerPage', 'integer'),
×
UNCOV
149
            'paginationMaximumItemsPerPage' => $this->phpize($resource, 'paginationMaximumItemsPerPage', 'integer'),
×
UNCOV
150
            'paginationPartial' => $this->phpize($resource, 'paginationPartial', 'bool'),
×
UNCOV
151
            'paginationType' => $this->phpize($resource, 'paginationType', 'string'),
×
UNCOV
152
            'processor' => $this->phpize($resource, 'processor', 'string'),
×
UNCOV
153
            'provider' => $this->phpize($resource, 'provider', 'string'),
×
UNCOV
154
            'security' => $this->phpize($resource, 'security', 'string'),
×
UNCOV
155
            'securityMessage' => $this->phpize($resource, 'securityMessage', 'string'),
×
UNCOV
156
            'securityPostDenormalize' => $this->phpize($resource, 'securityPostDenormalize', 'string'),
×
UNCOV
157
            'securityPostDenormalizeMessage' => $this->phpize($resource, 'securityPostDenormalizeMessage', 'string'),
×
UNCOV
158
            'securityPostValidation' => $this->phpize($resource, 'securityPostValidation', 'string'),
×
UNCOV
159
            'securityPostValidationMessage' => $this->phpize($resource, 'securityPostValidationMessage', 'string'),
×
UNCOV
160
            'input' => $this->phpize($resource, 'input', 'bool|string'),
×
UNCOV
161
            'output' => $this->phpize($resource, 'output', 'bool|string'),
×
UNCOV
162
            'normalizationContext' => $this->buildArrayValue($resource, 'normalizationContext'),
×
UNCOV
163
            'denormalizationContext' => $this->buildArrayValue($resource, 'denormalizationContext'),
×
UNCOV
164
            'collectDenormalizationErrors' => $this->phpize($resource, 'collectDenormalizationErrors', 'bool'),
×
UNCOV
165
            'validationContext' => $this->buildArrayValue($resource, 'validationContext'),
×
UNCOV
166
            'filters' => $this->buildArrayValue($resource, 'filters'),
×
UNCOV
167
            'order' => $this->buildArrayValue($resource, 'order'),
×
UNCOV
168
            'extraProperties' => $this->buildArrayValue($resource, 'extraProperties'),
×
UNCOV
169
            'mercure' => $this->buildMercure($resource),
×
UNCOV
170
            'messenger' => $this->buildMessenger($resource),
×
UNCOV
171
            'read' => $this->phpize($resource, 'read', 'bool'),
×
UNCOV
172
            'write' => $this->phpize($resource, 'write', 'bool'),
×
UNCOV
173
        ];
×
174
    }
175

176
    private function buildUriVariables(array $resource): ?array
177
    {
UNCOV
178
        if (!\array_key_exists('uriVariables', $resource)) {
×
UNCOV
179
            return null;
×
180
        }
181

UNCOV
182
        $uriVariables = [];
×
UNCOV
183
        foreach ($resource['uriVariables'] as $parameterName => $data) {
×
UNCOV
184
            if (\is_string($data)) {
×
185
                $uriVariables[$data] = $data;
×
186
                continue;
×
187
            }
188

UNCOV
189
            if (2 === (is_countable($data) ? \count($data) : 0) && isset($data[0]) && isset($data[1])) {
×
UNCOV
190
                $data['fromClass'] = $data[0];
×
UNCOV
191
                $data['fromProperty'] = $data[1];
×
UNCOV
192
                unset($data[0], $data[1]);
×
193
            }
UNCOV
194
            if (isset($data['fromClass'])) {
×
UNCOV
195
                $uriVariables[$parameterName]['from_class'] = $this->resolve($data['fromClass']);
×
196
            }
UNCOV
197
            if (isset($data['fromProperty'])) {
×
UNCOV
198
                $uriVariables[$parameterName]['from_property'] = $data['fromProperty'];
×
199
            }
UNCOV
200
            if (isset($data['toClass'])) {
×
201
                $uriVariables[$parameterName]['to_class'] = $this->resolve($data['toClass']);
×
202
            }
UNCOV
203
            if (isset($data['toProperty'])) {
×
UNCOV
204
                $uriVariables[$parameterName]['to_property'] = $data['toProperty'];
×
205
            }
UNCOV
206
            if (isset($data['identifiers'])) {
×
207
                $uriVariables[$parameterName]['identifiers'] = $data['identifiers'];
×
208
            }
UNCOV
209
            if (isset($data['compositeIdentifier'])) {
×
210
                $uriVariables[$parameterName]['composite_identifier'] = $data['compositeIdentifier'];
×
211
            }
212
        }
213

UNCOV
214
        return $uriVariables;
×
215
    }
216

217
    private function buildOpenapi(array $resource): bool|OpenApiOperation|null
218
    {
UNCOV
219
        if (!\array_key_exists('openapi', $resource)) {
×
UNCOV
220
            return null;
×
221
        }
222

UNCOV
223
        if (!\is_array($resource['openapi'])) {
×
224
            return $this->phpize($resource, 'openapi', 'bool');
×
225
        }
226

UNCOV
227
        $allowedProperties = array_map(fn (\ReflectionProperty $reflProperty): string => $reflProperty->getName(), (new \ReflectionClass(OpenApiOperation::class))->getProperties());
×
UNCOV
228
        foreach ($resource['openapi'] as $key => $value) {
×
UNCOV
229
            $resource['openapi'][$key] = match ($key) {
×
230
                'externalDocs' => new ExternalDocumentation(description: $value['description'] ?? '', url: $value['url'] ?? ''),
×
231
                'requestBody' => new RequestBody(description: $value['description'] ?? '', content: isset($value['content']) ? new \ArrayObject($value['content'] ?? []) : null, required: $value['required'] ?? false),
×
232
                'callbacks' => new \ArrayObject($value ?? []),
×
UNCOV
233
                default => $value,
×
UNCOV
234
            };
×
235

UNCOV
236
            if (\in_array($key, $allowedProperties, true)) {
×
237
                continue;
×
238
            }
239

UNCOV
240
            $resource['openapi']['extensionProperties'][$key] = $value;
×
UNCOV
241
            unset($resource['openapi'][$key]);
×
242
        }
243

UNCOV
244
        if (\array_key_exists('parameters', $resource['openapi']) && \is_array($openapiParameters = $resource['openapi']['parameters'] ?? [])) {
×
245
            $parameters = [];
×
246
            foreach ($openapiParameters as $parameter) {
×
247
                $parameters[] = new Parameter(
×
248
                    name: $parameter['name'],
×
249
                    in: $parameter['in'],
×
250
                    description: $parameter['description'] ?? '',
×
251
                    required: $parameter['required'] ?? false,
×
252
                    deprecated: $parameter['deprecated'] ?? false,
×
253
                    allowEmptyValue: $parameter['allowEmptyValue'] ?? false,
×
254
                    schema: $parameter['schema'] ?? [],
×
255
                    style: $parameter['style'] ?? null,
×
256
                    explode: $parameter['explode'] ?? false,
×
257
                    allowReserved: $parameter['allowReserved '] ?? false,
×
258
                    example: $parameter['example'] ?? null,
×
259
                    examples: isset($parameter['examples']) ? new \ArrayObject($parameter['examples']) : null,
×
260
                    content: isset($parameter['content']) ? new \ArrayObject($parameter['content']) : null
×
261
                );
×
262
            }
263
            $resource['openapi']['parameters'] = $parameters;
×
264
        }
265

UNCOV
266
        return new OpenApiOperation(...$resource['openapi']);
×
267
    }
268

269
    /**
270
     * @return bool|string|string[]|null
271
     */
272
    private function buildMercure(array $resource): array|bool|string|null
273
    {
UNCOV
274
        if (!\array_key_exists('mercure', $resource)) {
×
UNCOV
275
            return null;
×
276
        }
277

278
        if (\is_string($resource['mercure'])) {
×
279
            return $this->phpize($resource, 'mercure', 'bool|string');
×
280
        }
281

282
        return $resource['mercure'];
×
283
    }
284

285
    private function buildMessenger(array $resource): bool|array|string|null
286
    {
UNCOV
287
        if (!\array_key_exists('messenger', $resource)) {
×
UNCOV
288
            return null;
×
289
        }
290

291
        return $this->phpize($resource, 'messenger', 'bool|string');
×
292
    }
293

294
    private function buildOperations(array $resource, array $root): ?array
295
    {
UNCOV
296
        if (!\array_key_exists('operations', $resource)) {
×
UNCOV
297
            return null;
×
298
        }
299

UNCOV
300
        $data = [];
×
UNCOV
301
        foreach ($resource['operations'] as $class => $operation) {
×
UNCOV
302
            if (null === $operation) {
×
UNCOV
303
                $operation = [];
×
304
            }
305

UNCOV
306
            if (\array_key_exists('class', $operation)) {
×
307
                if (!\array_key_exists('name', $operation) && \is_string($class)) {
×
308
                    $operation['name'] = $class;
×
309
                }
310
                $class = $operation['class'];
×
311
            }
312

UNCOV
313
            if (empty($class)) {
×
314
                throw new InvalidArgumentException('Missing "class" attribute');
×
315
            }
316

UNCOV
317
            if (!class_exists($class)) {
×
318
                throw new InvalidArgumentException(\sprintf('Operation class "%s" does not exist', $class));
×
319
            }
320

UNCOV
321
            $datum = $this->buildExtendedBase($operation);
×
UNCOV
322
            foreach ($datum as $key => $value) {
×
UNCOV
323
                if (null === $value) {
×
UNCOV
324
                    $datum[$key] = $root[$key];
×
325
                }
326
            }
327

UNCOV
328
            if (\in_array((string) $class, [GetCollection::class, Post::class], true)) {
×
UNCOV
329
                $datum['itemUriTemplate'] = $this->phpize($operation, 'itemUriTemplate', 'string');
×
UNCOV
330
            } elseif (isset($operation['itemUriTemplate'])) {
×
331
                throw new InvalidArgumentException(\sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $class));
×
332
            }
333

UNCOV
334
            $data[] = array_merge($datum, [
×
UNCOV
335
                'read' => $this->phpize($operation, 'read', 'bool'),
×
UNCOV
336
                'deserialize' => $this->phpize($operation, 'deserialize', 'bool'),
×
UNCOV
337
                'validate' => $this->phpize($operation, 'validate', 'bool'),
×
UNCOV
338
                'write' => $this->phpize($operation, 'write', 'bool'),
×
UNCOV
339
                'serialize' => $this->phpize($operation, 'serialize', 'bool'),
×
UNCOV
340
                'queryParameterValidate' => $this->phpize($operation, 'queryParameterValidate', 'bool'),
×
UNCOV
341
                'strictQueryParameterValidation' => $this->phpize($operation, 'strictQueryParameterValidation', 'bool'),
×
UNCOV
342
                'hideHydraOperation' => $this->phpize($resource, 'hideHydraOperation', 'bool'),
×
UNCOV
343
                'priority' => $this->phpize($operation, 'priority', 'integer'),
×
UNCOV
344
                'name' => $this->phpize($operation, 'name', 'string'),
×
UNCOV
345
                'class' => (string) $class,
×
UNCOV
346
            ]);
×
347
        }
348

UNCOV
349
        return $data;
×
350
    }
351

352
    private function buildGraphQlOperations(array $resource, array $root): ?array
353
    {
UNCOV
354
        if (!\array_key_exists('graphQlOperations', $resource) || !\is_array($resource['graphQlOperations'])) {
×
UNCOV
355
            return null;
×
356
        }
357

UNCOV
358
        $data = [];
×
UNCOV
359
        foreach ($resource['graphQlOperations'] as $class => $operation) {
×
360
            if (null === $operation) {
×
361
                $operation = [];
×
362
            }
363

364
            if (\array_key_exists('class', $operation)) {
×
365
                if (!\array_key_exists('name', $operation) && \is_string($class)) {
×
366
                    $operation['name'] = $class;
×
367
                }
368
                $class = $operation['class'];
×
369
            }
370

371
            if (empty($class)) {
×
372
                throw new InvalidArgumentException('Missing "class" attribute');
×
373
            }
374

375
            if (!class_exists($class)) {
×
376
                throw new InvalidArgumentException(\sprintf('Operation class "%s" does not exist', $class));
×
377
            }
378

379
            $datum = $this->buildBase($operation);
×
380
            foreach ($datum as $key => $value) {
×
381
                if (null === $value) {
×
382
                    $datum[$key] = $root[$key];
×
383
                }
384
            }
385

386
            $data[] = array_merge($datum, [
×
387
                'resolver' => $this->phpize($operation, 'resolver', 'string'),
×
388
                'args' => $operation['args'] ?? null,
×
389
                'extraArgs' => $operation['extraArgs'] ?? null,
×
390
                'class' => (string) $class,
×
391
                'read' => $this->phpize($operation, 'read', 'bool'),
×
392
                'deserialize' => $this->phpize($operation, 'deserialize', 'bool'),
×
393
                'validate' => $this->phpize($operation, 'validate', 'bool'),
×
394
                'write' => $this->phpize($operation, 'write', 'bool'),
×
395
                'serialize' => $this->phpize($operation, 'serialize', 'bool'),
×
396
                'priority' => $this->phpize($operation, 'priority', 'integer'),
×
397
                'name' => $this->phpize($operation, 'name', 'string'),
×
398
            ]);
×
399
        }
400

UNCOV
401
        return $data ?: null;
×
402
    }
403

404
    private function buildStateOptions(array $resource): ?OptionsInterface
405
    {
UNCOV
406
        $stateOptions = $resource['stateOptions'] ?? [];
×
UNCOV
407
        if (!\is_array($stateOptions)) {
×
408
            return null;
×
409
        }
410

UNCOV
411
        if (!$stateOptions) {
×
UNCOV
412
            return null;
×
413
        }
414

415
        $configuration = reset($stateOptions);
×
416
        switch (key($stateOptions)) {
×
417
            case 'elasticsearchOptions':
×
418
                if (class_exists(Options::class)) {
×
419
                    return new Options($configuration['index'] ?? null, $configuration['type'] ?? null);
×
420
                }
421
        }
422

423
        return null;
×
424
    }
425

426
    /**
427
     * @return Link[]
428
     */
429
    private function buildLinks(array $resource): ?array
430
    {
UNCOV
431
        if (!isset($resource['links']) || !\is_array($resource['links'])) {
×
UNCOV
432
            return null;
×
433
        }
434

435
        $links = [];
×
436
        foreach ($resource['links'] as $link) {
×
437
            $links[] = new Link(rel: $link['rel'], href: $link['href']);
×
438
        }
439

440
        return $links;
×
441
    }
442

443
    /**
444
     * @return array<string, string>
445
     */
446
    private function buildHeaders(array $resource): ?array
447
    {
UNCOV
448
        if (!isset($resource['headers']) || !\is_array($resource['headers'])) {
×
UNCOV
449
            return null;
×
450
        }
451

452
        $headers = [];
×
453
        foreach ($resource['headers'] as $key => $value) {
×
454
            $headers[$key] = $value;
×
455
        }
456

457
        return $headers;
×
458
    }
459

460
    /**
461
     * @return array<string, \ApiPlatform\Metadata\Parameter>
462
     */
463
    private function buildParameters(array $resource): ?array
464
    {
UNCOV
465
        if (!isset($resource['parameters']) || !\is_array($resource['parameters'])) {
×
UNCOV
466
            return null;
×
467
        }
468

469
        $parameters = [];
×
470
        foreach ($resource['parameters'] as $key => $parameter) {
×
471
            $cl = ($parameter['in'] ?? 'query') === 'header' ? HeaderParameter::class : QueryParameter::class;
×
472
            $parameters[$key] = new $cl(
×
473
                key: $key,
×
474
                required: $this->phpize($parameter, 'required', 'bool'),
×
475
                schema: $parameter['schema'] ?? null,
×
476
                openApi: ($parameter['openapi'] ?? null) ? new Parameter(
×
477
                    name: $parameter['openapi']['name'],
×
478
                    in: $parameter['in'] ?? 'query',
×
479
                    description: $parameter['openapi']['description'] ?? '',
×
480
                    required: $parameter['openapi']['required'] ?? $parameter['required'] ?? false,
×
481
                    deprecated: $parameter['openapi']['deprecated'] ?? false,
×
482
                    allowEmptyValue: $parameter['openapi']['allowEmptyValue'] ?? false,
×
483
                    schema: $parameter['openapi']['schema'] ?? $parameter['schema'] ?? [],
×
484
                    style: $parameter['openapi']['style'] ?? null,
×
485
                    explode: $parameter['openapi']['explode'] ?? false,
×
486
                    allowReserved: $parameter['openapi']['allowReserved '] ?? false,
×
487
                    example: $parameter['openapi']['example'] ?? null,
×
488
                    examples: isset($parameter['openapi']['examples']) ? new \ArrayObject($parameter['openapi']['examples']) : null,
×
489
                    content: isset($parameter['openapi']['content']) ? new \ArrayObject($parameter['openapi']['content']) : null
×
490
                ) : null,
×
491
                provider: $this->phpize($parameter, 'provider', 'string'),
×
492
                filter: $this->phpize($parameter, 'filter', 'string'),
×
493
                property: $this->phpize($parameter, 'property', 'string'),
×
494
                description: $this->phpize($parameter, 'description', 'string'),
×
495
                priority: $this->phpize($parameter, 'priority', 'integer'),
×
496
                extraProperties: $this->buildArrayValue($parameter, 'extraProperties') ?? [],
×
497
            );
×
498
        }
499

500
        return $parameters;
×
501
    }
502
}
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