Skip to content

Commit 7237db0

Browse files
feat(openapi): document per-key custom_field endpoints
Adds /api/devices/{uid}/custom_fields/{key} with PUT and DELETE. PUT requires {value} body; both responses are 200 only. Removes custom_fields and the required:[name] from PUT /api/devices/{uid}, which is now strictly a rename.
1 parent dddbb14 commit 7237db0

4 files changed

Lines changed: 78 additions & 10 deletions

File tree

openapi/spec/community-openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ paths:
8787
$ref: paths/api@devices@resolve.yaml
8888
/api/devices/{uid}/{status}:
8989
$ref: paths/api@devices@{uid}@{status}.yaml
90+
/api/devices/{uid}/custom_fields/{key}:
91+
$ref: paths/api@devices@{uid}@custom_fields@{key}.yaml
9092
/internal/devices/{uid}/offline:
9193
$ref: paths/api@devices@{uid}@offline.yaml
9294
/api/sessions:

openapi/spec/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ paths:
131131
$ref: paths/api@devices@resolve.yaml
132132
/api/devices/{uid}/{status}:
133133
$ref: paths/api@devices@{uid}@{status}.yaml
134+
/api/devices/{uid}/custom_fields/{key}:
135+
$ref: paths/api@devices@{uid}@custom_fields@{key}.yaml
134136
/internal/devices/{uid}/offline:
135137
$ref: paths/api@devices@{uid}@offline.yaml
136138
/api/sessions:

openapi/spec/paths/api@devices@{uid}.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ put:
6262
$ref: ../components/schemas/deviceName.yaml
6363
public_url:
6464
$ref: ../components/schemas/devicePublicURL.yaml
65-
custom_fields:
66-
description: User-defined key-value metadata. Replaces all existing custom fields.
67-
type: object
68-
additionalProperties:
69-
type: string
70-
example:
71-
env: production
72-
owner: team-a
73-
required:
74-
- name
7565
responses:
7666
'200':
7767
description: Success to update device's data.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
parameters:
2+
- $ref: ../components/parameters/path/deviceUIDPath.yaml
3+
- name: key
4+
in: path
5+
required: true
6+
description: The custom field key.
7+
schema:
8+
type: string
9+
minLength: 1
10+
maxLength: 64
11+
put:
12+
operationId: setDeviceCustomField
13+
summary: Set or update a device custom field
14+
description: |
15+
Sets or updates a single custom_fields entry on the device. Idempotent:
16+
sending the same key with the same value has no effect. Adding a new
17+
key when the device already holds the maximum number of custom_fields
18+
entries returns 400.
19+
tags:
20+
- community
21+
- devices
22+
security:
23+
- jwt: []
24+
- api-key: []
25+
requestBody:
26+
required: true
27+
content:
28+
application/json:
29+
schema:
30+
type: object
31+
required:
32+
- value
33+
properties:
34+
value:
35+
type: string
36+
maxLength: 256
37+
description: The custom field value.
38+
example: production
39+
responses:
40+
'200':
41+
description: Custom field set successfully.
42+
'400':
43+
$ref: ../components/responses/400.yaml
44+
'401':
45+
$ref: ../components/responses/401.yaml
46+
'403':
47+
$ref: ../components/responses/403.yaml
48+
'404':
49+
$ref: ../components/responses/404.yaml
50+
'500':
51+
$ref: ../components/responses/500.yaml
52+
delete:
53+
operationId: deleteDeviceCustomField
54+
summary: Remove a device custom field
55+
description: |
56+
Removes a single custom_fields entry from the device. Idempotent:
57+
removing a key that does not exist returns 200.
58+
tags:
59+
- community
60+
- devices
61+
security:
62+
- jwt: []
63+
- api-key: []
64+
responses:
65+
'200':
66+
description: Custom field removed successfully.
67+
'401':
68+
$ref: ../components/responses/401.yaml
69+
'403':
70+
$ref: ../components/responses/403.yaml
71+
'404':
72+
$ref: ../components/responses/404.yaml
73+
'500':
74+
$ref: ../components/responses/500.yaml

0 commit comments

Comments
 (0)