| 1 |
<?php declare(strict_types=1); |
| 2 |
|
| 3 |
/** |
| 4 |
* @license Apache 2.0 |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace OpenApi\Annotations; |
| 8 |
|
| 9 |
use OpenApi\Attributes\JsonContent; |
| 10 |
use OpenApi\Attributes\XmlContent; |
| 11 |
use OpenApi\Generator; |
| 12 |
|
| 13 |
/** |
| 14 |
* Describes a single request body. |
| 15 |
* |
| 16 |
* @see [Request Body Object](https://spec.openapis.org/oas/v3.1.1.html#request-body-object) |
| 17 |
* |
| 18 |
* @Annotation |
| 19 |
*/ |
| 20 |
class RequestBody extends AbstractAnnotation |
| 21 |
{ |
| 22 |
/** |
| 23 |
* The relative or absolute path to a request body. |
| 24 |
* |
| 25 |
* @see [Reference Object](https://spec.openapis.org/oas/v3.1.1.html#reference-object) |
| 26 |
* |
| 27 |
* @var string|class-string|object |
| 28 |
*/ |
| 29 |
public $ref = Generator::UNDEFINED; |
| 30 |
|
| 31 |
/** |
| 32 |
* The key into Components->requestBodies array. |
| 33 |
* |
| 34 |
* @var string |
| 35 |
*/ |
| 36 |
public $request = Generator::UNDEFINED; |
| 37 |
|
| 38 |
/** |
| 39 |
* A brief description of the parameter. |
| 40 |
* |
| 41 |
* This could contain examples of use. |
| 42 |
* |
| 43 |
* CommonMark syntax may be used for rich text representation. |
| 44 |
* |
| 45 |
* @var string |
| 46 |
*/ |
| 47 |
public $description = Generator::UNDEFINED; |
| 48 |
|
| 49 |
/** |
| 50 |
* Determines whether this parameter is mandatory. |
| 51 |
* |
| 52 |
* If the parameter location is "path", this property is required and its value must be true. |
| 53 |
* Otherwise, the property may be included and its default value is false. |
| 54 |
* |
| 55 |
* @var bool |
| 56 |
*/ |
| 57 |
public $required = Generator::UNDEFINED; |
| 58 |
|
| 59 |
/** |
| 60 |
* The content of the request body. |
| 61 |
* |
| 62 |
* The key is a media type or media type range and the value describes it. For requests that match multiple keys, |
| 63 |
* only the most specific key is applicable. e.g. text/plain overrides text/*. |
| 64 |
* |
| 65 |
* @var array<MediaType|JsonContent|XmlContent>|MediaType|JsonContent|XmlContent|Attachable |
| 66 |
*/ |
| 67 |
public $content = Generator::UNDEFINED; |
| 68 |
|
| 69 |
/** |
| 70 |
* @inheritdoc |
| 71 |
*/ |
| 72 |
public static $_types = [ |
| 73 |
'description' => 'string', |
| 74 |
'required' => 'boolean', |
| 75 |
'request' => 'string', |
| 76 |
]; |
| 77 |
|
| 78 |
public static $_parents = [ |
| 79 |
Components::class, |
| 80 |
Delete::class, |
| 81 |
Get::class, |
| 82 |
Head::class, |
| 83 |
Operation::class, |
| 84 |
Options::class, |
| 85 |
Patch::class, |
| 86 |
Post::class, |
| 87 |
Trace::class, |
| 88 |
Put::class, |
| 89 |
]; |
| 90 |
|
| 91 |
/** |
| 92 |
* @inheritdoc |
| 93 |
*/ |
| 94 |
public static $_nested = [ |
| 95 |
MediaType::class => ['content', 'mediaType'], |
| 96 |
Attachable::class => ['attachables'], |
| 97 |
]; |
| 98 |
|
| 99 |
public function jsonSerialize(): \stdClass |
| 100 |
{ |
| 101 |
$data = parent::jsonSerialize(); |
| 102 |
|
| 103 |
unset($data->request); |
| 104 |
|
| 105 |
return $data; |
| 106 |
} |
| 107 |
} |