Factor out all the common parameters of the various /relations apis (#1745)

Contributed by @zecakeh bd54781052.

Co-authored-by: Richard van der Hoff <richard@matrix.org>
pull/1754/head
David Baker 8 months ago committed by GitHub
parent 38796de79a
commit bb4003afa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1 @@
Factor out all the common parameters of the various `/relations` apis.

@ -33,69 +33,12 @@ paths:
security: security:
- accessToken: [] - accessToken: []
parameters: parameters:
- in: path - $ref: '#/components/parameters/roomId'
name: roomId - $ref: '#/components/parameters/eventId'
description: The ID of the room containing the parent event. - $ref: '#/components/parameters/from'
required: true - $ref: '#/components/parameters/to'
example: "!636q39766251:matrix.org" - $ref: '#/components/parameters/limit'
schema: - $ref: '#/components/parameters/dir'
type: string
- in: path
name: eventId
description: The ID of the parent event whose child events are to be returned.
required: true
example: $asfDuShaf7Gafaw
schema:
type: string
- in: query
name: from
description: |-
The pagination token to start returning results from. If not supplied, results
start at the most recent topological event known to the server.
Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
`start` token from [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages),
or a `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
required: false
example: page2_token
schema:
type: string
- in: query
name: to
description: |-
The pagination token to stop returning results at. If not supplied, results
continue up to `limit` or until there are no more events.
Like `from`, this can be a previous token from a prior call to this endpoint
or from `/messages` or `/sync`.
required: false
example: page3_token
schema:
type: string
- in: query
name: limit
description: |-
The maximum number of results to return in a single `chunk`. The server can
and should apply a maximum value to this parameter to avoid large responses.
Similarly, the server should apply a default value when not supplied.
required: false
example: 20
schema:
type: integer
- in: query
name: dir
x-addedInMatrixVersion: "1.4"
description: |-
Optional (default `b`) direction to return events from. If this is set to `f`, events
will be returned in chronological order starting at `from`. If it
is set to `b`, events will be returned in *reverse* chronological
order, again starting at `from`.
schema:
type: string
enum:
- b
- f
responses: responses:
# note: this endpoint deliberately does not support rate limiting, therefore a # note: this endpoint deliberately does not support rate limiting, therefore a
# 429 error response is not included. # 429 error response is not included.
@ -107,60 +50,24 @@ paths:
content: content:
application/json: application/json:
schema: schema:
type: object allOf:
properties: - $ref: '#/components/schemas/response'
chunk: - type: object
title: ChildEventsChunk properties:
type: array chunk:
description: The child events of the requested event, ordered topologically title: ChildEventsChunk
most-recent first. type: array
items: description: The child events of the requested event, ordered topologically
allOf: most-recent first.
- $ref: definitions/client_event.yaml items:
next_batch: $ref: definitions/client_event.yaml
type: string required:
description: |- - chunk
An opaque string representing a pagination token. The absence of this token
means there are no more results to fetch and the client should stop paginating.
prev_batch:
type: string
description: |-
An opaque string representing a pagination token. The absence of this token
means this is the start of the result set, i.e. this is the first batch/page.
required:
- chunk
examples: examples:
response: response:
value: { $ref: '#/components/examples/response'
"chunk": [
{
"room_id": "!636q39766251:matrix.org",
"$ref": "../../event-schemas/examples/m.room.message$m.text.yaml",
"content": {
"m.relates_to": {
"rel_type": "org.example.my_relation",
"event_id": "$asfDuShaf7Gafaw"
}
}
}
],
"next_batch": "page2_token",
"prev_batch": "page1_token"
}
"404": "404":
description: |- $ref: '#/components/responses/404'
The parent event was not found or the user does not have permission to read
this event (it might be contained in history that is not accessible to the user).
content:
application/json:
schema:
$ref: definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_FOUND",
"error": "Event not found."
}
tags: tags:
- Event relationships - Event relationships
# The same as above, with added `/{relType}` # The same as above, with added `/{relType}`
@ -182,77 +89,13 @@ paths:
security: security:
- accessToken: [] - accessToken: []
parameters: parameters:
- in: path - $ref: '#/components/parameters/roomId'
name: roomId - $ref: '#/components/parameters/eventId'
description: The ID of the room containing the parent event. - $ref: '#/components/parameters/relType'
required: true - $ref: '#/components/parameters/from'
example: "!636q39766251:matrix.org" - $ref: '#/components/parameters/to'
schema: - $ref: '#/components/parameters/limit'
type: string - $ref: '#/components/parameters/dir'
- in: path
name: eventId
description: The ID of the parent event whose child events are to be returned.
required: true
example: $asfDuShaf7Gafaw
schema:
type: string
- in: path
name: relType
description: The [relationship type](/client-server-api/#relationship-types) to
search for.
required: true
example: org.example.my_relation
schema:
type: string
- in: query
name: from
description: |-
The pagination token to start returning results from. If not supplied, results
start at the most recent topological event known to the server.
Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
`start` token from [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages),
or a `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
required: false
example: page2_token
schema:
type: string
- in: query
name: to
description: |-
The pagination token to stop returning results at. If not supplied, results
continue up to `limit` or until there are no more events.
Like `from`, this can be a previous token from a prior call to this endpoint
or from `/messages` or `/sync`.
required: false
example: page3_token
schema:
type: string
- in: query
name: limit
description: |-
The maximum number of results to return in a single `chunk`. The server can
and should apply a maximum value to this parameter to avoid large responses.
Similarly, the server should apply a default value when not supplied.
required: false
example: 20
schema:
type: integer
- in: query
name: dir
x-addedInMatrixVersion: "1.4"
description: |-
Optional (default `b`) direction to return events from. If this is set to `f`, events
will be returned in chronological order starting at `from`. If it
is set to `b`, events will be returned in *reverse* chronological
order, again starting at `from`.
schema:
type: string
enum:
- b
- f
responses: responses:
# note: this endpoint deliberately does not support rate limiting, therefore a # note: this endpoint deliberately does not support rate limiting, therefore a
# 429 error response is not included. # 429 error response is not included.
@ -264,62 +107,26 @@ paths:
content: content:
application/json: application/json:
schema: schema:
type: object allOf:
properties: - $ref: '#/components/schemas/response'
chunk: - type: object
title: ChildEventsChunk properties:
type: array chunk:
description: |- title: ChildEventsChunk
The child events of the requested event, ordered topologically type: array
most-recent first. The events returned will match the `relType` description: |-
supplied in the URL. The child events of the requested event, ordered topologically
items: most-recent first. The events returned will match the `relType`
allOf: supplied in the URL.
- $ref: definitions/client_event.yaml items:
next_batch: $ref: definitions/client_event.yaml
type: string required:
description: |- - chunk
An opaque string representing a pagination token. The absence of this token
means there are no more results to fetch and the client should stop paginating.
prev_batch:
type: string
description: |-
An opaque string representing a pagination token. The absence of this token
means this is the start of the result set, i.e. this is the first batch/page.
required:
- chunk
examples: examples:
response: response:
value: { $ref: '#/components/examples/response'
"chunk": [
{
"room_id": "!636q39766251:matrix.org",
"$ref": "../../event-schemas/examples/m.room.message$m.text.yaml",
"content": {
"m.relates_to": {
"rel_type": "org.example.my_relation",
"event_id": "$asfDuShaf7Gafaw"
}
}
}
],
"next_batch": "page2_token",
"prev_batch": "page1_token"
}
"404": "404":
description: |- $ref: '#/components/responses/404'
The parent event was not found or the user does not have permission to read
this event (it might be contained in history that is not accessible to the user).
content:
application/json:
schema:
$ref: definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_FOUND",
"error": "Event not found."
}
tags: tags:
- Event relationships - Event relationships
# The same as above, with added `/{eventType}` # The same as above, with added `/{eventType}`
@ -342,28 +149,9 @@ paths:
security: security:
- accessToken: [] - accessToken: []
parameters: parameters:
- in: path - $ref: '#/components/parameters/roomId'
name: roomId - $ref: '#/components/parameters/eventId'
description: The ID of the room containing the parent event. - $ref: '#/components/parameters/relType'
required: true
example: "!636q39766251:matrix.org"
schema:
type: string
- in: path
name: eventId
description: The ID of the parent event whose child events are to be returned.
required: true
example: $asfDuShaf7Gafaw
schema:
type: string
- in: path
name: relType
description: The [relationship type](/client-server-api/#relationship-types) to
search for.
required: true
example: org.example.my_relation
schema:
type: string
- in: path - in: path
name: eventType name: eventType
description: |- description: |-
@ -375,55 +163,10 @@ paths:
example: m.room.message example: m.room.message
schema: schema:
type: string type: string
- in: query - $ref: '#/components/parameters/from'
name: from - $ref: '#/components/parameters/to'
description: |- - $ref: '#/components/parameters/limit'
The pagination token to start returning results from. If not supplied, results - $ref: '#/components/parameters/dir'
start at the most recent topological event known to the server.
Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
`start` token from [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages),
or a `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
required: false
example: page2_token
schema:
type: string
- in: query
name: to
description: |-
The pagination token to stop returning results at. If not supplied, results
continue up to `limit` or until there are no more events.
Like `from`, this can be a previous token from a prior call to this endpoint
or from `/messages` or `/sync`.
required: false
example: page3_token
schema:
type: string
- in: query
name: limit
description: |-
The maximum number of results to return in a single `chunk`. The server can
and should apply a maximum value to this parameter to avoid large responses.
Similarly, the server should apply a default value when not supplied.
required: false
example: 20
schema:
type: integer
- in: query
name: dir
x-addedInMatrixVersion: "1.4"
description: |-
Optional (default `b`) direction to return events from. If this is set to `f`, events
will be returned in chronological order starting at `from`. If it
is set to `b`, events will be returned in *reverse* chronological
order, again starting at `from`.
schema:
type: string
enum:
- b
- f
responses: responses:
# note: this endpoint deliberately does not support rate limiting, therefore a # note: this endpoint deliberately does not support rate limiting, therefore a
# 429 error response is not included. # 429 error response is not included.
@ -435,62 +178,26 @@ paths:
content: content:
application/json: application/json:
schema: schema:
type: object allOf:
properties: - $ref: '#/components/schemas/response'
chunk: - type: object
title: ChildEventsChunk properties:
type: array chunk:
description: |- title: ChildEventsChunk
The child events of the requested event, ordered topologically most-recent type: array
first. The events returned will match the `relType` and `eventType` supplied description: |-
in the URL. The child events of the requested event, ordered topologically most-recent
items: first. The events returned will match the `relType` and `eventType` supplied
allOf: in the URL.
- $ref: definitions/client_event.yaml items:
next_batch: $ref: definitions/client_event.yaml
type: string required:
description: |- - chunk
An opaque string representing a pagination token. The absence of this token
means there are no more results to fetch and the client should stop paginating.
prev_batch:
type: string
description: |-
An opaque string representing a pagination token. The absence of this token
means this is the start of the result set, i.e. this is the first batch/page.
required:
- chunk
examples: examples:
response: response:
value: { $ref: '#/components/examples/response'
"chunk": [
{
"room_id": "!636q39766251:matrix.org",
"$ref": "../../event-schemas/examples/m.room.message$m.text.yaml",
"content": {
"m.relates_to": {
"rel_type": "org.example.my_relation",
"event_id": "$asfDuShaf7Gafaw"
}
}
}
],
"next_batch": "page2_token",
"prev_batch": "page1_token"
}
"404": "404":
description: |- $ref: '#/components/responses/404'
The parent event was not found or the user does not have permission to read
this event (it might be contained in history that is not accessible to the user).
content:
application/json:
schema:
$ref: definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_FOUND",
"error": "Event not found."
}
tags: tags:
- Event relationships - Event relationships
servers: servers:
@ -508,3 +215,129 @@ servers:
components: components:
securitySchemes: securitySchemes:
$ref: definitions/security.yaml $ref: definitions/security.yaml
parameters:
roomId:
in: path
name: roomId
description: The ID of the room containing the parent event.
required: true
example: "!636q39766251:matrix.org"
schema:
type: string
eventId:
in: path
name: eventId
description: The ID of the parent event whose child events are to be returned.
required: true
example: $asfDuShaf7Gafaw
schema:
type: string
from:
in: query
name: from
description: |-
The pagination token to start returning results from. If not supplied, results
start at the most recent topological event known to the server.
Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
`start` token from [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages),
or a `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
required: false
example: page2_token
schema:
type: string
to:
in: query
name: to
description: |-
The pagination token to stop returning results at. If not supplied, results
continue up to `limit` or until there are no more events.
Like `from`, this can be a previous token from a prior call to this endpoint
or from `/messages` or `/sync`.
required: false
example: page3_token
schema:
type: string
limit:
in: query
name: limit
description: |-
The maximum number of results to return in a single `chunk`. The server can
and should apply a maximum value to this parameter to avoid large responses.
Similarly, the server should apply a default value when not supplied.
required: false
example: 20
schema:
type: integer
dir:
in: query
name: dir
x-addedInMatrixVersion: "1.4"
description: |-
Optional (default `b`) direction to return events from. If this is set to `f`, events
will be returned in chronological order starting at `from`. If it
is set to `b`, events will be returned in *reverse* chronological
order, again starting at `from`.
schema:
type: string
enum:
- b
- f
relType:
in: path
name: relType
description: The [relationship type](/client-server-api/#relationship-types) to
search for.
required: true
example: org.example.my_relation
schema:
type: string
schemas:
response:
type: object
properties:
next_batch:
type: string
description: |-
An opaque string representing a pagination token. The absence of this token
means there are no more results to fetch and the client should stop paginating.
prev_batch:
type: string
description: |-
An opaque string representing a pagination token. The absence of this token
means this is the start of the result set, i.e. this is the first batch/page.
responses:
"404":
description: |-
The parent event was not found or the user does not have permission to read
this event (it might be contained in history that is not accessible to the user).
content:
application/json:
schema:
$ref: definitions/errors/error.yaml
examples:
response:
value: {
"errcode": "M_NOT_FOUND",
"error": "Event not found."
}
examples:
response:
value: {
"chunk": [
{
"room_id": "!636q39766251:matrix.org",
"$ref": "../../event-schemas/examples/m.room.message$m.text.yaml",
"content": {
"m.relates_to": {
"rel_type": "org.example.my_relation",
"event_id": "$asfDuShaf7Gafaw"
}
}
}
],
"next_batch": "page2_token",
"prev_batch": "page1_token"
}

Loading…
Cancel
Save