-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yml
294 lines (294 loc) · 8.91 KB
/
openapi.yml
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
openapi: "3.0.2"
info:
title: Attachments OpenAPI
version: "2.0.0"
description: Description of the HTTP endpoints of the Polyflix attachments service
servers:
- url: "http://{server}/v{version}"
description: Local
variables:
server:
default: localhost:5006
version:
default: "2.0.0"
- url: "https://{server}/v{version}"
description: QA
variables:
server:
default: qapolyflix.dopolytech.fr/api
version:
default: "2.0.0"
tags:
- name: Attachments
components:
schemas:
attachment:
type: object
allOf:
- $ref: "#/components/schemas/attachmentBase"
- properties:
id:
type: string
userId:
type: string
description: The id of the user who created this attachment.
url:
type: string
description: The public URL of the attachment. It should be a classical URL if the attachment is a external link, or a PSU if the attachment is a file.
status:
type: string
description: If the attachment is a file, it describes the status of the upload of the file.
enum:
- IN_PROGRESS
- COMPLETED
videos:
type: array
description: An array of linked videos ids.
items:
type: string
modules:
type: array
description: An array of linked modules ids.
items:
type: string
required:
- id
- userId
- url
- status
- type
- videos
- modules
attachmentBase:
type: object
properties:
type:
type: string
description: The type of the attachment, either a file to be uploaded or an external link.
enum:
- INTERNAL
- EXTERNAL
extension:
type: string
description: The file type / extension of the attachment, if it is a file to be uploaded.
title:
type: string
description: The name of the attachment, should be explicit to all users.
description:
type: string
description: The description of the attachment, if it needs to be clarified.
required:
- type
- title
paginatedAttachments:
type: object
properties:
data:
type: array
description: An array of attachments
items:
$ref: "#/components/schemas/attachment"
totalCount:
type: integer
description: The total number of attachments, ignoring pagination parameters
roles:
type: string
enum:
- ADMINISTRATOR
- CONTRIBUTOR
- MEMBER
requestBodies:
createAttachment:
description: The DTO of a new attachment.
content:
application/json:
schema:
oneOf:
- allOf:
- $ref: "#/components/schemas/attachmentBase"
- type: object
properties:
url:
type: string
description: The public URL of the attachment (if it is an external URL)
- type: object
responses:
createdAttachment:
description: Either the attachment entity if the type is an external link, or a MinIO PSU
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/attachment"
- type: object
properties:
url:
type: string
description: The MinIO PSU to upload the file
attachmentResponse:
description: An attachment
content:
application/json:
schema:
$ref: "#/components/schemas/attachment"
attachmentsResponse:
description: Returns a list of paginated attachments (for administration purposes).
content:
application/json:
schema:
$ref: "#/components/schemas/paginatedAttachments"
notFoundError:
description: Either the attachment was not found, or the attachment status is still `IN_PROGRESS`.
parameters:
pageSize:
name: pageSize
in: query
description: The maximum number of attachments to return by page (default is 10)
required: false
schema:
type: number
page:
name: page
in: query
description: The page number of attachments to return (default is 1)
required: false
schema:
type: number
userId:
name: userId
in: query
description: The id of the author of the attachments
required: false
schema:
type: string
videos:
name: videos
in: query
description: An array of the linked videos of the attachments
required: false
schema:
type: array
items:
type: string
explode: true
modules:
name: modules
in: query
description: An array of the linked modules of the attachments
required: false
schema:
type: array
items:
type: string
explode: true
id:
name: id
in: path
description: The id of the attachment
required: true
schema:
type: string
x-roles:
name: x-user-roles
in: header
description: An array of the roles of the connected user
required: false
schema:
type: array
items:
$ref: "#/components/schemas/roles"
x-userId:
name: x-user-id
in: header
description: The id of the connected user
required: false
schema:
type: string
paths:
/attachments/:
get:
tags:
- Attachments
summary: Get a list of paginated attachments, only for contributors and administrators
parameters:
- $ref: "#/components/parameters/pageSize"
- $ref: "#/components/parameters/page"
- $ref: "#/components/parameters/userId"
- $ref: "#/components/parameters/videos"
- $ref: "#/components/parameters/modules"
- $ref: "#/components/parameters/x-roles"
- $ref: "#/components/parameters/x-userId"
responses:
"200":
$ref: "#/components/responses/attachmentsResponse"
post:
tags:
- Attachments
summary: Creates an attachment
parameters:
- $ref: "#/components/parameters/x-roles"
- $ref: "#/components/parameters/x-userId"
description: >
Creates an attachment. If the type of the attachment is an external link, it returns the full attachment entity.
If the type of the attachment is a file, it creates the attachment entity in a `IN_PROGRESS` mode, and returns a MinIO PSU.
When the file will be uploaded by the user, MinIO will notify the service via a Kafka topic and the service will set the status to `COMPLETED`.
requestBody:
$ref: "#/components/requestBodies/createAttachment"
responses:
"201":
$ref: "#/components/responses/createdAttachment"
/attachments/video/{videoId}:
get:
tags:
- Attachments
summary: Get a list of attachments linked to a video
parameters:
- name: videoId
in: path
description: The id of the video
required: true
schema:
type: string
- $ref: "#/components/parameters/x-roles"
- $ref: "#/components/parameters/x-userId"
responses:
"200":
$ref: "#/components/responses/attachmentsResponse"
/attachments/{id}:
get:
tags:
- Attachments
summary: Get an attachment by its id
parameters:
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/x-roles"
- $ref: "#/components/parameters/x-userId"
responses:
"200":
$ref: "#/components/responses/attachmentResponse"
"404":
$ref: "#/components/responses/notFoundError"
patch:
tags:
- Attachments
summary: Update an attachment by its id. If the attachment is an internal file and the file should be updated too, the `extension` field must be set.
parameters:
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/x-roles"
- $ref: "#/components/parameters/x-userId"
requestBody:
$ref: "#/components/requestBodies/createAttachment"
responses:
"200":
$ref: "#/components/responses/createdAttachment"
delete:
tags:
- Attachments
summary: Delete an attachment by its id
parameters:
- $ref: "#/components/parameters/id"
- $ref: "#/components/parameters/x-roles"
- $ref: "#/components/parameters/x-userId"
responses:
"204":
description: The attachment was deleted successfully