Skip to content

Commit 90f3465

Browse files
committed
Use patternProperties in more places with supported formats
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
1 parent 48f4c49 commit 90f3465

File tree

16 files changed

+484
-404
lines changed

16 files changed

+484
-404
lines changed

data/api/client-server/cross_signing.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ paths:
165165
type: object
166166
description: |-
167167
A map of user ID to a map of key ID to signed JSON object.
168-
additionalProperties:
169-
type: object
170-
additionalProperties:
168+
patternProperties:
169+
"^@":
170+
x-pattern-format: mx-user-id
171171
type: object
172+
additionalProperties:
173+
type: object
172174
example: {
173175
"@alice:example.com": {
174176
"HIJKLMN": {
@@ -238,11 +240,13 @@ paths:
238240
A map from user ID to key ID to an error for any signatures
239241
that failed. If a signature was invalid, the `errcode` will
240242
be set to `M_INVALID_SIGNATURE`.
241-
additionalProperties:
242-
type: object
243-
additionalProperties:
243+
patternProperties:
244+
"^@":
244245
type: object
245-
title: Error
246+
x-pattern-format: mx-user-id
247+
additionalProperties:
248+
type: object
249+
title: Error
246250
example:
247251
"@alice:example.com":
248252
HIJKLMN:

data/api/client-server/definitions/device_keys.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ properties:
5353
`<algorithm>:<device_id>` to the signature.
5454
5555
The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json).
56-
additionalProperties:
57-
type: object
58-
additionalProperties:
59-
type: string
56+
patternProperties:
57+
"^@":
58+
x-pattern-format: mx-user-id
59+
type: object
60+
additionalProperties:
61+
type: string
6062
example:
6163
"@alice:example.com":
6264
"ed25519:JLAFKJWSCS": "dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA"

data/api/client-server/definitions/one_time_keys.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ additionalProperties:
2020
Signature for the device. Mapped from user ID to signature object,
2121
containing mapping from _key signing identifier_ to the signature
2222
(see also: [Signing JSON](/appendices/#signing-json))
23-
additionalProperties:
24-
type: object
23+
patternProperties:
24+
"^@":
25+
x-pattern-format: mx-user-id
26+
type: object
2527
required: ['key', 'signatures']

data/api/client-server/key_backup.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,11 @@ paths:
840840
rooms:
841841
type: object
842842
description: A map of room IDs to room key backup data.
843-
additionalProperties:
844-
$ref: definitions/room_key_backup.yaml
843+
patternProperties:
844+
"^!":
845+
x-pattern-format: mx-room-id
846+
allOf:
847+
- $ref: definitions/room_key_backup.yaml
845848
example:
846849
"!room:example.org":
847850
sessions:
@@ -944,8 +947,11 @@ paths:
944947
rooms:
945948
type: object
946949
description: A map of room IDs to room key backup data.
947-
additionalProperties:
948-
$ref: definitions/room_key_backup.yaml
950+
patternProperties:
951+
"^!":
952+
x-pattern-format: mx-room-id
953+
allOf:
954+
- $ref: definitions/room_key_backup.yaml
949955
example:
950956
"!room:example.org":
951957
sessions:

data/api/client-server/keys.yaml

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ paths:
137137
The keys to be downloaded. A map from user ID, to a list of
138138
device IDs, or to an empty list to indicate all devices for the
139139
corresponding user.
140-
additionalProperties:
141-
type: array
142-
items:
143-
type: string
144-
description: device ID
140+
patternProperties:
141+
"^@":
142+
x-pattern-format: mx-user-id
143+
type: array
144+
items:
145+
type: string
146+
description: device ID
145147
example:
146148
"@alice:example.com": []
147149
required:
@@ -177,24 +179,26 @@ paths:
177179
the information returned will be the same as uploaded via
178180
`/keys/upload`, with the addition of an `unsigned`
179181
property.
180-
additionalProperties:
181-
type: object
182-
additionalProperties:
183-
title: DeviceInformation
184-
allOf:
185-
- $ref: definitions/device_keys.yaml
186-
properties:
187-
unsigned:
188-
title: UnsignedDeviceInfo
189-
type: object
190-
description: |-
191-
Additional data added to the device key information
192-
by intermediate servers, and not covered by the
193-
signatures.
194-
properties:
195-
device_display_name:
196-
type: string
197-
description: The display name which the user set on the device.
182+
patternProperties:
183+
"^@":
184+
x-pattern-format: mx-user-id
185+
type: object
186+
additionalProperties:
187+
title: DeviceInformation
188+
allOf:
189+
- $ref: definitions/device_keys.yaml
190+
properties:
191+
unsigned:
192+
title: UnsignedDeviceInfo
193+
type: object
194+
description: |-
195+
Additional data added to the device key information
196+
by intermediate servers, and not covered by the
197+
signatures.
198+
properties:
199+
device_display_name:
200+
type: string
201+
description: The display name which the user set on the device.
198202
example:
199203
"@alice:example.com":
200204
JLAFKJWSCS:
@@ -221,8 +225,11 @@ paths:
221225
`/keys/device_signing/upload`, along with the signatures
222226
uploaded via `/keys/signatures/upload` that the requesting user
223227
is allowed to see.
224-
additionalProperties:
225-
$ref: definitions/cross_signing_key.yaml
228+
patternProperties:
229+
"^@":
230+
x-pattern-format: mx-user-id
231+
allOf:
232+
- $ref: definitions/cross_signing_key.yaml
226233
example:
227234
"@alice:example.com":
228235
user_id: "@alice:example.com"
@@ -238,8 +245,11 @@ paths:
238245
from user ID, to self-signing key information. For each key, the
239246
information returned will be the same as uploaded via
240247
`/keys/device_signing/upload`.
241-
additionalProperties:
242-
$ref: definitions/cross_signing_key.yaml
248+
patternProperties:
249+
"^@":
250+
x-pattern-format: mx-user-id
251+
allOf:
252+
- $ref: definitions/cross_signing_key.yaml
243253
example:
244254
"@alice:example.com":
245255
user_id: "@alice:example.com"
@@ -258,8 +268,11 @@ paths:
258268
from user ID, to user-signing key information. The
259269
information returned will be the same as uploaded via
260270
`/keys/device_signing/upload`.
261-
additionalProperties:
262-
$ref: definitions/cross_signing_key.yaml
271+
patternProperties:
272+
"^@":
273+
x-pattern-format: mx-user-id
274+
allOf:
275+
- $ref: definitions/cross_signing_key.yaml
263276
example:
264277
"@alice:example.com":
265278
user_id: "@alice:example.com"
@@ -297,12 +310,14 @@ paths:
297310
description: |-
298311
The keys to be claimed. A map from user ID, to a map from
299312
device ID to algorithm name.
300-
additionalProperties:
301-
type: object
302-
additionalProperties:
303-
type: string
304-
description: algorithm
305-
example: signed_curve25519
313+
patternProperties:
314+
"^@":
315+
x-pattern-format: mx-user-id
316+
type: object
317+
additionalProperties:
318+
type: string
319+
description: algorithm
320+
example: signed_curve25519
306321
example:
307322
"@alice:example.com":
308323
JLAFKJWSCS: signed_curve25519
@@ -342,10 +357,12 @@ paths:
342357
343358
If necessary, the claimed key might be a fallback key. Fallback
344359
keys are re-used by the server until replaced by the device.
345-
additionalProperties:
346-
type: object
347-
additionalProperties:
348-
$ref: "definitions/one_time_keys.yaml"
360+
patternProperties:
361+
"^@":
362+
x-pattern-format: mx-user-id
363+
type: object
364+
additionalProperties:
365+
$ref: "definitions/one_time_keys.yaml"
349366
example:
350367
"@alice:example.com":
351368
JLAFKJWSCS:

data/api/client-server/rooms.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,20 @@ paths:
299299
type: object
300300
properties:
301301
joined:
302-
additionalProperties:
303-
title: RoomMember
304-
type: object
305-
properties:
306-
display_name:
307-
type: string
308-
description: The display name of the user this object is representing.
309-
avatar_url:
310-
type: string
311-
format: uri
312-
description: The avatar of the user this object is representing, as an [`mxc://`
313-
URI](/client-server-api/#matrix-content-mxc-uris).
302+
patternProperties:
303+
"^@":
304+
x-pattern-format: mx-user-id
305+
title: RoomMember
306+
type: object
307+
properties:
308+
display_name:
309+
type: string
310+
description: The display name of the user this object is representing.
311+
avatar_url:
312+
type: string
313+
format: uri
314+
description: The avatar of the user this object is representing, as an [`mxc://`
315+
URI](/client-server-api/#matrix-content-mxc-uris).
314316
description: A map from user ID to a RoomMember object.
315317
type: object
316318
examples:

data/api/client-server/search.yaml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,21 @@ paths:
225225
The historic profile information of the
226226
users that sent the events returned.
227227
228-
The `string` key is the user ID for which
228+
The key is the user ID for which
229229
the profile belongs to.
230-
additionalProperties:
231-
type: object
232-
title: User Profile
233-
properties:
234-
displayname:
235-
type: string
236-
title: Display name
237-
avatar_url:
238-
type: string
239-
format: uri
240-
title: Avatar Url
230+
patternProperties:
231+
"^@":
232+
x-pattern-format: mx-user-id
233+
type: object
234+
title: User Profile
235+
properties:
236+
displayname:
237+
type: string
238+
title: Display name
239+
avatar_url:
240+
type: string
241+
format: uri
242+
title: Avatar Url
241243
events_before:
242244
type: array
243245
title: Events Before
@@ -262,13 +264,15 @@ paths:
262264
This is included if the request had the
263265
`include_state` key set with a value of `true`.
264266
265-
The `string` key is the room ID for which the `State
267+
The key is the room ID for which the `State
266268
Event` array belongs to.
267-
additionalProperties:
268-
type: array
269-
title: Room State
270-
items:
271-
$ref: definitions/client_event.yaml
269+
patternProperties:
270+
"^!":
271+
x-pattern-format: mx-room-id
272+
type: array
273+
title: Room State
274+
items:
275+
$ref: definitions/client_event.yaml
272276
groups:
273277
type: object
274278
title: Groups

0 commit comments

Comments
 (0)