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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332openapi: 3.0.3
info:
version: 1.0.0
title: Example.com
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://redocly.github.io/openapi-template/logo.png"
description: |
This is an **example** API to demonstrate features of the OpenAPI
specification.
# Introduction
This API definition is intended to to be a good starting point for
describing your API in [OpenAPI/Swaggerformat](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md).
It also demonstrates features of the
[create-openapi-repo](https://github.com/Redocly/create-openapi-repo) tool and
the [Redoc](https://github.com/Redocly/Redoc) documentation engine. 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.
tags:
- name: Cron
description: |
The cron API is used to manage cron jobs.
- name: Logs
description: |
The logs API is used to manage cron job logs.
- name: Notify
description: |
The notify API is used to manage cron job notifications.
servers:
- url: "http://127.0.0.1:8008/v1"
# security:
# - access_token: []
paths:
/cron:
get:
tags:
- Cron
summary: Get all cron jobs
description: |
Get all cron jobs.
operationId: getCronJobs
security: []
responses:
"200":
$ref: "#/components/responses/GetCronJobsOK"
"403":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/BadRequest"
post:
tags:
- Cron
summary: Create a cron job
description: |
Create a cron job.
operationId: createCronJob
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Cron"
required: true
responses:
"200":
$ref: "#/components/responses/OKRequest"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/BadRequest"
/cron/{id}:
delete:
tags:
- Cron
summary: Delete a cron job
description: |
Delete a cron job.
operationId: deleteCronJob
parameters:
- name: id
in: path
description: Cron job ID
required: true
schema:
type: integer
example: 1
responses:
"200":
$ref: "#/components/responses/OKRequest"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/BadRequest"
/log/{id}:
get:
tags:
- Logs
summary: Get log by id
operationId: getLogById
parameters:
- name: id
in: path
description: Log ID
required: true
schema:
type: integer
format: int64
example: 1
responses:
"200":
$ref: "#/components/responses/GetLogByIdOK"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/BadRequest"
/notify:
get:
tags:
- Notify
summary: Get all notifications
description: |
Get all notifications.
operationId: getNotifications
responses:
"200":
$ref: "#/components/responses/GetNotificationsOK"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/BadRequest"
post:
tags:
- Notify
summary: Create a notification
operationId: createNotification
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Notification"
responses:
"200":
$ref: "#/components/responses/OKRequest"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/BadRequest"
/notify/{id}:
delete:
tags:
- Notify
summary: Delete a notification
operationId: deleteNotification
parameters:
- name: id
in: path
description: Notification ID
required: true
schema:
type: integer
example: 1
responses:
"200":
$ref: "#/components/responses/OKRequest"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/BadRequest"
components:
securitySchemes:
access_token:
type: apiKey
in: header
name: Authorization
responses:
GetNotificationsOK:
description: OK
content:
application/json:
schema:
properties:
data:
type: array
items:
$ref: "#/components/schemas/Notification"
BadRequest:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
OKRequest:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/OK"
GetCronJobsOK:
description: Success
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/OK"
- type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/Cron"
GetLogByIdOK:
description: Success
content:
application/json:
schema:
properties:
data:
type: array
items:
$ref: "#/components/schemas/Log"
schemas:
OK:
type: object
properties:
message:
type: string
example: OK
Error:
required:
- message
properties:
message:
type: string
example: Not found
Cron:
type: object
required:
- name
- command
- time
- notify
properties:
id:
type: integer
example: 1
name:
type: string
example: "My cron job"
command:
type: string
example: "date"
time:
type: string
example: "0/20 * * * * *"
notify:
type: integer
example: 1
Log:
type: object
required:
- name
- cron_id
- log
properties:
id:
type: integer
example: 1
format: int
readOnly: true
name:
type: string
example: "test"
cron_id:
type: string
example: 1
log:
type: string
example: "Hello world"
time:
type: string
example: "1669690727"
Notification:
type: object
properties:
id:
type: integer
example: 1
name:
type: string
example: "My notification"
type:
type: string
example: "feishu"
enum:
- feishu
- telegram
title:
type: string
example: "My notification"
content:
type: string
example: "Hello world"
url:
type: string
example: "https://open.feishu.cn/open-apis/bot/v2/hook/xxxx"