Skip to content

Commit d6a92b5

Browse files
committed
Add Swagger docs to every endpoint
1 parent 265ffb9 commit d6a92b5

File tree

7 files changed

+1177
-1
lines changed

7 files changed

+1177
-1
lines changed

src/openapi/schemas.yaml

Lines changed: 343 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ components:
142142
- longitude
143143
- created_at
144144

145-
# Reusable request bodies for locations
146145
LocationCreate:
147146
type: object
148147
description: Payload to create a new location for a device
@@ -228,6 +227,205 @@ components:
228227
altitude_accuracy: 1.0
229228
battery: 78
230229

230+
Preference:
231+
type: object
232+
properties:
233+
id:
234+
type: string
235+
user_id:
236+
type: string
237+
key:
238+
type: string
239+
description: Preference key
240+
value:
241+
type: string
242+
description: Preference value
243+
created_at:
244+
type: string
245+
format: date-time
246+
updated_at:
247+
type: string
248+
format: date-time
249+
required:
250+
- id
251+
- user_id
252+
- key
253+
- value
254+
- created_at
255+
- updated_at
256+
257+
PreferenceCreate:
258+
type: object
259+
description: Payload to create a preference
260+
required:
261+
- user_id
262+
- key
263+
- value
264+
properties:
265+
user_id:
266+
type: string
267+
example: "123"
268+
key:
269+
type: string
270+
example: "theme"
271+
value:
272+
type: string
273+
example: "dark"
274+
example:
275+
user_id: "123"
276+
key: "theme"
277+
value: "dark"
278+
279+
PreferenceUpdate:
280+
type: object
281+
description: Payload to update an existing preference
282+
required:
283+
- id
284+
- user_id
285+
- key
286+
properties:
287+
id:
288+
type: string
289+
example: "789"
290+
user_id:
291+
type: string
292+
key:
293+
type: string
294+
value:
295+
type: string
296+
example:
297+
id: "789"
298+
user_id: "123"
299+
key: "theme"
300+
value: "light"
301+
302+
Setting:
303+
type: object
304+
properties:
305+
id:
306+
type: string
307+
key:
308+
type: string
309+
description: Setting key
310+
value:
311+
type: string
312+
description: Setting value
313+
created_at:
314+
type: string
315+
format: date-time
316+
updated_at:
317+
type: string
318+
format: date-time
319+
required:
320+
- id
321+
- key
322+
- value
323+
- created_at
324+
- updated_at
325+
326+
SettingCreate:
327+
type: object
328+
description: Payload to create a new setting (admin only)
329+
required:
330+
- key
331+
- value
332+
properties:
333+
key:
334+
type: string
335+
example: "site_name"
336+
value:
337+
type: string
338+
example: "Onloc Server"
339+
example:
340+
key: "site_name"
341+
value: "Onloc Server"
342+
343+
SettingUpdate:
344+
type: object
345+
description: Payload to update an existing setting (admin only)
346+
required:
347+
- id
348+
properties:
349+
id:
350+
type: string
351+
description: Setting ID
352+
example: "321"
353+
key:
354+
type: string
355+
value:
356+
type: string
357+
example:
358+
id: "321"
359+
key: "site_name"
360+
value: "Onloc API"
361+
362+
Tier:
363+
type: object
364+
properties:
365+
id:
366+
type: string
367+
name:
368+
type: string
369+
max_devices:
370+
type: integer
371+
order_rank:
372+
type: integer
373+
nullable: true
374+
created_at:
375+
type: string
376+
format: date-time
377+
updated_at:
378+
type: string
379+
format: date-time
380+
required:
381+
- id
382+
- name
383+
- max_devices
384+
- created_at
385+
- updated_at
386+
387+
TierCreate:
388+
type: object
389+
description: Payload to create a new tier (admin only)
390+
required:
391+
- name
392+
- max_devices
393+
properties:
394+
name:
395+
type: string
396+
example: "Pro"
397+
max_devices:
398+
type: integer
399+
example: 10
400+
order_rank:
401+
type: integer
402+
nullable: true
403+
example:
404+
name: "Pro"
405+
max_devices: 10
406+
order_rank: 2
407+
408+
TierUpdate:
409+
type: object
410+
description: Payload to update an existing tier (admin only)
411+
required:
412+
- id
413+
properties:
414+
id:
415+
type: string
416+
example: "123"
417+
name:
418+
type: string
419+
max_devices:
420+
type: integer
421+
order_rank:
422+
type: integer
423+
example:
424+
id: "123"
425+
name: "Pro"
426+
max_devices: 10
427+
order_rank: 1
428+
231429
DeviceWithExtras:
232430
allOf:
233431
- $ref: "#/components/schemas/DeviceSafe"
@@ -241,6 +439,150 @@ components:
241439
required:
242440
- is_connected
243441

442+
RefreshToken:
443+
type: object
444+
description: A stored refresh token record
445+
properties:
446+
id:
447+
type: string
448+
user_id:
449+
type: string
450+
token:
451+
type: string
452+
agent:
453+
type: string
454+
nullable: true
455+
created_at:
456+
type: string
457+
format: date-time
458+
updated_at:
459+
type: string
460+
format: date-time
461+
required:
462+
- id
463+
- user_id
464+
- token
465+
- created_at
466+
- updated_at
467+
468+
RefreshTokenDelete:
469+
type: object
470+
description: Request body to delete a refresh token by value
471+
properties:
472+
refresh_token:
473+
type: string
474+
required:
475+
- refresh_token
476+
example:
477+
refresh_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
478+
479+
RefreshTokenList:
480+
type: object
481+
properties:
482+
tokens:
483+
type: array
484+
items:
485+
$ref: "#/components/schemas/RefreshToken"
486+
487+
UserWithExtras:
488+
type: object
489+
description: User data with additional computed fields
490+
properties:
491+
id:
492+
type: string
493+
username:
494+
type: string
495+
admin:
496+
type: boolean
497+
created_at:
498+
type: string
499+
format: date-time
500+
updated_at:
501+
type: string
502+
format: date-time
503+
tier:
504+
$ref: "#/components/schemas/Tier"
505+
nullable: true
506+
number_of_devices:
507+
type: integer
508+
number_of_locations:
509+
type: integer
510+
required:
511+
- id
512+
- username
513+
- admin
514+
- created_at
515+
- updated_at
516+
517+
UserList:
518+
type: object
519+
properties:
520+
users:
521+
type: array
522+
items:
523+
$ref: "#/components/schemas/UserWithExtras"
524+
525+
UserUpdate:
526+
type: object
527+
description: Payload to update a user (partial)
528+
properties:
529+
username:
530+
type: string
531+
password:
532+
type: string
533+
admin:
534+
type: boolean
535+
example:
536+
username: "newuser"
537+
password: "newpassword"
538+
admin: false
539+
540+
UserTier:
541+
type: object
542+
description: Link between a user and a tier
543+
properties:
544+
id:
545+
type: string
546+
user_id:
547+
type: string
548+
tier_id:
549+
type: string
550+
created_at:
551+
type: string
552+
format: date-time
553+
updated_at:
554+
type: string
555+
format: date-time
556+
required:
557+
- id
558+
- user_id
559+
- tier_id
560+
- created_at
561+
- updated_at
562+
563+
UserTierCreate:
564+
type: object
565+
description: Payload to assign a tier to a user (admin only)
566+
required:
567+
- user_id
568+
- tier_id
569+
properties:
570+
user_id:
571+
type: string
572+
tier_id:
573+
type: string
574+
example:
575+
user_id: "123"
576+
tier_id: "456"
577+
578+
UserTierList:
579+
type: object
580+
properties:
581+
user_tiers:
582+
type: array
583+
items:
584+
$ref: "#/components/schemas/UserTier"
585+
244586
responses:
245587
Unauthorized:
246588
description: Access token missing or invalid

0 commit comments

Comments
 (0)