-
Notifications
You must be signed in to change notification settings - Fork 1
/
SR_OpenAPI.yaml
361 lines (352 loc) · 12.3 KB
/
SR_OpenAPI.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
openapi: 3.0.0
info:
title: Semantic Representation OpenAPI
description: Semantic Representation OpenAPI for validate data objects and schemas.
version: 1.0.0
contact:
name: Filippo Vimini
email: [email protected]
externalDocs:
description: SOFIE project wiki
url: https://sofie.comnet.aalto.fi/index.php/Main_Page
servers:
- url: /api/
paths:
/schema/{id}:
parameters:
- in: path
name: id
description: The db's id of the schema. You can lists all schemas' ids with calling the API "schemas"
schema:
type: integer
required: true
get:
operationId: getSchema
summary: "Get a Schema or a Thing description from the system"
tags:
- SR schema
responses:
200:
description: Returns the requested json schema.
content:
application/json:
schema:
type: "object"
example: {
"@context": ["https://www.w3.org/2019/wot/td/v1"],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://smaugexample.com/schema2.json",
"title": "SMAUG data model schema",
"type": "object",
"securityDefinitions": {
"bearer_sc": {
"description": "bearer token available to locker renter",
"in": "header",
"scheme": "bearer",
"format": "jwt",
"alg": "ES256"
}
},
"security": ["bearer_sc"],
"properties": {
"lockerId": {
"description": "The unique identifier of the locker",
"type": "integer",
"forms": [{"href": "//api/status"}]
},
"price": {
"description": "The price for the locker",
"type": "integer",
"minimum": 0,
"maximum": 50,
"forms": [{"href": "//api/status"}]
}
},
"required": ["lockerId", "price"]
}
404:
description: Returns a json indicating the requested schema is not found.
content:
application/json:
schema:
type: "object"
example:
error: Not Found
5XX:
description: Unexpected error.
delete:
operationId: deleteSchema
summary: "Delete a Schema or a Thing description in the system"
tags:
- SR schema
responses:
201:
description: Returns a json indicating the schema is removed.
content:
application/json:
schema:
type: "object"
example:
message: schema removed
404:
description: Returns a json indicating the requested schema is not found.
content:
application/json:
schema:
type: "object"
example:
error: Not Found
5XX:
description: Unexpected error.
/schema:
post:
operationId: addSchema
summary: "Add a new schema or Thing Description to the component"
tags:
- SR schema
requestBody:
description: this API is used to add WoT schemas or WoT Thing descriptions to the system. These information will be used to validate the message against.
required: true
content:
application/json:
schema:
type: "object"
example: {
"name": "test_schema",
"extend":"old_schema",
"schema": {
"@context": ["https://www.w3.org/2019/wot/td/v1"],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://smaugexample.com/schema.json",
"title": "SMAUG data model schema",
"type": "object",
"security": ["bearer_sc"],
"properties": {
"lockerId": {
"description": "The unique identifier of the locker",
"type": "integer",
"forms": [{"href": "//api/status"}]
},
"volume":{
"description": "The volume of the locker in cc",
"type": "integer",
"minimum": 0,
"forms": [{"href": "//api/status"}]
}
}
}
}
responses:
201:
description: Returns the schema added during the operation.
content:
application/json:
schema:
type: "object"
example: {
"@context": ["https://www.w3.org/2019/wot/td/v1"],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://smaugexample.com/schema.json",
"title": "SMAUG data model schema",
"type": "object",
"security": ["bearer_sc"],
"properties": {
"lockerId": {
"description": "The unique identifier of the locker",
"type": "integer",
"forms": [{"href": "//api/status"}]
},
"volume":{
"description": "The volume of the locker in cc",
"type": "integer",
"minimum": 0,
"forms": [{"href": "//api/status"}]
}
}
}
422:
description: Returns a json indicating bad data input.
content:
application/json:
schema:
type: "object"
example:
error: Unprocessable Entity
message: bad data input, must include schema and schema name
406:
description: Returns a json indicated that the extended schema is not found.
content:
application/json:
schema:
type: "object"
example:
error: Not Acceptable
message: Extended schema not in the DB
409:
description: Returns a json indicating that a schema with the same name is already saved.
content:
application/json:
schema:
type: "object"
example:
error: Conflict
message: schema name already saved
5XX:
description: Unexpected error.
put:
operationId: updateSchema
summary: "Update a schema or Thing Description on the component"
tags:
- SR schema
requestBody:
description: this API is used to update an existing WoT schemas or WoT Thing descriptions on the system.
required: true
content:
application/json:
schema:
type: "object"
example: {
"name": "test_schema",
"schema": {
"@context": ["https://www.w3.org/2019/wot/td/v1"],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://smaugexample.com/schema.json",
"title": "SMAUG data model schema",
"type": "object",
"security": ["bearer_sc"],
"properties": {
"lockerId": {
"description": "The unique identifier of the locker",
"type": "integer",
"forms": [{"href": "//api/status"}]
},
"volume":{
"description": "The volume of the locker in cc",
"type": "integer",
"minimum": 0,
"forms": [{"href": "//api/status"}]
}
}
}
}
responses:
201:
description: Schema successfully updated, return a json with the updated schema
content:
application/json:
schema:
type: "object"
example: {
"@context": ["https://www.w3.org/2019/wot/td/v1"],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://smaugexample.com/schema.json",
"title": "SMAUG data model schema",
"type": "object",
"security": ["bearer_sc"],
"properties": {
"lockerId": {
"description": "The unique identifier of the locker",
"type": "integer",
"forms": [{"href": "//api/status"}]
},
"volume":{
"description": "The volume of the locker in cc",
"type": "integer",
"minimum": 0,
"forms": [{"href": "//api/status"}]
}
}
}
422:
description: Return a json indicating bad data input, the call must include schema and schema name in its json body.
content:
application/json:
schema:
type: "object"
example:
error: Unprocessable Entity
message: bad data input, must include schema and schema name
404:
description: The requested schema, indicated with the keyword "name" is not found, return a json indicating the schema is not found.
content:
application/json:
schema:
type: "object"
example:
error: Not Found
5XX:
description: Unexpected error.
/schemas:
get:
operationId: schemaList
summary: "Get the list of all saved schemas or a Thing description in the system with their db's id"
tags:
- SR schema
responses:
200:
description: Returns a json containing the list of the schemas'id and names saved in the system.
content:
application/json:
schema:
type: "object"
example:
1: http://smaugexample.com/schema.json
2: http://smaugexample.com/schema2.json
404:
description: Returns a json indicating that no schema is found in the system
content:
application/json:
schema:
type: "object"
example:
error: Not Found
5XX:
description: Unexpected error.
/validate:
post:
operationId: validateJson
summary: "validate a json against a specified schema"
tags:
- SR validation
requestBody:
description: This API is used to validate json messages sent by the IoT platforms
required: True
content:
application/json:
schema:
type: "object"
example: {
"message": {"lockerId": 1234, "price": 35, "volume": 15},
"schema": "test_schema"
}
responses:
204:
description: The validation succeeded
400:
description: The validation failed, returns a json with the description of what failed
content:
application/json:
schema:
type: "object"
example:
error: Bad Request
message: lockerId is a required property
404:
description: Returns a json indicating the required schema is not found.
content:
application/json:
schema:
type: "object"
example:
error: Not Found
422:
description: Return a json indicating bad data input, the call must include schema and schema name in its json body.
content:
application/json:
schema:
type: "object"
example:
error: Unprocessable Entity
message: bad data input, must include schema and schema name
5XX:
description: Unexpected error.