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

api-platform / core / 3712739783

pending completion
3712739783

Pull #5254

github

GitHub
Merge 9dfa88fa6 into ac711530f
Pull Request #5254: [OpenApi] Add ApiResource::openapi and deprecate openapiContext

199 of 199 new or added lines in 6 files covered. (100.0%)

7494 of 12363 relevant lines covered (60.62%)

67.55 hits per line

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

73.65
/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\OpenApi\Model\Operation as OpenApiOperation;
17

18
class HttpOperation extends Operation
19
{
20
    public const METHOD_GET = 'GET';
21
    public const METHOD_POST = 'POST';
22
    public const METHOD_PUT = 'PUT';
23
    public const METHOD_PATCH = 'PATCH';
24
    public const METHOD_DELETE = 'DELETE';
25
    public const METHOD_HEAD = 'HEAD';
26
    public const METHOD_OPTIONS = 'OPTIONS';
27

28
    /**
29
     * @param array|null                                                      $types                          the RDF types of this property
30
     * @param array|string|null                                               $formats                        https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
31
     * @param array|string|null                                               $inputFormats                   https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
32
     * @param array|string|null                                               $outputFormats                  https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
33
     * @param array<string, Link>|array<string, mixed[]>|string[]|string|null $uriVariables
34
     * @param string|null                                                     $routePrefix                    https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations
35
     * @param string|null                                                     $sunset                         https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed
36
     * @param string|int|null                                                 $status
37
     * @param string|null                                                     $deprecationReason              https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
38
     * @param array|null                                                      $cacheHeaders                   https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers
39
     * @param array|null                                                      $normalizationContext           https://api-platform.com/docs/core/serialization/#using-serialization-groups
40
     * @param array|null                                                      $denormalizationContext         https://api-platform.com/docs/core/serialization/#using-serialization-groups
41
     * @param string[]                                                        $hydraContext                   https://api-platform.com/docs/core/extending-jsonld-context/#hydra
42
     * @param array|null                                                      $openapiContext                 https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
43
     * @param bool|OpenApiOperation|null                                      $openapi                        https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
44
     * @param string[]|null                                                   $filters                        https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters
45
     * @param bool|null                                                       $elasticsearch                  https://api-platform.com/docs/core/elasticsearch/
46
     * @param mixed|null                                                      $mercure                        https://api-platform.com/docs/core/mercure
47
     * @param mixed|null                                                      $messenger                      https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus
48
     * @param mixed|null                                                      $input                          https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
49
     * @param mixed|null                                                      $output                         https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
50
     * @param array|null                                                      $order                          https://api-platform.com/docs/core/default-order/#overriding-default-order
51
     * @param bool|null                                                       $fetchPartial                   https://api-platform.com/docs/core/performance/#fetch-partial
52
     * @param bool|null                                                       $forceEager                     https://api-platform.com/docs/core/performance/#force-eager
53
     * @param bool|null                                                       $paginationClientEnabled        https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1
54
     * @param bool|null                                                       $paginationClientItemsPerPage   https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3
55
     * @param bool|null                                                       $paginationClientPartial        https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6
56
     * @param array|null                                                      $paginationViaCursor            https://api-platform.com/docs/core/pagination/#cursor-based-pagination
57
     * @param bool|null                                                       $paginationEnabled              https://api-platform.com/docs/core/pagination/#for-a-specific-resource
58
     * @param bool|null                                                       $paginationFetchJoinCollection  https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
59
     * @param int|null                                                        $paginationItemsPerPage         https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page
60
     * @param int|null                                                        $paginationMaximumItemsPerPage  https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page
61
     * @param bool|null                                                       $paginationPartial              https://api-platform.com/docs/core/performance/#partial-pagination
62
     * @param string|null                                                     $paginationType                 https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination
63
     * @param string|null                                                     $security                       https://api-platform.com/docs/core/security
64
     * @param string|null                                                     $securityMessage                https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
65
     * @param string|null                                                     $securityPostDenormalize        https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
66
     * @param string|null                                                     $securityPostDenormalizeMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
67
     * @param bool|null                                                       $read                           https://api-platform.com/docs/core/events/#the-event-system
68
     * @param bool|null                                                       $deserialize                    https://api-platform.com/docs/core/events/#the-event-system
69
     * @param bool|null                                                       $validate                       https://api-platform.com/docs/core/events/#the-event-system
70
     * @param bool|null                                                       $write                          https://api-platform.com/docs/core/events/#the-event-system
71
     * @param bool|null                                                       $serialize                      https://api-platform.com/docs/core/events/#the-event-system
72
     * @param mixed|null                                                      $provider
73
     * @param mixed|null                                                      $processor
74
     */
75
    public function __construct(
76
        protected string $method = self::METHOD_GET,
77
        protected ?string $uriTemplate = null,
78
        protected ?array $types = null,
79
        protected $formats = null,
80
        protected $inputFormats = null,
81
        protected $outputFormats = null,
82
        protected $uriVariables = null,
83
        protected ?string $routePrefix = null,
84
        protected ?string $routeName = null,
85
        protected ?array $defaults = null,
86
        protected ?array $requirements = null,
87
        protected ?array $options = null,
88
        protected ?bool $stateless = null,
89
        protected ?string $sunset = null,
90
        protected ?string $acceptPatch = null,
91
        protected $status = null,
92
        protected ?string $host = null,
93
        protected ?array $schemes = null,
94
        protected ?string $condition = null,
95
        protected ?string $controller = null,
96
        protected ?array $cacheHeaders = null,
97

98
        protected ?array $hydraContext = null,
99
        protected ?array $openapiContext = null, // TODO Remove in 4.0
100
        protected bool|OpenApiOperation|null $openapi = null,
101
        protected ?array $exceptionToStatus = null,
102

103
        protected ?bool $queryParameterValidationEnabled = null,
104

105
        // abstract operation arguments
106
        ?string $shortName = null,
107
        ?string $class = null,
108
        ?bool $paginationEnabled = null,
109
        ?string $paginationType = null,
110
        ?int $paginationItemsPerPage = null,
111
        ?int $paginationMaximumItemsPerPage = null,
112
        ?bool $paginationPartial = null,
113
        ?bool $paginationClientEnabled = null,
114
        ?bool $paginationClientItemsPerPage = null,
115
        ?bool $paginationClientPartial = null,
116
        ?bool $paginationFetchJoinCollection = null,
117
        ?bool $paginationUseOutputWalkers = null,
118
        ?array $paginationViaCursor = null,
119
        ?array $order = null,
120
        ?string $description = null,
121
        ?array $normalizationContext = null,
122
        ?array $denormalizationContext = null,
123
        ?string $security = null,
124
        ?string $securityMessage = null,
125
        ?string $securityPostDenormalize = null,
126
        ?string $securityPostDenormalizeMessage = null,
127
        ?string $securityPostValidation = null,
128
        ?string $securityPostValidationMessage = null,
129
        ?string $deprecationReason = null,
130
        ?array $filters = null,
131
        ?array $validationContext = null,
132
        $input = null,
133
        $output = null,
134
        $mercure = null,
135
        $messenger = null,
136
        ?bool $elasticsearch = null,
137
        ?int $urlGenerationStrategy = null,
138
        ?bool $read = null,
139
        ?bool $deserialize = null,
140
        ?bool $validate = null,
141
        ?bool $write = null,
142
        ?bool $serialize = null,
143
        ?bool $fetchPartial = null,
144
        ?bool $forceEager = null,
145
        ?int $priority = null,
146
        ?string $name = null,
147
        $provider = null,
148
        $processor = null,
149
        array $extraProperties = []
150
    ) {
151
        $this->shortName = $shortName;
437✔
152
        $this->description = $description;
437✔
153
        $this->class = $class;
437✔
154
        $this->urlGenerationStrategy = $urlGenerationStrategy;
437✔
155
        $this->deprecationReason = $deprecationReason;
437✔
156
        $this->normalizationContext = $normalizationContext;
437✔
157
        $this->denormalizationContext = $denormalizationContext;
437✔
158
        $this->validationContext = $validationContext;
437✔
159
        $this->filters = $filters;
437✔
160
        $this->elasticsearch = $elasticsearch;
437✔
161
        $this->mercure = $mercure;
437✔
162
        $this->messenger = $messenger;
437✔
163
        $this->input = $input;
437✔
164
        $this->output = $output;
437✔
165
        $this->order = $order;
437✔
166
        $this->fetchPartial = $fetchPartial;
437✔
167
        $this->forceEager = $forceEager;
437✔
168
        $this->paginationClientEnabled = $paginationClientEnabled;
437✔
169
        $this->paginationClientItemsPerPage = $paginationClientItemsPerPage;
437✔
170
        $this->paginationClientPartial = $paginationClientPartial;
437✔
171
        $this->paginationViaCursor = $paginationViaCursor;
437✔
172
        $this->paginationEnabled = $paginationEnabled;
437✔
173
        $this->paginationFetchJoinCollection = $paginationFetchJoinCollection;
437✔
174
        $this->paginationUseOutputWalkers = $paginationUseOutputWalkers;
437✔
175
        $this->paginationItemsPerPage = $paginationItemsPerPage;
437✔
176
        $this->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
437✔
177
        $this->paginationPartial = $paginationPartial;
437✔
178
        $this->paginationType = $paginationType;
437✔
179
        $this->security = $security;
437✔
180
        $this->securityMessage = $securityMessage;
437✔
181
        $this->securityPostDenormalize = $securityPostDenormalize;
437✔
182
        $this->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
437✔
183
        $this->securityPostValidation = $securityPostValidation;
437✔
184
        $this->securityPostValidationMessage = $securityPostValidationMessage;
437✔
185
        $this->read = $read;
437✔
186
        $this->deserialize = $deserialize;
437✔
187
        $this->validate = $validate;
437✔
188
        $this->write = $write;
437✔
189
        $this->serialize = $serialize;
437✔
190
        $this->priority = $priority;
437✔
191
        $this->name = $name;
437✔
192
        $this->provider = $provider;
437✔
193
        $this->processor = $processor;
437✔
194
        $this->extraProperties = $extraProperties;
437✔
195
    }
196

197
    public function getMethod(): ?string
198
    {
199
        return $this->method;
644✔
200
    }
201

202
    public function withMethod(string $method): self
203
    {
204
        $self = clone $this;
×
205
        $self->method = $method;
×
206

207
        return $self;
×
208
    }
209

210
    public function getUriTemplate(): ?string
211
    {
212
        return $this->uriTemplate;
632✔
213
    }
214

215
    public function withUriTemplate(?string $uriTemplate = null)
216
    {
217
        $self = clone $this;
20✔
218
        $self->uriTemplate = $uriTemplate;
20✔
219

220
        return $self;
20✔
221
    }
222

223
    public function getTypes(): ?array
224
    {
225
        return $this->types;
499✔
226
    }
227

228
    /**
229
     * @param string[]|string $types
230
     */
231
    public function withTypes($types): self
232
    {
233
        $self = clone $this;
4✔
234
        $self->types = (array) $types;
4✔
235

236
        return $self;
4✔
237
    }
238

239
    /**
240
     * @return array|mixed|string|null
241
     */
242
    public function getFormats()
243
    {
244
        return $this->formats;
20✔
245
    }
246

247
    public function withFormats($formats = null): self
248
    {
249
        $self = clone $this;
1✔
250
        $self->formats = $formats;
1✔
251

252
        return $self;
1✔
253
    }
254

255
    /**
256
     * @return array|mixed|string|null
257
     */
258
    public function getInputFormats()
259
    {
260
        return $this->inputFormats;
185✔
261
    }
262

263
    public function withInputFormats($inputFormats = null): self
264
    {
265
        $self = clone $this;
20✔
266
        $self->inputFormats = $inputFormats;
20✔
267

268
        return $self;
20✔
269
    }
270

271
    /**
272
     * @return array|mixed|string|null
273
     */
274
    public function getOutputFormats()
275
    {
276
        return $this->outputFormats;
507✔
277
    }
278

279
    public function withOutputFormats($outputFormats = null): self
280
    {
281
        $self = clone $this;
20✔
282
        $self->outputFormats = $outputFormats;
20✔
283

284
        return $self;
20✔
285
    }
286

287
    /**
288
     * @return array<string, Link>|array<string, array>|string[]|string|null
289
     */
290
    public function getUriVariables()
291
    {
292
        return $this->uriVariables;
587✔
293
    }
294

295
    /**
296
     * @param array<string, Link>|array<string, array>|string[]|string $uriVariables
297
     */
298
    public function withUriVariables($uriVariables): self
299
    {
300
        $self = clone $this;
20✔
301
        $self->uriVariables = $uriVariables;
20✔
302

303
        return $self;
20✔
304
    }
305

306
    public function getRoutePrefix(): ?string
307
    {
308
        return $this->routePrefix;
24✔
309
    }
310

311
    public function withRoutePrefix(string $routePrefix): self
312
    {
313
        $self = clone $this;
1✔
314
        $self->routePrefix = $routePrefix;
1✔
315

316
        return $self;
1✔
317
    }
318

319
    public function getRouteName(): ?string
320
    {
321
        return $this->routeName;
24✔
322
    }
323

324
    public function withRouteName(?string $routeName): self
325
    {
326
        $self = clone $this;
×
327
        $self->routeName = $routeName;
×
328

329
        return $self;
×
330
    }
331

332
    public function getDefaults(): ?array
333
    {
334
        return $this->defaults;
24✔
335
    }
336

337
    public function withDefaults(array $defaults): self
338
    {
339
        $self = clone $this;
×
340
        $self->defaults = $defaults;
×
341

342
        return $self;
×
343
    }
344

345
    public function getRequirements(): ?array
346
    {
347
        return $this->requirements;
24✔
348
    }
349

350
    public function withRequirements(array $requirements): self
351
    {
352
        $self = clone $this;
×
353
        $self->requirements = $requirements;
×
354

355
        return $self;
×
356
    }
357

358
    public function getOptions(): ?array
359
    {
360
        return $this->options;
24✔
361
    }
362

363
    public function withOptions(array $options): self
364
    {
365
        $self = clone $this;
×
366
        $self->options = $options;
×
367

368
        return $self;
×
369
    }
370

371
    public function getStateless(): ?bool
372
    {
373
        return $this->stateless;
24✔
374
    }
375

376
    public function withStateless($stateless): self
377
    {
378
        $self = clone $this;
×
379
        $self->stateless = $stateless;
×
380

381
        return $self;
×
382
    }
383

384
    public function getSunset(): ?string
385
    {
386
        return $this->sunset;
446✔
387
    }
388

389
    public function withSunset(string $sunset): self
390
    {
391
        $self = clone $this;
1✔
392
        $self->sunset = $sunset;
1✔
393

394
        return $self;
1✔
395
    }
396

397
    public function getAcceptPatch(): ?string
398
    {
399
        return $this->acceptPatch;
446✔
400
    }
401

402
    public function withAcceptPatch(string $acceptPatch): self
403
    {
404
        $self = clone $this;
16✔
405
        $self->acceptPatch = $acceptPatch;
16✔
406

407
        return $self;
16✔
408
    }
409

410
    public function getStatus(): ?int
411
    {
412
        return $this->status;
540✔
413
    }
414

415
    public function withStatus(int $status): self
416
    {
417
        $self = clone $this;
7✔
418
        $self->status = $status;
7✔
419

420
        return $self;
7✔
421
    }
422

423
    public function getHost(): ?string
424
    {
425
        return $this->host;
24✔
426
    }
427

428
    public function withHost(string $host): self
429
    {
430
        $self = clone $this;
×
431
        $self->host = $host;
×
432

433
        return $self;
×
434
    }
435

436
    public function getSchemes(): ?array
437
    {
438
        return $this->schemes;
24✔
439
    }
440

441
    public function withSchemes(array $schemes): self
442
    {
443
        $self = clone $this;
×
444
        $self->schemes = $schemes;
×
445

446
        return $self;
×
447
    }
448

449
    public function getCondition(): ?string
450
    {
451
        return $this->condition;
24✔
452
    }
453

454
    public function withCondition(string $condition): self
455
    {
456
        $self = clone $this;
×
457
        $self->condition = $condition;
×
458

459
        return $self;
×
460
    }
461

462
    public function getController(): ?string
463
    {
464
        return $this->controller;
24✔
465
    }
466

467
    public function withController(string $controller): self
468
    {
469
        $self = clone $this;
×
470
        $self->controller = $controller;
×
471

472
        return $self;
×
473
    }
474

475
    public function getCacheHeaders(): ?array
476
    {
477
        return $this->cacheHeaders;
310✔
478
    }
479

480
    public function withCacheHeaders(array $cacheHeaders): self
481
    {
482
        $self = clone $this;
20✔
483
        $self->cacheHeaders = $cacheHeaders;
20✔
484

485
        return $self;
20✔
486
    }
487

488
    /**
489
     * @return string[]
490
     */
491
    public function getHydraContext(): ?array
492
    {
493
        return $this->hydraContext;
24✔
494
    }
495

496
    public function withHydraContext(array $hydraContext): self
497
    {
498
        $self = clone $this;
1✔
499
        $self->hydraContext = $hydraContext;
1✔
500

501
        return $self;
1✔
502
    }
503

504
    /**
505
     * TODO Remove in 4.0.
506
     *
507
     * @deprecated
508
     */
509
    public function getOpenapiContext(): ?array
510
    {
511
        return $this->openapiContext;
24✔
512
    }
513

514
    /**
515
     * TODO Remove in 4.0.
516
     *
517
     * @deprecated
518
     */
519
    public function withOpenapiContext(array $openapiContext): self
520
    {
521
        $self = clone $this;
1✔
522
        $self->openapiContext = $openapiContext;
1✔
523

524
        return $self;
1✔
525
    }
526

527
    public function getOpenapi(): bool|OpenApiOperation|null
528
    {
529
        return $this->openapi;
24✔
530
    }
531

532
    public function withOpenapi(bool|OpenApiOperation $openapi): self
533
    {
534
        $self = clone $this;
×
535
        $self->openapi = $openapi;
×
536

537
        return $self;
×
538
    }
539

540
    public function getExceptionToStatus(): ?array
541
    {
542
        return $this->exceptionToStatus;
65✔
543
    }
544

545
    public function withExceptionToStatus(array $exceptionToStatus): self
546
    {
547
        $self = clone $this;
×
548
        $self->exceptionToStatus = $exceptionToStatus;
×
549

550
        return $self;
×
551
    }
552

553
    public function getQueryParameterValidationEnabled(): ?bool
554
    {
555
        return $this->queryParameterValidationEnabled;
325✔
556
    }
557

558
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): self
559
    {
560
        $self = clone $this;
×
561
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
562

563
        return $self;
×
564
    }
565
}
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