Use patternProperties in more places with supported formats (#1813)

Allows to have more places where the property name's type is better defined.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2024-05-08 15:59:17 +02:00 committed by GitHub
parent df1e799c51
commit b0df8e7fb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 489 additions and 407 deletions

View file

@ -0,0 +1 @@
Use `patternProperties` in more places with supported formats.

View file

@ -0,0 +1 @@
Use `patternProperties` in more places with supported formats.

View file

@ -165,7 +165,9 @@ paths:
type: object type: object
description: |- description: |-
A map of user ID to a map of key ID to signed JSON object. A map of user ID to a map of key ID to signed JSON object.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
@ -238,8 +240,10 @@ paths:
A map from user ID to key ID to an error for any signatures A map from user ID to key ID to an error for any signatures
that failed. If a signature was invalid, the `errcode` will that failed. If a signature was invalid, the `errcode` will
be set to `M_INVALID_SIGNATURE`. be set to `M_INVALID_SIGNATURE`.
additionalProperties: patternProperties:
"^@":
type: object type: object
x-pattern-format: mx-user-id
additionalProperties: additionalProperties:
type: object type: object
title: Error title: Error

View file

@ -53,7 +53,9 @@ properties:
`<algorithm>:<device_id>` to the signature. `<algorithm>:<device_id>` to the signature.
The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json). The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json).
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
type: string type: string

View file

@ -20,6 +20,8 @@ additionalProperties:
Signature for the device. Mapped from user ID to signature object, Signature for the device. Mapped from user ID to signature object,
containing mapping from _key signing identifier_ to the signature containing mapping from _key signing identifier_ to the signature
(see also: [Signing JSON](/appendices/#signing-json)) (see also: [Signing JSON](/appendices/#signing-json))
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
required: ['key', 'signatures'] required: ['key', 'signatures']

View file

@ -840,8 +840,11 @@ paths:
rooms: rooms:
type: object type: object
description: A map of room IDs to room key backup data. description: A map of room IDs to room key backup data.
additionalProperties: patternProperties:
$ref: definitions/room_key_backup.yaml "^!":
x-pattern-format: mx-room-id
allOf:
- $ref: definitions/room_key_backup.yaml
example: example:
"!room:example.org": "!room:example.org":
sessions: sessions:
@ -944,8 +947,11 @@ paths:
rooms: rooms:
type: object type: object
description: A map of room IDs to room key backup data. description: A map of room IDs to room key backup data.
additionalProperties: patternProperties:
$ref: definitions/room_key_backup.yaml "^!":
x-pattern-format: mx-room-id
allOf:
- $ref: definitions/room_key_backup.yaml
example: example:
"!room:example.org": "!room:example.org":
sessions: sessions:

View file

@ -137,7 +137,9 @@ paths:
The keys to be downloaded. A map from user ID, to a list of The keys to be downloaded. A map from user ID, to a list of
device IDs, or to an empty list to indicate all devices for the device IDs, or to an empty list to indicate all devices for the
corresponding user. corresponding user.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: array type: array
items: items:
type: string type: string
@ -177,7 +179,9 @@ paths:
the information returned will be the same as uploaded via the information returned will be the same as uploaded via
`/keys/upload`, with the addition of an `unsigned` `/keys/upload`, with the addition of an `unsigned`
property. property.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
title: DeviceInformation title: DeviceInformation
@ -221,8 +225,11 @@ paths:
`/keys/device_signing/upload`, along with the signatures `/keys/device_signing/upload`, along with the signatures
uploaded via `/keys/signatures/upload` that the requesting user uploaded via `/keys/signatures/upload` that the requesting user
is allowed to see. is allowed to see.
additionalProperties: patternProperties:
$ref: definitions/cross_signing_key.yaml "^@":
x-pattern-format: mx-user-id
allOf:
- $ref: definitions/cross_signing_key.yaml
example: example:
"@alice:example.com": "@alice:example.com":
user_id: "@alice:example.com" user_id: "@alice:example.com"
@ -238,8 +245,11 @@ paths:
from user ID, to self-signing key information. For each key, the from user ID, to self-signing key information. For each key, the
information returned will be the same as uploaded via information returned will be the same as uploaded via
`/keys/device_signing/upload`. `/keys/device_signing/upload`.
additionalProperties: patternProperties:
$ref: definitions/cross_signing_key.yaml "^@":
x-pattern-format: mx-user-id
allOf:
- $ref: definitions/cross_signing_key.yaml
example: example:
"@alice:example.com": "@alice:example.com":
user_id: "@alice:example.com" user_id: "@alice:example.com"
@ -258,8 +268,11 @@ paths:
from user ID, to user-signing key information. The from user ID, to user-signing key information. The
information returned will be the same as uploaded via information returned will be the same as uploaded via
`/keys/device_signing/upload`. `/keys/device_signing/upload`.
additionalProperties: patternProperties:
$ref: definitions/cross_signing_key.yaml "^@":
x-pattern-format: mx-user-id
allOf:
- $ref: definitions/cross_signing_key.yaml
example: example:
"@alice:example.com": "@alice:example.com":
user_id: "@alice:example.com" user_id: "@alice:example.com"
@ -297,7 +310,9 @@ paths:
description: |- description: |-
The keys to be claimed. A map from user ID, to a map from The keys to be claimed. A map from user ID, to a map from
device ID to algorithm name. device ID to algorithm name.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
type: string type: string
@ -342,7 +357,9 @@ paths:
If necessary, the claimed key might be a fallback key. Fallback If necessary, the claimed key might be a fallback key. Fallback
keys are re-used by the server until replaced by the device. keys are re-used by the server until replaced by the device.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
$ref: "definitions/one_time_keys.yaml" $ref: "definitions/one_time_keys.yaml"

View file

@ -299,7 +299,9 @@ paths:
type: object type: object
properties: properties:
joined: joined:
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
title: RoomMember title: RoomMember
type: object type: object
properties: properties:

View file

@ -225,9 +225,11 @@ paths:
The historic profile information of the The historic profile information of the
users that sent the events returned. users that sent the events returned.
The `string` key is the user ID for which The key is the user ID for which
the profile belongs to. the profile belongs to.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
title: User Profile title: User Profile
properties: properties:
@ -262,9 +264,11 @@ paths:
This is included if the request had the This is included if the request had the
`include_state` key set with a value of `true`. `include_state` key set with a value of `true`.
The `string` key is the room ID for which the `State The key is the room ID for which the `State
Event` array belongs to. Event` array belongs to.
additionalProperties: patternProperties:
"^!":
x-pattern-format: mx-room-id
type: array type: array
title: Room State title: Room State
items: items:

View file

@ -141,7 +141,9 @@ paths:
description: |- description: |-
The rooms that the user has joined, mapped as room ID to The rooms that the user has joined, mapped as room ID to
room information. room information.
additionalProperties: patternProperties:
"^!":
x-pattern-format: mx-room-id
title: Joined Room title: Joined Room
type: object type: object
properties: properties:
@ -269,7 +271,9 @@ paths:
If a thread does not have any notifications it can be omitted from this object. If If a thread does not have any notifications it can be omitted from this object. If
no threads have notification counts, this whole object can be omitted. no threads have notification counts, this whole object can be omitted.
x-addedInMatrixVersion: "1.4" x-addedInMatrixVersion: "1.4"
additionalProperties: patternProperties:
"^\\$":
x-pattern-format: mx-event-id
title: ThreadNotificationCounts title: ThreadNotificationCounts
type: object type: object
properties: properties:
@ -288,7 +292,9 @@ paths:
description: |- description: |-
The rooms that the user has been invited to, mapped as room ID to The rooms that the user has been invited to, mapped as room ID to
room information. room information.
additionalProperties: patternProperties:
"^!":
x-pattern-format: mx-room-id
title: Invited Room title: Invited Room
type: object type: object
properties: properties:
@ -310,7 +316,9 @@ paths:
type: object type: object
description: The rooms that the user has knocked upon, mapped as room ID to room description: The rooms that the user has knocked upon, mapped as room ID to room
information. information.
additionalProperties: patternProperties:
"^!":
x-pattern-format: mx-room-id
title: Knocked Room title: Knocked Room
type: object type: object
properties: properties:
@ -332,7 +340,9 @@ paths:
description: |- description: |-
The rooms that the user has left or been banned from, mapped as room ID to The rooms that the user has left or been banned from, mapped as room ID to
room information. room information.
additionalProperties: patternProperties:
"^!":
x-pattern-format: mx-room-id
title: Left Room title: Left Room
type: object type: object
properties: properties:

View file

@ -57,7 +57,9 @@ paths:
The messages to send. A map from user ID, to a map from The messages to send. A map from user ID, to a map from
device ID to message body. The device ID may also be `*`, device ID to message body. The device ID may also be `*`,
meaning all known devices for the user. meaning all known devices for the user.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
type: object type: object

View file

@ -51,7 +51,9 @@ allOf:
The contents of the messages to be sent. These are arranged in The contents of the messages to be sent. These are arranged in
a map of user IDs to a map of device IDs to message bodies. a map of user IDs to a map of device IDs to message bodies.
The device ID may also be `*`, meaning all known devices for the user. The device ID may also be `*`, meaning all known devices for the user.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
title: User Devices title: User Devices
additionalProperties: additionalProperties:

View file

@ -33,7 +33,9 @@ allOf:
description: |- description: |-
Receipts for a particular room. The string key is the room ID for Receipts for a particular room. The string key is the room ID for
which the receipts under it belong. which the receipts under it belong.
additionalProperties: patternProperties:
"^!":
x-pattern-format: mx-room-id
type: object type: object
title: Room Receipts title: Room Receipts
properties: properties:
@ -44,7 +46,9 @@ allOf:
description: |- description: |-
Read receipts for users in the room. The string key is the user Read receipts for users in the room. The string key is the user
ID the receipt belongs to. ID the receipt belongs to.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
title: User Read Receipt title: User Read Receipt
properties: properties:

View file

@ -74,7 +74,9 @@ paths:
description: |- description: |-
The PDUs from the original transaction. The string key represents the ID of the The PDUs from the original transaction. The string key represents the ID of the
PDU (event) that was processed. PDU (event) that was processed.
additionalProperties: patternProperties:
"^\\$":
x-pattern-format: mx-event-id
type: object type: object
title: PDU Processing Result title: PDU Processing Result
description: Information about how the PDU was handled. description: Information about how the PDU was handled.

View file

@ -36,7 +36,9 @@ paths:
The keys to be claimed. A map from user ID, to a map from The keys to be claimed. A map from user ID, to a map from
device ID to algorithm name. Requested users must be local device ID to algorithm name. Requested users must be local
to the receiving homeserver. to the receiving homeserver.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
type: string type: string
@ -65,7 +67,9 @@ paths:
See the [Client-Server Key Algorithms](/client-server-api/#key-algorithms) section for more information on See the [Client-Server Key Algorithms](/client-server-api/#key-algorithms) section for more information on
the Key Object format. the Key Object format.
# User # User
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
# Device # Device
additionalProperties: additionalProperties:
@ -124,7 +128,9 @@ paths:
device IDs, or to an empty list to indicate all devices for the device IDs, or to an empty list to indicate all devices for the
corresponding user. Requested users must be local to the corresponding user. Requested users must be local to the
receiving homeserver. receiving homeserver.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: array type: array
items: items:
type: string type: string
@ -150,7 +156,9 @@ paths:
the information returned will be the same as uploaded via the information returned will be the same as uploaded via
`/keys/upload`, with the addition of an `unsigned` `/keys/upload`, with the addition of an `unsigned`
property. property.
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object type: object
additionalProperties: additionalProperties:
allOf: allOf:
@ -177,8 +185,11 @@ paths:
`/keys/device_signing/upload`, along with the signatures `/keys/device_signing/upload`, along with the signatures
uploaded via `/keys/signatures/upload` that the user is uploaded via `/keys/signatures/upload` that the user is
allowed to see. allowed to see.
additionalProperties: patternProperties:
$ref: ../client-server/definitions/cross_signing_key.yaml "^@":
x-pattern-format: mx-user-id
allOf:
- $ref: ../client-server/definitions/cross_signing_key.yaml
example: example:
"@alice:example.com": "@alice:example.com":
user_id: "@alice:example.com" user_id: "@alice:example.com"
@ -194,8 +205,11 @@ paths:
from user ID, to self-signing key information. For each key, the from user ID, to self-signing key information. For each key, the
information returned will be the same as uploaded via information returned will be the same as uploaded via
`/keys/device_signing/upload`. `/keys/device_signing/upload`.
additionalProperties: patternProperties:
$ref: ../client-server/definitions/cross_signing_key.yaml "^@":
x-pattern-format: mx-user-id
allOf:
- $ref: ../client-server/definitions/cross_signing_key.yaml
example: example:
"@alice:example.com": "@alice:example.com":
user_id: "@alice:example.com" user_id: "@alice:example.com"

View file

@ -32,6 +32,11 @@ mx-event-id:
url: /appendices#event-ids url: /appendices#event-ids
# regex: "^\\$" # regex: "^\\$"
mx-room-id:
title: Room ID
url: /appendices#room-ids
# regex: "^!"
uri: uri:
title: URI title: URI
url: http://tools.ietf.org/html/rfc3986 url: http://tools.ietf.org/html/rfc3986

View file

@ -9,7 +9,9 @@ description: |-
that user ID. that user ID.
properties: properties:
content: content:
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: array type: array
items: items:
type: string type: string

View file

@ -67,7 +67,9 @@ properties:
by the `events` key. Defaults to 50 if unspecified. by the `events` key. Defaults to 50 if unspecified.
type: integer type: integer
users: users:
additionalProperties: patternProperties:
"^@":
x-pattern-format: mx-user-id
type: integer type: integer
description: The power levels for specific users. This is a mapping from `user_id` to power level for that user. description: The power levels for specific users. This is a mapping from `user_id` to power level for that user.
title: User power levels title: User power levels