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

@ -51,13 +51,15 @@ allOf:
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.
The device ID may also be `*`, meaning all known devices for the user.
additionalProperties:
type: object
title: User Devices
additionalProperties:
patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object
title: Device Message Contents
properties: {}
title: User Devices
additionalProperties:
type: object
title: Device Message Contents
properties: {}
example: {
"@alice:example.org": {
"IWHQUZUIAH": {

View file

@ -33,54 +33,58 @@ allOf:
description: |-
Receipts for a particular room. The string key is the room ID for
which the receipts under it belong.
additionalProperties:
type: object
title: Room Receipts
properties:
# We strongly define the receipt type to help spec future ones later
# on. At that point, m.read can become optional (maybe).
"m.read":
type: object
description: |-
Read receipts for users in the room. The string key is the user
ID the receipt belongs to.
additionalProperties:
patternProperties:
"^!":
x-pattern-format: mx-room-id
type: object
title: Room Receipts
properties:
# We strongly define the receipt type to help spec future ones later
# on. At that point, m.read can become optional (maybe).
"m.read":
type: object
title: User Read Receipt
properties:
event_ids:
type: array
description: |-
The extremity event IDs that the user has read up to.
minItems: 1
maxItems: 1
items:
type: string
example: ['$read_this_event:matrix.org']
data:
description: |-
Read receipts for users in the room. The string key is the user
ID the receipt belongs to.
patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object
description: Metadata for the read receipt.
title: Read Receipt Metadata
title: User Read Receipt
properties:
ts:
type: integer
format: int64
event_ids:
type: array
description: |-
A POSIX timestamp in milliseconds for when the user read
the event specified in the read receipt.
example: 1533358089009
thread_id:
The extremity event IDs that the user has read up to.
minItems: 1
maxItems: 1
items:
type: string
x-addedInMatrixVersion: "1.4"
description: |-
The root thread event's ID (or `main`) for which
thread this receipt is intended to be under. If
not specified, the read receipt is *unthreaded*
(default).
example: "$threadroot"
required: ['ts']
required: ['event_ids', 'data']
required: ['m.read']
example: ['$read_this_event:matrix.org']
data:
type: object
description: Metadata for the read receipt.
title: Read Receipt Metadata
properties:
ts:
type: integer
format: int64
description: |-
A POSIX timestamp in milliseconds for when the user read
the event specified in the read receipt.
example: 1533358089009
thread_id:
type: string
x-addedInMatrixVersion: "1.4"
description: |-
The root thread event's ID (or `main`) for which
thread this receipt is intended to be under. If
not specified, the read receipt is *unthreaded*
(default).
example: "$threadroot"
required: ['ts']
required: ['event_ids', 'data']
required: ['m.read']
example: {
"!some_room:example.org": {
"m.read": {

View file

@ -74,17 +74,19 @@ paths:
description: |-
The PDUs from the original transaction. The string key represents the ID of the
PDU (event) that was processed.
additionalProperties:
type: object
title: PDU Processing Result
description: Information about how the PDU was handled.
properties:
error:
type: string
description: |-
A human readable description about what went wrong in processing this PDU.
If no error is present, the PDU can be considered successfully handled.
example: You are not allowed to send a message to this room.
patternProperties:
"^\\$":
x-pattern-format: mx-event-id
type: object
title: PDU Processing Result
description: Information about how the PDU was handled.
properties:
error:
type: string
description: |-
A human readable description about what went wrong in processing this PDU.
If no error is present, the PDU can be considered successfully handled.
example: You are not allowed to send a message to this room.
required:
- pdus
examples:

View file

@ -36,12 +36,14 @@ paths:
The keys to be claimed. A map from user ID, to a map from
device ID to algorithm name. Requested users must be local
to the receiving homeserver.
additionalProperties:
type: object
additionalProperties:
type: string
description: algorithm
example: signed_curve25519
patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object
additionalProperties:
type: string
description: algorithm
example: signed_curve25519
example:
"@alice:example.com":
JLAFKJWSCS: signed_curve25519
@ -65,35 +67,37 @@ paths:
See the [Client-Server Key Algorithms](/client-server-api/#key-algorithms) section for more information on
the Key Object format.
# User
additionalProperties:
type: object
# Device
additionalProperties:
patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object
# Key
# Device
additionalProperties:
oneOf:
- type: string
- type: object
title: KeyObject
properties:
key:
type: string
description: The key, encoded using unpadded base64.
signatures:
type: object
title: Signatures
additionalProperties:
type: object
# Key
additionalProperties:
oneOf:
- type: string
- type: object
title: KeyObject
properties:
key:
type: string
description: The key, encoded using unpadded base64.
signatures:
type: object
title: Signatures
additionalProperties:
type: string
description: |-
Signature of the key object.
type: object
additionalProperties:
type: string
description: |-
Signature of the key object.
The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json).
required:
- key
- signatures
The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json).
required:
- key
- signatures
example:
"@alice:example.com":
JLAFKJWSCS:
@ -124,11 +128,13 @@ paths:
device IDs, or to an empty list to indicate all devices for the
corresponding user. Requested users must be local to the
receiving homeserver.
additionalProperties:
type: array
items:
type: string
description: Device ID
patternProperties:
"^@":
x-pattern-format: mx-user-id
type: array
items:
type: string
description: Device ID
example:
"@alice:example.com": []
required:
@ -150,23 +156,25 @@ paths:
the information returned will be the same as uploaded via
`/keys/upload`, with the addition of an `unsigned`
property.
additionalProperties:
type: object
additionalProperties:
allOf:
- $ref: ../client-server/definitions/device_keys.yaml
properties:
unsigned:
title: UnsignedDeviceInfo
type: object
description: |-
Additional data added to the device key information
by intermediate servers, and not covered by the
signatures.
properties:
device_display_name:
type: string
description: The display name which the user set on the device.
patternProperties:
"^@":
x-pattern-format: mx-user-id
type: object
additionalProperties:
allOf:
- $ref: ../client-server/definitions/device_keys.yaml
properties:
unsigned:
title: UnsignedDeviceInfo
type: object
description: |-
Additional data added to the device key information
by intermediate servers, and not covered by the
signatures.
properties:
device_display_name:
type: string
description: The display name which the user set on the device.
master_keys:
x-addedInMatrixVersion: "1.1"
type: object
@ -177,8 +185,11 @@ paths:
`/keys/device_signing/upload`, along with the signatures
uploaded via `/keys/signatures/upload` that the user is
allowed to see.
additionalProperties:
$ref: ../client-server/definitions/cross_signing_key.yaml
patternProperties:
"^@":
x-pattern-format: mx-user-id
allOf:
- $ref: ../client-server/definitions/cross_signing_key.yaml
example:
"@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
information returned will be the same as uploaded via
`/keys/device_signing/upload`.
additionalProperties:
$ref: ../client-server/definitions/cross_signing_key.yaml
patternProperties:
"^@":
x-pattern-format: mx-user-id
allOf:
- $ref: ../client-server/definitions/cross_signing_key.yaml
example:
"@alice:example.com":
user_id: "@alice:example.com"