Skip to content

Commit 4189fbc

Browse files
committed
openapi.yaml: document Device endpoints + schemas
Layer 1 of the agent's reviewer (per the agent's docs/SPEC.md) checks OpenAPI parity between Rails ↔ iOS networking ↔ Android repository layers. Adding the Device controller without the corresponding spec entries means PRs #3-5 (the iOS/Android push registration clients) wouldn't have a contract to integrate against and would fail Layer 1 contract-parity scan. Adds: - Tag: Devices - Path POST /devices: idempotent register; 201 on create, 200 on touch, 422 on validation error - Path DELETE /devices/{deviceId}: 204 no_content, 404 if device isn't owned by current_shopkeeper - Schemas: DeviceAttributes, Device, DeviceCreateRequest (jsonapi-style envelope to match the rest of the API) YAML parses; paths now 25, schemas now 38.
1 parent bf7a601 commit 4189fbc

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

docs/openapi.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,58 @@ components:
369369
attributes:
370370
$ref: '#/components/schemas/PermissionAttributes'
371371

372+
DeviceAttributes:
373+
type: object
374+
properties:
375+
token:
376+
type: string
377+
description: Push token (APNs device token for ios, FCM registration token for android)
378+
platform:
379+
type: string
380+
enum: [ios, android]
381+
bundle_id:
382+
type: string
383+
nullable: true
384+
description: Bundle identifier of the registering app (helps disambiguate when one shopkeeper uses multiple variants generated by the agent)
385+
last_active_at:
386+
type: string
387+
format: date-time
388+
created_at:
389+
type: string
390+
format: date-time
391+
updated_at:
392+
type: string
393+
format: date-time
394+
395+
Device:
396+
type: object
397+
properties:
398+
id:
399+
type: string
400+
format: uuid
401+
type:
402+
type: string
403+
enum: [device]
404+
attributes:
405+
$ref: '#/components/schemas/DeviceAttributes'
406+
407+
DeviceCreateRequest:
408+
type: object
409+
required: [device]
410+
properties:
411+
device:
412+
type: object
413+
required: [token, platform]
414+
properties:
415+
token:
416+
type: string
417+
platform:
418+
type: string
419+
enum: [ios, android]
420+
bundle_id:
421+
type: string
422+
nullable: true
423+
372424
# --- Auth Resources ---
373425

374426
ShopkeeperSignIn:
@@ -708,6 +760,8 @@ tags:
708760
description: Email confirmation for shopkeeper accounts
709761
- name: Auth - Password Reset
710762
description: Forgot password and reset password flow
763+
- name: Devices
764+
description: Register and unregister mobile devices for push notifications
711765
- name: Permissions
712766
description: Retrieve permissions and app configuration metadata
713767
- name: Me
@@ -992,6 +1046,63 @@ paths:
9921046
$ref: '#/components/responses/Unauthorized'
9931047

9941048
# ──────────────── Permissions ────────────────
1049+
# ──────────────── Devices ────────────────
1050+
/devices:
1051+
post:
1052+
operationId: registerDevice
1053+
summary: Register a mobile device for push notifications (idempotent upsert)
1054+
tags: [Devices]
1055+
requestBody:
1056+
required: true
1057+
content:
1058+
application/json:
1059+
schema:
1060+
$ref: '#/components/schemas/DeviceCreateRequest'
1061+
responses:
1062+
'201':
1063+
description: Device created
1064+
content:
1065+
application/json:
1066+
schema:
1067+
type: object
1068+
properties:
1069+
data:
1070+
$ref: '#/components/schemas/Device'
1071+
'200':
1072+
description: Device already registered, last_active_at touched
1073+
content:
1074+
application/json:
1075+
schema:
1076+
type: object
1077+
properties:
1078+
data:
1079+
$ref: '#/components/schemas/Device'
1080+
'401':
1081+
$ref: '#/components/responses/Unauthorized'
1082+
'422':
1083+
$ref: '#/components/responses/UnprocessableEntity'
1084+
1085+
/devices/{deviceId}:
1086+
parameters:
1087+
- name: deviceId
1088+
in: path
1089+
required: true
1090+
schema:
1091+
type: string
1092+
format: uuid
1093+
1094+
delete:
1095+
operationId: unregisterDevice
1096+
summary: Unregister a mobile device (sign-out, app uninstall, etc.)
1097+
tags: [Devices]
1098+
responses:
1099+
'204':
1100+
description: Device deleted
1101+
'401':
1102+
$ref: '#/components/responses/Unauthorized'
1103+
'404':
1104+
$ref: '#/components/responses/NotFound'
1105+
9951106
/permissions:
9961107
get:
9971108
operationId: listPermissions

0 commit comments

Comments
 (0)