source: src/mapservice/openapi.yaml@ 28198a1

debian/bullseye
Last change on this file since 28198a1 was 28198a1, checked in by Joachim Langenbach <joachim.langenbach@…>, 8 years ago

Changed api so that ApiKeys could only managed if a user has logged in with basic auth and not with an api key. This makes sure, that a stolen api key could not be used to generate new or delete existing api keys

  • Property mode set to 100644
File size: 12.5 KB
Line 
1openapi: 3.0.0
2info:
3 title: GNUBoat Mapservice API
4 contact:
5 name: EngSaS - Engineering Solutions and Services Langenbach
6 url: 'http://www.engsas.com'
7 email: info@engsas.de
8 license:
9 name: GPL 3
10 url: 'https://www.gnu.org/licenses/gpl-3.0.en.html'
11 version: v1
12 description: API to upload log files with water depth to GNUBoat server
13servers:
14 - url: 'https://gnuboat.engsas.com/mapservice/{version}'
15 description: The production API server
16 variables:
17 version:
18 default: v1
19 - url: 'http://localhost:8080/mapservice/{version}'
20 description: The local flask development url
21 variables:
22 version:
23 default: v1
24paths:
25 '/user':
26 get:
27 description: Returns information of current/authorized user
28 tags:
29 - users
30 summary: Returns info of a user
31 operationId: usersGet
32 security:
33 - basicAuth: []
34 - apiKeyAuth: []
35 responses:
36 '200':
37 description: OK
38 content:
39 application/json:
40 schema:
41 $ref: '#/components/schemas/User'
42 examples:
43 User:
44 $ref: '#/components/examples/User'
45 '400':
46 $ref: '#/components/responses/BadRequest'
47 '401':
48 $ref: '#/components/responses/Unauthorized'
49 post:
50 description: Registers a new user
51 tags:
52 - users
53 summary: Registers a new user
54 operationId: usersRegister
55 requestBody:
56 content:
57 application/json:
58 schema:
59 $ref: '#/components/schemas/UserCreation'
60 examples:
61 Water:
62 $ref: '#/components/examples/UserCreation'
63 responses:
64 '201':
65 description: Userr created
66 content:
67 application/json:
68 schema:
69 $ref: '#/components/schemas/User'
70 examples:
71 Water:
72 $ref: '#/components/examples/User'
73 '400':
74 $ref: '#/components/responses/BadRequest'
75 options:
76 description: Used by CORS preflight
77 tags:
78 - users
79 responses:
80 '200':
81 description: CORS prefilght requests should return 200 as status code
82 content:
83 application/json: {}
84 '/user/apikey_create':
85 get:
86 description: Generates and returns a new API key for current user
87 tags:
88 - users
89 summary: Returns a new API key
90 operationId: usersApiKeyCreate
91 security:
92 - basicAuth: []
93 responses:
94 '200':
95 description: OK
96 content:
97 application/json:
98 schema:
99 $ref: '#/components/schemas/apiKeys'
100 example: 'NewApiKey4711'
101 '400':
102 $ref: '#/components/responses/BadRequest'
103 '401':
104 $ref: '#/components/responses/Unauthorized'
105 '/user/{api_key}':
106 delete:
107 description: Deletes given API key and returns remaining API keys of the user
108 tags:
109 - users
110 summary: Deletes API key
111 operationId: usersApiKeyDelete
112 security:
113 - basicAuth: []
114 parameters:
115 - name: api_key
116 in: path
117 description: API key
118 required: true
119 schema:
120 $ref: '#/components/schemas/apiKey'
121 example: 'DelApiKey4711'
122 responses:
123 '200':
124 description: OK
125 content:
126 application/json:
127 schema:
128 $ref: '#/components/schemas/apiKeys'
129 example: 'ApiKey4711'
130 '400':
131 $ref: '#/components/responses/BadRequest'
132 '401':
133 $ref: '#/components/responses/Unauthorized'
134 '/user/activate/{activation_code}':
135 get:
136 description: Activates a user account
137 tags:
138 - users
139 summary: Activates a user account
140 operationId: usersActivate
141 parameters:
142 - name: activation_code
143 in: path
144 description: Activation code
145 required: true
146 schema:
147 $ref: '#/components/schemas/activationCode'
148 example: 'dac9630aec642a428cd73f4be0a03569'
149 responses:
150 '302':
151 description: OK or not OK
152 headers:
153 Location:
154 schema:
155 type: string
156 description: URL to the website, showing the result of the activation
157 /waters:
158 get:
159 description: Returns all waters
160 tags:
161 - waters
162 summary: Find waters by id
163 operationId: watersGet
164 parameters:
165 - name: name
166 in: query
167 schema:
168 $ref: '#/components/schemas/itemName'
169 example: 'Missi'
170 - name: manager
171 in: query
172 schema:
173 $ref: '#/components/schemas/username'
174 example: 'jane'
175 - $ref: '#/components/parameters/orderBy'
176 - $ref: '#/components/parameters/offset'
177 - $ref: '#/components/parameters/limit'
178 responses:
179 '200':
180 description: OK
181 content:
182 application/json:
183 schema:
184 $ref: '#/components/schemas/waters'
185 examples:
186 Waters:
187 $ref: '#/components/examples/waters'
188 post:
189 description: Adds a new water to the database
190 tags:
191 - waters
192 summary: Add a new water
193 operationId: watersCreate
194 security:
195 - basicAuth: []
196 - apiKeyAuth: []
197 requestBody:
198 content:
199 application/json:
200 schema:
201 $ref: '#/components/schemas/WaterCreation'
202 example:
203 name: Rhein
204 osmId: 1756854
205 osmType: 'Relation'
206 responses:
207 '201':
208 description: Water created
209 content:
210 application/json:
211 schema:
212 $ref: '#/components/schemas/Water'
213 examples:
214 Water:
215 $ref: '#/components/examples/Water'
216 '400':
217 $ref: '#/components/responses/BadRequest'
218 '401':
219 $ref: '#/components/responses/Unauthorized'
220 '/waters/{id}':
221 get:
222 description: Returns the water identified by id
223 tags:
224 - waters
225 summary: Represents a water
226 operationId: waterGetById
227 parameters:
228 - name: id
229 in: path
230 description: Item ID
231 required: true
232 schema:
233 $ref: '#/components/schemas/itemId'
234 responses:
235 '200':
236 description: OK
237 content:
238 application/json:
239 schema:
240 $ref: '#/components/schemas/Water'
241 examples:
242 Water:
243 $ref: '#/components/examples/Water'
244 '404':
245 $ref: '#/components/responses/NotFound'
246components:
247 securitySchemes:
248 basicAuth:
249 type: http
250 scheme: basic
251 x-basicInfoFunc: openapi_server.server_impl.security.Security.auth_basic
252 apiKeyAuth:
253 type: apiKey
254 in: header
255 name: X-API-KEY
256 x-apikeyInfoFunc: openapi_server.server_impl.security.Security.auth_api
257 schemas:
258 username:
259 title: Username
260 type: string
261 apiKey:
262 title: API Key
263 type: string
264 apiKeys:
265 title: Array of API keys
266 type: array
267 items:
268 $ref: '#/components/schemas/apiKey'
269 activationCode:
270 title: Activation code for a User
271 type: string
272 itemId:
273 title: Item ID
274 type: integer
275 format: int32
276 itemName:
277 title: Item Name
278 type: string
279 osmType:
280 title: OSM type of item (N|W|R)
281 type: string
282 enum:
283 - Node
284 - Way
285 - Relation
286 User:
287 title: User
288 type: object
289 properties:
290 username:
291 $ref: '#/components/schemas/username'
292 email:
293 type: string
294 firstName:
295 type: string
296 lastName:
297 type: string
298 activated:
299 type: boolean
300 apiKeys:
301 $ref: '#/components/schemas/apiKeys'
302 UserCreation:
303 title: User
304 type: object
305 properties:
306 username:
307 $ref: '#/components/schemas/username'
308 email:
309 type: string
310 firstName:
311 type: string
312 lastName:
313 type: string
314 password:
315 type: string
316 required:
317 - username
318 - email
319 - firstName
320 - lastName
321 - password
322 Water:
323 title: Water
324 type: object
325 properties:
326 waterId:
327 $ref: '#/components/schemas/itemId'
328 name:
329 $ref: '#/components/schemas/itemName'
330 manager:
331 $ref: '#/components/schemas/username'
332 osmId:
333 $ref: '#/components/schemas/itemId'
334 osmType:
335 $ref: '#/components/schemas/osmType'
336 required:
337 - waterId
338 - name
339 WaterCreation:
340 title: Water
341 type: object
342 properties:
343 name:
344 $ref: '#/components/schemas/itemName'
345 osmId:
346 $ref: '#/components/schemas/itemId'
347 osmType:
348 $ref: '#/components/schemas/osmType'
349 required:
350 - name
351 waters:
352 title: waters
353 type: array
354 items:
355 $ref: '#/components/schemas/Water'
356 order:
357 title: order
358 enum:
359 - desc
360 - asc
361 type: string
362 default: asc
363 description: |
364 Sort order:
365 * `asc` - Ascending, from A to Z
366 * `desc` - Descending, from Z to A
367 example: asc
368 HttpError:
369 title: HTTP Error Response Object
370 type: object
371 properties:
372 code:
373 type: integer
374 message:
375 type: string
376 required:
377 - code
378 - message
379 parameters:
380 orderBy:
381 name: orderBy
382 in: query
383 description: 'Order by field: name'
384 schema:
385 type: string
386 default: name
387 example: 'name'
388 order:
389 name: order
390 in: query
391 description: Order
392 schema:
393 $ref: '#/components/schemas/order'
394 example: ''
395 offset:
396 name: offset
397 in: query
398 description: >-
399 Skip over a number of elements by specifying an offset value for the
400 query
401 schema:
402 type: integer
403 format: int32
404 default: 0
405 example: 0
406 limit:
407 name: limit
408 in: query
409 description: Limit the number of elements on the response
410 style: form
411 explode: true
412 schema:
413 type: integer
414 format: int32
415 default: 10
416 example: 10
417 examples:
418 User:
419 value:
420 username: jane
421 email: jane@example.org
422 firstName: Jane
423 lastName: Doe
424 activated: true
425 apiKeys:
426 - ApiKey4701
427 UserCreation:
428 value:
429 username: richard
430 email: richard@examle.org
431 firstName: Richard
432 lastName: Roe
433 password: sdfl.1238_ASDkeil?
434 Water:
435 value:
436 waterId: 1
437 name: Mississippi
438 osmId: 1756854
439 osmType: R
440 summary: A water example object
441 WaterCreation:
442 value:
443 name: Mississippi
444 osmId: 1756854
445 osmType: 'Relation'
446 summary: A water example object for creation of a water
447 waters:
448 value:
449 - waterId: 1
450 name: 'Mississippi'
451 osmId: 1756854
452 osmType: 'Relation'
453 - waterId: 2
454 name: 'Bodensee'
455 summary: A sample list with waters
456 HttpError:
457 value:
458 code: 404
459 message: Water with id 999999 not found
460 responses:
461 BadRequest:
462 description: Bad Request (400)
463 content:
464 application/json:
465 schema:
466 $ref: '#/components/schemas/HttpError'
467 examples:
468 HttpError:
469 $ref: '#/components/examples/HttpError'
470 Unauthorized:
471 description: Unauthorized (401) acces to resource
472 content:
473 application/json:
474 schema:
475 $ref: '#/components/schemas/HttpError'
476 examples:
477 HttpError:
478 $ref: '#/components/examples/HttpError'
479 NotFound:
480 description: Water with given Id not found
481 content:
482 application/json:
483 schema:
484 $ref: '#/components/schemas/HttpError'
485 examples:
486 HttpError:
487 $ref: '#/components/examples/HttpError'
488tags:
489 - name: waters
490 description: >-
491 A water is a river (like Mississippi, lake (Lake Ontario), or a sea (North
492 Sea)
493 - name: users
494 description: >-
495 All actions used to manage users and api keys
Note: See TracBrowser for help on using the repository browser.