| 1 |
<?php declare(strict_types=1); |
| 2 |
|
| 3 |
/** |
| 4 |
* @license Apache 2.0 |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace OpenApi\Attributes; |
| 8 |
|
| 9 |
use OpenApi\Generator; |
| 10 |
|
| 11 |
trait ParameterTrait |
| 12 |
{ |
| 13 |
/** |
| 14 |
* @param 'query'|'header'|'path'|'cookie'|null $in |
| 15 |
* @param string|class-string|object|null $ref |
| 16 |
* @param array<Examples> $examples |
| 17 |
* @param array<MediaType>|JsonContent|XmlContent|Attachable|null $content |
| 18 |
* @param array<string,mixed>|null $x |
| 19 |
* @param list<Attachable>|null $attachables |
| 20 |
*/ |
| 21 |
public function __construct( |
| 22 |
?string $parameter = null, |
| 23 |
?string $name = null, |
| 24 |
?string $description = Generator::UNDEFINED, |
| 25 |
?string $in = null, |
| 26 |
?bool $required = null, |
| 27 |
?bool $deprecated = null, |
| 28 |
?bool $allowEmptyValue = null, |
| 29 |
string|object|null $ref = null, |
| 30 |
?Schema $schema = null, |
| 31 |
mixed $example = Generator::UNDEFINED, |
| 32 |
?array $examples = null, |
| 33 |
array|JsonContent|XmlContent|Attachable|null $content = null, |
| 34 |
?string $style = null, |
| 35 |
?bool $explode = null, |
| 36 |
?bool $allowReserved = null, |
| 37 |
?array $spaceDelimited = null, |
| 38 |
?array $pipeDelimited = null, |
| 39 |
mixed $deepObject = null, |
| 40 |
|
| 41 |
// abstract annotation |
| 42 |
?array $x = null, |
| 43 |
?array $attachables = null |
| 44 |
) { |
| 45 |
parent::__construct([ |
| 46 |
'parameter' => $parameter ?? Generator::UNDEFINED, |
| 47 |
'name' => $name ?? Generator::UNDEFINED, |
| 48 |
'description' => $description, |
| 49 |
// next two are special as we override the default value for specific Parameter subclasses |
| 50 |
'in' => $in ?? (Generator::isDefault($this->in) ? Generator::UNDEFINED : $this->in), |
| 51 |
'required' => $required ?? (Generator::isDefault($this->required) ? Generator::UNDEFINED : $this->required), |
| 52 |
'deprecated' => $deprecated ?? Generator::UNDEFINED, |
| 53 |
'allowEmptyValue' => $allowEmptyValue ?? Generator::UNDEFINED, |
| 54 |
'ref' => $ref ?? Generator::UNDEFINED, |
| 55 |
'example' => $example, |
| 56 |
'style' => $style ?? Generator::UNDEFINED, |
| 57 |
'explode' => $explode ?? Generator::UNDEFINED, |
| 58 |
'allowReserved' => $allowReserved ?? Generator::UNDEFINED, |
| 59 |
'spaceDelimited' => $spaceDelimited ?? Generator::UNDEFINED, |
| 60 |
'pipeDelimited' => $pipeDelimited ?? Generator::UNDEFINED, |
| 61 |
'deepObject' => $deepObject ?? Generator::UNDEFINED, |
| 62 |
'x' => $x ?? Generator::UNDEFINED, |
| 63 |
'attachables' => $attachables ?? Generator::UNDEFINED, |
| 64 |
'value' => $this->combine($schema, $examples, $content), |
| 65 |
]); |
| 66 |
} |
| 67 |
} |