-
Notifications
You must be signed in to change notification settings - Fork 24
/
openapi.yml
272 lines (272 loc) · 7.17 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
openapi: 3.0.1
info:
title: Oodrive File Manager
description: 'A simple file manager API. Find out more about its use at [@oodrive/front-technical-test](https://github.com/oodrive/front-technical-test).'
version: 1.0.0
servers:
- url: http://localhost:8080/api
tags:
- name: items
description: Operations related to items
paths:
/items:
get:
summary: Retrieve items
tags: [items]
parameters:
- $ref: '#/components/parameters/parentId'
responses:
200:
description: List of items
content:
application/json:
schema:
$ref: '#/components/schemas/ItemsList'
post:
summary: Create folder or empty file, or upload files using multipart.
description: When using multipart, if filename contains `/`, appropriate folders will be created as well.
tags: [items]
parameters:
- $ref: '#/components/parameters/parentId'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/itemCreate'
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
200:
description: Items uploaded (when using `multipart/form-data` Content-Type)
content:
application/json:
schema:
$ref: '#/components/schemas/itemsUploadResponse'
201:
description: Item created (when using `application/json` Content-Type)
content:
application/json:
schema:
$ref: '#/components/schemas/itemCreateResponse'
400:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
description: Parent not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
/items/{itemId}:
get:
summary: Download file
tags: [items]
parameters:
- $ref: '#/components/parameters/itemId'
responses:
200:
description: Download file
content:
'*/*':
schema:
type: string
format: binary
delete:
summary: Delete item and its subtree
tags: [items]
parameters:
- $ref: '#/components/parameters/itemId'
responses:
204:
description: Item deleted
404:
description: Item not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
patch:
summary: Move or rename item
description: To move an item to the root directory, set `parentId` to `null`.
tags: [items]
parameters:
- $ref: '#/components/parameters/itemId'
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/itemMove'
- $ref: '#/components/schemas/itemRename'
examples:
itemMove:
$ref: '#/components/examples/itemMove'
itemRename:
$ref: '#/components/examples/itemRename'
responses:
200:
description: Updated item
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
400:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
description: Item or parent not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
/items/{itemId}/path:
get:
summary: Retrieve item path
tags: [items]
parameters:
- $ref: '#/components/parameters/itemId'
responses:
200:
description: Item path
content:
application/json:
schema:
$ref: '#/components/schemas/ItemsList'
404:
description: Item not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
components:
parameters:
itemId:
in: path
name: itemId
required: true
description: An item ID
schema:
type: string
parentId:
in: query
name: parentId
required: false
description: Folder ID (if not set, refers to root folder)
schema:
type: string
schemas:
itemCreate:
description: An item creation payload
properties:
name:
type: string
description: Item name
folder:
type: boolean
description: Whether item is a folder
required:
- name
- folder
itemCreateResponse:
allOf:
- $ref: '#/components/schemas/Item'
itemsUploadResponse:
properties:
items:
type: array
items:
$ref: '#/components/schemas/Item'
errors:
type: array
items:
type: object
properties:
name:
type: string
title: Name of file that is in error
code:
type: string
title: Code of error
desc:
type: string
title: Description of error
itemMove:
description: An item move payload
properties:
parentId:
type: string
description: ID of the destination
nullable: true
required:
- parentId
itemRename:
description: An item rename payload
properties:
name:
type: string
description: New name for the specified item
required:
- name
Item:
description: An item
properties:
id:
type: string
description: ID of item
parentId:
type: string
description: ID of parent folder
name:
type: string
description: Item name
folder:
type: boolean
description: Whether item is a folder
creation:
type: string
format: date-time
description: Creation timestamp
modification:
type: string
format: date-time
description: Modification timestamp
required:
- id
- name
- folder
- creation
- modification
ItemsList:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/Item'
ApiError:
type: object
properties:
code:
type: string
desc:
type: string
examples:
itemMove:
summary: Move an item
value:
parentId: zDKBzxxAF
itemRename:
summary: Rename an item
value:
name: 'newname.jpg'