-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathOpenAPI.php
More file actions
198 lines (186 loc) · 6.22 KB
/
Copy pathOpenAPI.php
File metadata and controls
198 lines (186 loc) · 6.22 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
declare(strict_types=1);
namespace Api\App;
use Api\App\Handler\GetIndexResourceHandler;
use Api\App\Handler\PostErrorReportResourceHandler;
use Fig\Http\Message\StatusCodeInterface;
use OpenApi\Attributes as OA;
#[OA\Info(version: '1.0', title: 'Dotkernel API')]
#[OA\Server(url: 'http://api.dotkernel.localhost', description: 'Local development server')]
#[OA\SecurityScheme(securityScheme: 'AuthToken', type: 'http', in: 'header', bearerFormat: 'JWT', scheme: 'bearer')]
#[OA\SecurityScheme(securityScheme: 'ErrorReportingToken', type: 'apiKey', name: 'Error-Reporting-Token', in: 'header')]
#[OA\ExternalDocumentation(
description: 'Dotkernel API documentation',
url: 'https://docs.dotkernel.org/api-documentation/'
)]
/**
* @see GetIndexResourceHandler::handle()
*/
#[OA\Get(
path: '/',
description: 'API home page outputting default message',
summary: 'API home page',
tags: ['Home'],
responses: [
new OA\Response(
response: StatusCodeInterface::STATUS_OK,
description: 'OK',
content: new OA\JsonContent(
ref: '#/components/schemas/HomeMessage',
title: 'HomeMessage',
description: 'API home page output message',
),
),
],
)]
/**
* @see PostErrorReportResourceHandler::handle()
*/
#[OA\Post(
path: '/error-report',
description: 'Third-party application reports an error to the API',
summary: 'Report an error to the API',
security: [['ErrorReportingToken' => []]],
requestBody: new OA\RequestBody(
description: 'Error reporting request',
required: true,
content: new OA\JsonContent(
required: ['message'],
properties: [
new OA\Property(property: 'message', type: 'string'),
],
type: 'object',
)
),
tags: ['ErrorReport'],
responses: [
new OA\Response(
response: StatusCodeInterface::STATUS_CREATED,
description: 'Created',
content: new OA\JsonContent(ref: '#/components/schemas/InfoMessage'),
),
new OA\Response(
response: StatusCodeInterface::STATUS_UNAUTHORIZED,
description: 'Unauthorized',
content: new OA\JsonContent(ref: '#/components/schemas/ErrorMessage'),
),
new OA\Response(
response: StatusCodeInterface::STATUS_FORBIDDEN,
description: 'Forbidden',
content: new OA\JsonContent(ref: '#/components/schemas/ErrorMessage'),
),
new OA\Response(
response: StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR,
description: 'Error',
content: new OA\JsonContent(ref: '#/components/schemas/ErrorMessage'),
),
],
)]
#[OA\Schema(
schema: 'HomeMessage',
properties: [
new OA\Property(property: 'message', type: 'string', default: 'Dotkernel API version 6'),
],
type: 'object',
)]
#[OA\Schema(
schema: 'ErrorMessage',
properties: [
new OA\Property(
property: 'error',
properties: [
new OA\Property(property: 'messages', type: 'array', items: new OA\Items(type: 'string')),
],
type: 'object',
),
],
type: 'object',
)]
#[OA\Schema(
schema: 'InfoMessage',
properties: [
new OA\Property(
property: 'info',
properties: [
new OA\Property(property: 'messages', type: 'array', items: new OA\Items(type: 'string')),
],
type: 'object',
),
],
type: 'object',
)]
#[OA\Schema(
schema: 'Collection',
description: 'Base collection providing common structure to be extended by entity-specific collections',
properties: [
new OA\Property(property: '_total_items', type: 'integer', example: 1),
new OA\Property(property: '_page', type: 'integer', example: 1),
new OA\Property(property: '_page_count', type: 'integer', example: 1),
new OA\Property(
property: '_links',
required: ['self'],
properties: [
new OA\Property(
property: 'first',
properties: [
new OA\Property(
property: 'href',
type: 'string',
example: 'https://example.com/resource?page=1',
),
],
type: 'object',
),
new OA\Property(
property: 'prev',
properties: [
new OA\Property(
property: 'href',
type: 'string',
example: 'https://example.com/resource?page=2',
),
],
type: 'object',
),
new OA\Property(
property: 'self',
properties: [
new OA\Property(
property: 'href',
type: 'string',
example: 'https://example.com/resource?page=3',
),
],
type: 'object',
),
new OA\Property(
property: 'next',
properties: [
new OA\Property(
property: 'href',
type: 'string',
example: 'https://example.com/resource?page=4',
),
],
type: 'object',
),
new OA\Property(
property: 'last',
properties: [
new OA\Property(
property: 'href',
type: 'string',
example: 'https://example.com/resource?page=5',
),
],
type: 'object',
),
],
type: 'object',
),
],
type: 'object',
)]
class OpenAPI
{
}