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

api-platform / core / 17071323229

19 Aug 2025 01:36PM UTC coverage: 0.0%. First build
17071323229

Pull #7225

github

web-flow
Merge 1e726a585 into 020385253
Pull Request #7225: feat: json streamer

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

0 of 52230 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/HttpOperation.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;
15

16
use ApiPlatform\Metadata\Exception\ProblemExceptionInterface;
17
use ApiPlatform\OpenApi\Attributes\Webhook;
18
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
19
use ApiPlatform\State\OptionsInterface;
20
use Symfony\Component\WebLink\Link as WebLink;
21

22
class HttpOperation extends Operation
23
{
24
    public const METHOD_GET = 'GET';
25
    public const METHOD_POST = 'POST';
26
    public const METHOD_PUT = 'PUT';
27
    public const METHOD_PATCH = 'PATCH';
28
    public const METHOD_DELETE = 'DELETE';
29
    public const METHOD_HEAD = 'HEAD';
30
    public const METHOD_OPTIONS = 'OPTIONS';
31

32
    /** @var array<int|string, string|string[]>|null */
33
    protected $formats;
34
    /** @var array<int|string, string|string[]>|null */
35
    protected $inputFormats;
36
    /** @var array<int|string, string|string[]>|null */
37
    protected $outputFormats;
38

39
    /**
40
     * @param string[]|null                                  $types         the RDF types of this property
41
     * @param array<int|string, string|string[]>|string|null $formats       {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
42
     * @param array<int|string, string|string[]>|string|null $inputFormats  {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
43
     * @param array<int|string, string|string[]>|string|null $outputFormats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
44
     * @param array<string,array{
45
     *     0: string,
46
     *     1: string
47
     * }|array{
48
     *     from_property?: string,
49
     *     to_property?: string,
50
     *     from_class?: string,
51
     *     to_class?: string,
52
     *     identifiers?: string[],
53
     *     composite_identifier?: bool,
54
     *     expanded_value?: string,
55
     * }|Link>|string[]|string|null $uriVariables {@see https://api-platform.com/docs/core/subresources/}
56
     * @param string|null     $routePrefix {@see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations}
57
     * @param string|null     $sunset      {@see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed}
58
     * @param string|int|null $status      {@see https://api-platform.com/docs/core/operations/#configuring-operations}
59
     * @param array{
60
     *     max_age?: int,
61
     *     vary?: string|string[],
62
     *     public?: bool,
63
     *     shared_max_age?: int,
64
     *     stale_while_revalidate?: int,
65
     *     stale_if_error?: int,
66
     *     must_revalidate?: bool,
67
     *     proxy_revalidate?: bool,
68
     *     no_cache?: bool,
69
     *     no_store?: bool,
70
     *     no_transform?: bool,
71
     *     immutable?: bool,
72
     * }|null $cacheHeaders {@see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers}
73
     * @param array<string, string>|null $headers
74
     * @param array{
75
     *     field: string,
76
     *     direction: string,
77
     * }|null $paginationViaCursor {@see https://api-platform.com/docs/core/pagination/#cursor-based-pagination}
78
     * @param array|null $normalizationContext   {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
79
     * @param array|null $denormalizationContext {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
80
     * @param array|null $hydraContext           {@see https://api-platform.com/docs/core/extending-jsonld-context/#hydra}
81
     * @param array{
82
     *     class?: string|null,
83
     *     name?: string,
84
     * }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
85
     * @param array{
86
     *     class?: string|null,
87
     *     name?: string,
88
     * }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
89
     * @param string|array|bool|null                              $mercure   {@see https://api-platform.com/docs/core/mercure}
90
     * @param string|bool|null                                    $messenger {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus}
91
     * @param string|callable|null                                $provider  {@see https://api-platform.com/docs/core/state-providers/#state-providers}
92
     * @param string|callable|null                                $processor {@see https://api-platform.com/docs/core/state-processors/#state-processors}
93
     * @param WebLink[]|null                                      $links
94
     * @param array<class-string<ProblemExceptionInterface>>|null $errors
95
     */
96
    public function __construct(
97
        protected string $method = 'GET',
98
        protected ?string $uriTemplate = null,
99
        protected ?array $types = null,
100
        $formats = null,
101
        $inputFormats = null,
102
        $outputFormats = null,
103
        protected $uriVariables = null,
104
        protected ?string $routePrefix = null,
105
        protected ?string $routeName = null,
106
        protected ?array $defaults = null,
107
        protected ?array $requirements = null,
108
        protected ?array $options = null,
109
        protected ?bool $stateless = null,
110
        /**
111
         * The `sunset` option indicates when a deprecated operation will be removed.
112
         *
113
         * <div data-code-selector>
114
         *
115
         * ```php
116
         * <?php
117
         * // api/src/Entity/Parchment.php
118
         * use ApiPlatform\Metadata\Get;
119
         *
120
         * #[Get(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
121
         * class Parchment
122
         * {
123
         *     // ...
124
         * }
125
         * ```
126
         *
127
         * ```yaml
128
         * # api/config/api_platform/resources.yaml
129
         * resources:
130
         *     App\Entity\Parchment:
131
         *         - operations:
132
         *               ApiPlatform\Metadata\Get:
133
         *                   deprecationReason: 'Create a Book instead'
134
         *                   sunset: '01/01/2020'
135
         * ```
136
         *
137
         * ```xml
138
         * <?xml version="1.0" encoding="UTF-8" ?>
139
         * <!-- api/config/api_platform/resources.xml -->
140
         *
141
         * <resources
142
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
143
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
144
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
145
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
146
         *     <resource class="App\Entity\Parchment">
147
         *         <operations>
148
         *             <operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" sunset="01/01/2020" />
149
         *         <operations>
150
         *     </resource>
151
         * </resources>
152
         * ```
153
         *
154
         * </div>
155
         */
156
        protected ?string $sunset = null,
157
        protected ?string $acceptPatch = null,
158
        protected $status = null,
159
        protected ?string $host = null,
160
        protected ?array $schemes = null,
161
        protected ?string $condition = null,
162
        protected ?string $controller = null,
163
        protected ?array $headers = null,
164
        protected ?array $cacheHeaders = null,
165
        protected ?array $paginationViaCursor = null,
166
        protected ?array $hydraContext = null,
167
        protected bool|OpenApiOperation|Webhook|null $openapi = null,
168
        protected ?array $exceptionToStatus = null,
169
        protected ?array $links = null,
170
        protected ?array $errors = null,
171
        protected ?bool $strictQueryParameterValidation = null,
172
        protected ?bool $hideHydraOperation = null,
173

174
        ?string $shortName = null,
175
        ?string $class = null,
176
        ?bool $paginationEnabled = null,
177
        ?string $paginationType = null,
178
        ?int $paginationItemsPerPage = null,
179
        ?int $paginationMaximumItemsPerPage = null,
180
        ?bool $paginationPartial = null,
181
        ?bool $paginationClientEnabled = null,
182
        ?bool $paginationClientItemsPerPage = null,
183
        ?bool $paginationClientPartial = null,
184
        ?bool $paginationFetchJoinCollection = null,
185
        ?bool $paginationUseOutputWalkers = null,
186
        ?array $order = null,
187
        ?string $description = null,
188
        ?array $normalizationContext = null,
189
        ?array $denormalizationContext = null,
190
        ?bool $collectDenormalizationErrors = null,
191
        string|\Stringable|null $security = null,
192
        ?string $securityMessage = null,
193
        string|\Stringable|null $securityPostDenormalize = null,
194
        ?string $securityPostDenormalizeMessage = null,
195
        string|\Stringable|null $securityPostValidation = null,
196
        ?string $securityPostValidationMessage = null,
197
        ?string $deprecationReason = null,
198
        ?array $filters = null,
199
        ?array $validationContext = null,
200
        $input = null,
201
        $output = null,
202
        $mercure = null,
203
        $messenger = null,
204
        ?int $urlGenerationStrategy = null,
205
        ?bool $read = null,
206
        ?bool $deserialize = null,
207
        ?bool $validate = null,
208
        ?bool $write = null,
209
        ?bool $serialize = null,
210
        ?bool $fetchPartial = null,
211
        ?bool $forceEager = null,
212
        ?int $priority = null,
213
        ?string $name = null,
214
        $provider = null,
215
        $processor = null,
216
        ?OptionsInterface $stateOptions = null,
217
        array|Parameters|null $parameters = null,
218
        array|string|null $rules = null,
219
        ?string $policy = null,
220
        array|string|null $middleware = null,
221
        ?bool $queryParameterValidationEnabled = null,
222
        ?bool $jsonStream = null,
223
        array $extraProperties = [],
224
    ) {
225
        $this->formats = (null === $formats || \is_array($formats)) ? $formats : [$formats];
×
226
        $this->inputFormats = (null === $inputFormats || \is_array($inputFormats)) ? $inputFormats : [$inputFormats];
×
227
        $this->outputFormats = (null === $outputFormats || \is_array($outputFormats)) ? $outputFormats : [$outputFormats];
×
228

229
        parent::__construct(
×
230
            shortName: $shortName,
×
231
            class: $class,
×
232
            paginationEnabled: $paginationEnabled,
×
233
            paginationType: $paginationType,
×
234
            paginationItemsPerPage: $paginationItemsPerPage,
×
235
            paginationMaximumItemsPerPage: $paginationMaximumItemsPerPage,
×
236
            paginationPartial: $paginationPartial,
×
237
            paginationClientEnabled: $paginationClientEnabled,
×
238
            paginationClientItemsPerPage: $paginationClientItemsPerPage,
×
239
            paginationClientPartial: $paginationClientPartial,
×
240
            paginationFetchJoinCollection: $paginationFetchJoinCollection,
×
241
            paginationUseOutputWalkers: $paginationUseOutputWalkers,
×
242
            order: $order,
×
243
            description: $description,
×
244
            normalizationContext: $normalizationContext,
×
245
            denormalizationContext: $denormalizationContext,
×
246
            collectDenormalizationErrors: $collectDenormalizationErrors,
×
247
            security: $security,
×
248
            securityMessage: $securityMessage,
×
249
            securityPostDenormalize: $securityPostDenormalize,
×
250
            securityPostDenormalizeMessage: $securityPostDenormalizeMessage,
×
251
            securityPostValidation: $securityPostValidation,
×
252
            securityPostValidationMessage: $securityPostValidationMessage,
×
253
            deprecationReason: $deprecationReason,
×
254
            filters: $filters,
×
255
            validationContext: $validationContext,
×
256
            input: $input,
×
257
            output: $output,
×
258
            mercure: $mercure,
×
259
            messenger: $messenger,
×
260
            urlGenerationStrategy: $urlGenerationStrategy,
×
261
            read: $read,
×
262
            deserialize: $deserialize,
×
263
            validate: $validate,
×
264
            write: $write,
×
265
            serialize: $serialize,
×
266
            fetchPartial: $fetchPartial,
×
267
            forceEager: $forceEager,
×
268
            priority: $priority,
×
269
            name: $name,
×
270
            provider: $provider,
×
271
            processor: $processor,
×
272
            stateOptions: $stateOptions,
×
273
            parameters: $parameters,
×
274
            rules: $rules,
×
275
            policy: $policy,
×
276
            middleware: $middleware,
×
277
            queryParameterValidationEnabled: $queryParameterValidationEnabled,
×
278
            strictQueryParameterValidation: $strictQueryParameterValidation,
×
279
            hideHydraOperation: $hideHydraOperation,
×
NEW
280
            jsonStream: $jsonStream,
×
281
            extraProperties: $extraProperties
×
282
        );
×
283
    }
284

285
    public function getMethod(): string
286
    {
287
        return $this->method;
×
288
    }
289

290
    public function withMethod(string $method): static
291
    {
292
        $self = clone $this;
×
293
        $self->method = $method;
×
294

295
        return $self;
×
296
    }
297

298
    public function getUriTemplate(): ?string
299
    {
300
        return $this->uriTemplate;
×
301
    }
302

303
    public function withUriTemplate(?string $uriTemplate = null): static
304
    {
305
        $self = clone $this;
×
306
        $self->uriTemplate = $uriTemplate;
×
307

308
        return $self;
×
309
    }
310

311
    public function getTypes(): ?array
312
    {
313
        return $this->types;
×
314
    }
315

316
    /**
317
     * @param string[]|string $types
318
     */
319
    public function withTypes($types): static
320
    {
321
        $self = clone $this;
×
322
        $self->types = (array) $types;
×
323

324
        return $self;
×
325
    }
326

327
    /**
328
     * @return array<int|string, string|string[]>|null
329
     */
330
    public function getFormats()
331
    {
332
        return $this->formats;
×
333
    }
334

335
    /**
336
     * @param array<int|string, string|string[]>|string|null $formats
337
     */
338
    public function withFormats($formats = null): static
339
    {
340
        $self = clone $this;
×
341
        $self->formats = (null === $formats || \is_array($formats)) ? $formats : [$formats];
×
342

343
        return $self;
×
344
    }
345

346
    /**
347
     * @return array<int|string, string|string[]>|null
348
     */
349
    public function getInputFormats()
350
    {
351
        return $this->inputFormats;
×
352
    }
353

354
    /**
355
     * @param array<int|string, string|string[]>|string|null $inputFormats
356
     */
357
    public function withInputFormats($inputFormats = null): static
358
    {
359
        $self = clone $this;
×
360
        $self->inputFormats = (null === $inputFormats || \is_array($inputFormats)) ? $inputFormats : [$inputFormats];
×
361

362
        return $self;
×
363
    }
364

365
    /**
366
     * @return array<int|string, string|string[]>|null
367
     */
368
    public function getOutputFormats()
369
    {
370
        return $this->outputFormats;
×
371
    }
372

373
    /**
374
     * @param array<int|string, string|string[]>|string|null $outputFormats
375
     */
376
    public function withOutputFormats($outputFormats = null): static
377
    {
378
        $self = clone $this;
×
379
        $self->outputFormats = (null === $outputFormats || \is_array($outputFormats)) ? $outputFormats : [$outputFormats];
×
380

381
        return $self;
×
382
    }
383

384
    /**
385
     * @return array<string, mixed>|array<int, Link>|list<string>|null
386
     */
387
    public function getUriVariables()
388
    {
389
        return $this->uriVariables;
×
390
    }
391

392
    /**
393
     * @param array<string, mixed>|array<int, Link>|list<string> $uriVariables
394
     */
395
    public function withUriVariables($uriVariables): static
396
    {
397
        $self = clone $this;
×
398
        $self->uriVariables = $uriVariables;
×
399

400
        return $self;
×
401
    }
402

403
    public function getRoutePrefix(): ?string
404
    {
405
        return $this->routePrefix;
×
406
    }
407

408
    public function withRoutePrefix(string $routePrefix): static
409
    {
410
        $self = clone $this;
×
411
        $self->routePrefix = $routePrefix;
×
412

413
        return $self;
×
414
    }
415

416
    public function getRouteName(): ?string
417
    {
418
        return $this->routeName;
×
419
    }
420

421
    public function withRouteName(?string $routeName): static
422
    {
423
        $self = clone $this;
×
424
        $self->routeName = $routeName;
×
425

426
        return $self;
×
427
    }
428

429
    public function getDefaults(): ?array
430
    {
431
        return $this->defaults;
×
432
    }
433

434
    public function withDefaults(array $defaults): static
435
    {
436
        $self = clone $this;
×
437
        $self->defaults = $defaults;
×
438

439
        return $self;
×
440
    }
441

442
    public function getRequirements(): ?array
443
    {
444
        return $this->requirements;
×
445
    }
446

447
    public function withRequirements(array $requirements): static
448
    {
449
        $self = clone $this;
×
450
        $self->requirements = $requirements;
×
451

452
        return $self;
×
453
    }
454

455
    public function getOptions(): ?array
456
    {
457
        return $this->options;
×
458
    }
459

460
    public function withOptions(array $options): static
461
    {
462
        $self = clone $this;
×
463
        $self->options = $options;
×
464

465
        return $self;
×
466
    }
467

468
    public function getStateless(): ?bool
469
    {
470
        return $this->stateless;
×
471
    }
472

473
    /**
474
     * @param bool $stateless
475
     */
476
    public function withStateless($stateless): static
477
    {
478
        $self = clone $this;
×
479
        $self->stateless = $stateless;
×
480

481
        return $self;
×
482
    }
483

484
    public function getSunset(): ?string
485
    {
486
        return $this->sunset;
×
487
    }
488

489
    public function withSunset(string $sunset): static
490
    {
491
        $self = clone $this;
×
492
        $self->sunset = $sunset;
×
493

494
        return $self;
×
495
    }
496

497
    public function getAcceptPatch(): ?string
498
    {
499
        return $this->acceptPatch;
×
500
    }
501

502
    public function withAcceptPatch(string $acceptPatch): static
503
    {
504
        $self = clone $this;
×
505
        $self->acceptPatch = $acceptPatch;
×
506

507
        return $self;
×
508
    }
509

510
    public function getStatus(): ?int
511
    {
512
        return $this->status;
×
513
    }
514

515
    public function withStatus(int $status): static
516
    {
517
        $self = clone $this;
×
518
        $self->status = $status;
×
519

520
        return $self;
×
521
    }
522

523
    public function getHost(): ?string
524
    {
525
        return $this->host;
×
526
    }
527

528
    public function withHost(string $host): static
529
    {
530
        $self = clone $this;
×
531
        $self->host = $host;
×
532

533
        return $self;
×
534
    }
535

536
    public function getSchemes(): ?array
537
    {
538
        return $this->schemes;
×
539
    }
540

541
    public function withSchemes(array $schemes): static
542
    {
543
        $self = clone $this;
×
544
        $self->schemes = $schemes;
×
545

546
        return $self;
×
547
    }
548

549
    public function getCondition(): ?string
550
    {
551
        return $this->condition;
×
552
    }
553

554
    public function withCondition(string $condition): static
555
    {
556
        $self = clone $this;
×
557
        $self->condition = $condition;
×
558

559
        return $self;
×
560
    }
561

562
    public function getController(): ?string
563
    {
564
        return $this->controller;
×
565
    }
566

567
    public function withController(string $controller): static
568
    {
569
        $self = clone $this;
×
570
        $self->controller = $controller;
×
571

572
        return $self;
×
573
    }
574

575
    public function getHeaders(): ?array
576
    {
577
        return $this->headers;
×
578
    }
579

580
    public function withHeaders(array $headers): static
581
    {
582
        $self = clone $this;
×
583
        $self->headers = $headers;
×
584

585
        return $self;
×
586
    }
587

588
    public function getCacheHeaders(): ?array
589
    {
590
        return $this->cacheHeaders;
×
591
    }
592

593
    public function withCacheHeaders(array $cacheHeaders): static
594
    {
595
        $self = clone $this;
×
596
        $self->cacheHeaders = $cacheHeaders;
×
597

598
        return $self;
×
599
    }
600

601
    public function getPaginationViaCursor(): ?array
602
    {
603
        return $this->paginationViaCursor;
×
604
    }
605

606
    public function withPaginationViaCursor(array $paginationViaCursor): static
607
    {
608
        $self = clone $this;
×
609
        $self->paginationViaCursor = $paginationViaCursor;
×
610

611
        return $self;
×
612
    }
613

614
    public function getHydraContext(): ?array
615
    {
616
        return $this->hydraContext;
×
617
    }
618

619
    public function withHydraContext(array $hydraContext): static
620
    {
621
        $self = clone $this;
×
622
        $self->hydraContext = $hydraContext;
×
623

624
        return $self;
×
625
    }
626

627
    public function getOpenapi(): bool|OpenApiOperation|Webhook|null
628
    {
629
        return $this->openapi;
×
630
    }
631

632
    public function withOpenapi(bool|OpenApiOperation|Webhook $openapi): static
633
    {
634
        $self = clone $this;
×
635
        $self->openapi = $openapi;
×
636

637
        return $self;
×
638
    }
639

640
    public function getExceptionToStatus(): ?array
641
    {
642
        return $this->exceptionToStatus;
×
643
    }
644

645
    public function withExceptionToStatus(array $exceptionToStatus): static
646
    {
647
        $self = clone $this;
×
648
        $self->exceptionToStatus = $exceptionToStatus;
×
649

650
        return $self;
×
651
    }
652

653
    public function getLinks(): ?array
654
    {
655
        return $this->links;
×
656
    }
657

658
    /**
659
     * @param WebLink[] $links
660
     */
661
    public function withLinks(array $links): static
662
    {
663
        $self = clone $this;
×
664
        $self->links = $links;
×
665

666
        return $self;
×
667
    }
668

669
    public function getErrors(): ?array
670
    {
671
        return $this->errors;
×
672
    }
673

674
    /**
675
     * @param class-string<ProblemExceptionInterface>[] $errors
676
     */
677
    public function withErrors(array $errors): static
678
    {
679
        $self = clone $this;
×
680
        $self->errors = $errors;
×
681

682
        return $self;
×
683
    }
684
}
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