-
Notifications
You must be signed in to change notification settings - Fork 0
/
oas3.yaml
309 lines (294 loc) · 8.47 KB
/
oas3.yaml
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
openapi: 3.0.2
info:
version: 1.0.0
title: Greeting API
termsOfService: "https://example.com/terms/"
contact:
email: contact@example.com
url: "http://example.com/contact"
license:
name: Apache 2.0
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
x-logo:
url: >-
https://images.unsplash.com/photo-1595420832643-faf4aaf65c5b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80
description: >
This is an **example** API to demonstrate features of OpenAPI specification
# Introduction
This API definition is intended to to be a good starting point for
describing your API in
[OpenAPI/Swagger
format](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md).
It also demonstrates features of
[create-openapi-repo](https://github.com/Redocly/create-openapi-repo) tool
and
[Redoc](https://github.com/Redocly/Redoc) documentation engine. So beyond
the standard OpenAPI syntax we use a few
[vendor
extensions](https://github.com/Redocly/Redoc/blob/master/docs/redoc-vendor-extensions.md).
# OpenAPI Specification
The goal of The OpenAPI Specification is to define a standard,
language-agnostic interface to REST APIs which
allows both humans and computers to discover and understand the capabilities
of the service without access to source
code, documentation, or through network traffic inspection. When properly
defined via OpenAPI, a consumer can
understand and interact with the remote service with a minimal amount of
implementation logic. Similar to what
interfaces have done for lower-level programming, OpenAPI removes the
guesswork in calling the service.
externalDocs:
description: Find out how to create a GitHub repo for your OpenAPI definition.
url: "https://github.com/Rebilly/generator-openapi-repo"
tags:
- name: Greetings
description: Endpoints to manage greetings using the REST API
servers:
- url: "http://host.docker.internal:8081"
paths:
/greetings/{greetingId}:
get:
description: "get a greeting by ID"
tags:
- "Greetings"
summary: Get a greeting by ID
operationId: greetings/get
security:
- api_key: []
parameters:
- $ref: "#/components/parameters/greetingId"
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/Greeting"
"401":
description: Unauthorised
"404":
$ref: "#/components/responses/NotFoundError"
"405":
description: Method not allowed
"500":
$ref: "#/components/responses/InternalServerError"
/greetings:
get:
tags:
- Greetings
summary: List greetings for the user
description: |
Some description of the operation.
You can use `markdown` here.
operationId: greetings/list
security:
- api_key: []
x-kong-plugin-rate-limiting:
enabled: true
config:
minute: 3
responses:
"200":
description: Success
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Greeting"
examples:
default:
$ref: "#/components/examples/GreetingItems"
"403":
description: Forbidden
"401":
description: Unauthorised
"405":
description: Method not allowed
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Shell
label: Curl
source: |
curl --request GET \
--url http://localhost:8081/greetings \
--header 'Accept: application/json'
post:
summary: Create a greeting
description: |-
Allows you to add a new greeting.
operationId: greetings/create
tags:
- Greetings
externalDocs:
description: API method documentation
url: https://docs.pexa.com.au/v1/greetings/#create-a-greeting
parameters: []
requestBody:
description: "Create a greeting request"
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Greeting"
responses:
"201":
description: "Greeting created"
content:
"application/json":
schema:
$ref: "#/components/schemas/Greeting"
"400":
$ref: "#/components/responses/InvalidEnumBadRequest"
"401":
description: Unauthorised
"404":
$ref: "#/components/responses/NotFoundError"
"405":
description: Method not allowed
"500":
$ref: "#/components/responses/InternalServerError"
components:
parameters:
greetingId:
name: greetingId
description: greetingId param
in: path
required: true
schema:
type: string
maxLength: 50
examples:
GreetingItems:
value:
- id: 1000
message: "Hello Docker"
creationDate: "2017-07-21T17:32:28Z"
label: "keys"
isFriendly: true
status: "SMILEY_FACE"
weatherType: 1
responses:
BadRequest:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Errors"
InvalidEnumBadRequest:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Errors"
example:
errors:
- code: "400007"
message: 4 is invalid or not supported.
field: WeatherType
InternalServerError:
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Errors"
example:
errors:
- code: "500001"
message: An internal error has occurred
NotFoundError:
description: Not found error
content:
application/json:
schema:
$ref: "#/components/schemas/Errors"
example:
errors:
- code: "404001"
message: Invalid end point
securitySchemes:
api_key:
type: apiKey
in: header
name: api_key
schemas:
Greeting:
type: object
required:
- message
- isFriendly
properties:
id:
description: Id
type: integer
format: int64
example: 1000
readOnly: true
message:
description: Message
type: string
minLength: 1
maxLength: 50
example: Hello Docker
creationDate:
description: Creation Date
type: string
format: date-time
example: "2017-07-21T17:32:28Z"
readOnly: true
label:
type: string
minLength: 3
maxLength: 7
example: key
isFriendly:
type: boolean
example: true
weatherType:
$ref: "#/components/schemas/WeatherType"
status:
type: string
enum: ["SMILEY_FACE", "SAD_FACE"]
WeatherType:
type: integer
format: int32
enum:
- 1
- 2
- 3
x-enum-descriptions:
- "Blue sky"
- "Slightly overcast"
- "Take an umbrella with you"
x-enum-varnames:
- SUNNY
- CLOUDY
- RAINY
Errors:
description: The list of errors related to the API
type: object
required:
- errors
properties:
errors:
type: array
items:
allOf:
- $ref: "#/components/schemas/Error"
Error:
description: A detailed error related to the API
type: object
properties:
code:
description: The error code
type: string
example: "OB1401.005"
message:
description: A human-readable description of the error for debugging purposes
type: string
example: "The message has not been provided"
field:
description: The name of the field provided in the original request (if any) that the error pertains to
type: string
example: "message"