forked from zircote/swagger-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponse.php
More file actions
128 lines (113 loc) · 3.27 KB
/
Response.php
File metadata and controls
128 lines (113 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php declare(strict_types=1);
/**
* @license Apache 2.0
*/
namespace OpenApi\Annotations;
use OpenApi\Generator;
/**
* Describes a single response from an API Operation, including design-time,
* static links to operations based on the response.
*
* @see [OAI Response Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#response-object)
*
* @Annotation
*/
class Response extends AbstractAnnotation
{
/**
* @see [Using refs](https://swagger.io/docs/specification/using-ref/)
*
* @var string|class-string|object
*/
public $ref = Generator::UNDEFINED;
/**
* The key into Operations->responses array.
*
* A HTTP status code or <code>default</code>.
*
* @var string|int
*/
public $response = Generator::UNDEFINED;
/**
* A short description of the response.
*
* CommonMark syntax may be used for rich text representation.
*
* @var string
*/
public $description = Generator::UNDEFINED;
/**
* Maps a header name to its definition.
*
* RFC7230 states header names are case insensitive.
*
* If a response header is defined with the name "Content-Type", it shall be ignored.
*
* @see [RFC7230](https://tools.ietf.org/html/rfc7230#page-22)
*
* @var Header[]
*/
public $headers = Generator::UNDEFINED;
/**
* A map containing descriptions of potential response payloads.
*
* The key is a media type or media type range and the value describes it.
*
* For responses that match multiple keys, only the most specific key is applicable;
* e.g. <code>text/plain</code> overrides <code>text/*</code>.
*
* @var MediaType|JsonContent|XmlContent|Attachable|array<MediaType|JsonContent|XmlContent|Attachable>
*/
public $content = Generator::UNDEFINED;
/**
* A map of operations links that can be followed from the response.
*
* The key of the map is a short name for the link, following the naming constraints of the names for Component
* Objects.
*
* @var Link[]
*/
public $links = Generator::UNDEFINED;
/**
* @inheritdoc
*/
public static $_types = [
'description' => 'string',
];
/**
* @inheritdoc
*/
public static $_nested = [
MediaType::class => ['content', 'mediaType'],
Header::class => ['headers', 'header'],
Link::class => ['links', 'link'],
Attachable::class => ['attachables'],
];
/**
* @inheritdoc
*/
public static $_parents = [
Components::class,
Operation::class,
Get::class,
Post::class,
Put::class,
Patch::class,
Delete::class,
Head::class,
Options::class,
Trace::class,
];
/**
* @inheritdoc
*/
public function validate(array $stack = [], array $skip = [], string $ref = '', $context = null): bool
{
$valid = parent::validate($stack, $skip, $ref, $context);
if (Generator::isDefault($this->description) && Generator::isDefault($this->ref)) {
$this->_context->logger->warning($this->identity() . ' One of description or ref is required');
$valid = false;
}
return $valid;
}
}