Fix the rendering of the event format for room versions 1 and 2 (#1883)
* Fix rendering of array with items using anyOf Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Use a single definition for Event Hash Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Add changelog Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Add ending newline Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> --------- Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
094e25b6cd
commit
bd20d946c4
8 changed files with 33 additions and 63 deletions
|
@ -0,0 +1 @@
|
||||||
|
Fix the rendering of the event format for room versions 1 and 2.
|
13
data/api/server-server/definitions/event_hash.yaml
Normal file
13
data/api/server-server/definitions/event_hash.yaml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
type: object
|
||||||
|
title: Event Hash
|
||||||
|
description: |-
|
||||||
|
Content hashes of the PDU, following the algorithm specified in [Signing Events](/server-server-api/#signing-events).
|
||||||
|
example: {
|
||||||
|
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
|
||||||
|
}
|
||||||
|
properties:
|
||||||
|
sha256:
|
||||||
|
type: string
|
||||||
|
description: The hash.
|
||||||
|
example: ThisHashCoversAllFieldsInCaseThisIsRedacted
|
||||||
|
required: ['sha256']
|
|
@ -25,19 +25,7 @@ allOf:
|
||||||
description: For redaction events, the ID of the event being redacted.
|
description: For redaction events, the ID of the event being redacted.
|
||||||
example: "$def456:matrix.org"
|
example: "$def456:matrix.org"
|
||||||
hashes:
|
hashes:
|
||||||
type: object
|
$ref: "event_hash.yaml"
|
||||||
title: Event Hash
|
|
||||||
description: |-
|
|
||||||
Content hashes of the PDU, following the algorithm specified in [Signing Events](/server-server-api/#signing-events).
|
|
||||||
example: {
|
|
||||||
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
|
|
||||||
}
|
|
||||||
properties:
|
|
||||||
sha256:
|
|
||||||
type: string
|
|
||||||
description: The hash.
|
|
||||||
example: ThisHashCoversAllFieldsInCaseThisIsRedacted
|
|
||||||
required: ['sha256']
|
|
||||||
signatures:
|
signatures:
|
||||||
type: object
|
type: object
|
||||||
description: |-
|
description: |-
|
||||||
|
|
|
@ -47,19 +47,7 @@ allOf:
|
||||||
Must contain less than or equal to 20 events.
|
Must contain less than or equal to 20 events.
|
||||||
example: ["$URLsafe-base64EncodedHash", "$Another_Event"]
|
example: ["$URLsafe-base64EncodedHash", "$Another_Event"]
|
||||||
hashes:
|
hashes:
|
||||||
type: object
|
$ref: "event_hash.yaml"
|
||||||
title: Event Hash
|
|
||||||
description: |-
|
|
||||||
Content hashes of the PDU, following the algorithm specified in [Signing Events](/server-server-api/#signing-events).
|
|
||||||
example: {
|
|
||||||
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
|
|
||||||
}
|
|
||||||
properties:
|
|
||||||
sha256:
|
|
||||||
type: string
|
|
||||||
description: The hash.
|
|
||||||
example: ThisHashCoversAllFieldsInCaseThisIsRedacted
|
|
||||||
required: ['sha256']
|
|
||||||
signatures:
|
signatures:
|
||||||
type: object
|
type: object
|
||||||
description: |-
|
description: |-
|
||||||
|
|
|
@ -49,19 +49,7 @@ allOf:
|
||||||
Must contain less than or equal to 20 events.
|
Must contain less than or equal to 20 events.
|
||||||
example: ["$base64EncodedHash", "$AnotherEvent"]
|
example: ["$base64EncodedHash", "$AnotherEvent"]
|
||||||
hashes:
|
hashes:
|
||||||
type: object
|
$ref: "event_hash.yaml"
|
||||||
title: Event Hash
|
|
||||||
description: |-
|
|
||||||
Content hashes of the PDU, following the algorithm specified in [Signing Events](/server-server-api/#signing-events).
|
|
||||||
example: {
|
|
||||||
"sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted"
|
|
||||||
}
|
|
||||||
properties:
|
|
||||||
sha256:
|
|
||||||
type: string
|
|
||||||
description: The hash.
|
|
||||||
example: ThisHashCoversAllFieldsInCaseThisIsRedacted
|
|
||||||
required: ['sha256']
|
|
||||||
signatures:
|
signatures:
|
||||||
type: object
|
type: object
|
||||||
description: |-
|
description: |-
|
||||||
|
|
|
@ -60,17 +60,7 @@ properties:
|
||||||
- type: string
|
- type: string
|
||||||
title: Event ID
|
title: Event ID
|
||||||
example: "$abc123:matrix.org"
|
example: "$abc123:matrix.org"
|
||||||
- type: object
|
- $ref: "event_hash.yaml"
|
||||||
title: Event Hash
|
|
||||||
example: {
|
|
||||||
"sha256": "Base64EncodedSha256HashesShouldBe43BytesLong"
|
|
||||||
}
|
|
||||||
properties:
|
|
||||||
sha256:
|
|
||||||
type: string
|
|
||||||
description: The event hash.
|
|
||||||
example: Base64EncodedSha256HashesShouldBe43BytesLong
|
|
||||||
required: ['sha256']
|
|
||||||
depth:
|
depth:
|
||||||
type: integer
|
type: integer
|
||||||
description: |-
|
description: |-
|
||||||
|
@ -96,17 +86,7 @@ properties:
|
||||||
- type: string
|
- type: string
|
||||||
title: Event ID
|
title: Event ID
|
||||||
example: "$abc123:matrix.org"
|
example: "$abc123:matrix.org"
|
||||||
- type: object
|
- $ref: "event_hash.yaml"
|
||||||
title: Event Hash
|
|
||||||
example: {
|
|
||||||
"sha256": "Base64EncodedSha256HashesShouldBe43BytesLong"
|
|
||||||
}
|
|
||||||
properties:
|
|
||||||
sha256:
|
|
||||||
type: string
|
|
||||||
description: The event hash.
|
|
||||||
example: Base64EncodedSha256HashesShouldBe43BytesLong
|
|
||||||
required: ['sha256']
|
|
||||||
unsigned:
|
unsigned:
|
||||||
type: object
|
type: object
|
||||||
title: UnsignedData
|
title: UnsignedData
|
||||||
|
|
|
@ -155,6 +155,7 @@
|
||||||
{{ if eq $this_object.type "array" }}
|
{{ if eq $this_object.type "array" }}
|
||||||
/* Add any nested objects referenced in this object's `items` */
|
/* Add any nested objects referenced in this object's `items` */
|
||||||
{{ if $this_object.items.anyOf }}
|
{{ if $this_object.items.anyOf }}
|
||||||
|
{{ $updated_schemas := slice }}
|
||||||
{{ range $idx, $item := $this_object.items.anyOf }}
|
{{ range $idx, $item := $this_object.items.anyOf }}
|
||||||
{{ $res := partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $item
|
"this_object" $item
|
||||||
|
@ -163,7 +164,10 @@
|
||||||
"name" (printf "%s.items[%d]" $name $idx)
|
"name" (printf "%s.items[%d]" $name $idx)
|
||||||
) }}
|
) }}
|
||||||
{{ $all_objects = $res.objects }}
|
{{ $all_objects = $res.objects }}
|
||||||
|
{{ $updated_schemas = $updated_schemas | append $res.schema }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
/* Update the top-level schema with the updated subschemas for the items */
|
||||||
|
{{ $this_object = merge $this_object (dict "items" (dict "anyOf" $updated_schemas)) }}
|
||||||
{{ else if reflect.IsMap $this_object.items}}
|
{{ else if reflect.IsMap $this_object.items}}
|
||||||
{{ $res := partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $this_object.items
|
"this_object" $this_object.items
|
||||||
|
|
|
@ -118,6 +118,9 @@ resolve-additional-types.)
|
||||||
* `oneOf`: optional array of dictionaries describing the different formats
|
* `oneOf`: optional array of dictionaries describing the different formats
|
||||||
that the property can have
|
that the property can have
|
||||||
|
|
||||||
|
* `anyOf`: optional array of dictionaries describing the different formats
|
||||||
|
that the property can have
|
||||||
|
|
||||||
* `properties`: if the type is an object, optional dictionary for
|
* `properties`: if the type is an object, optional dictionary for
|
||||||
well-defined properties, each given as: `property_name` : `property_data`
|
well-defined properties, each given as: `property_name` : `property_data`
|
||||||
|
|
||||||
|
@ -158,13 +161,14 @@ resolve-additional-types.)
|
||||||
{{ $type = . }}
|
{{ $type = . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else if or (reflect.IsSlice .type) .oneOf }}
|
{{ else if or (reflect.IsSlice .type) .oneOf .anyOf }}
|
||||||
{{/*
|
{{/*
|
||||||
It's legal to specify an array of types.
|
It's legal to specify an array of types.
|
||||||
|
|
||||||
There are two ways to do that:
|
There are three ways to do that:
|
||||||
- Use an array of strings.
|
- Use an array of strings.
|
||||||
- Use oneOf, with items having a schema.
|
- Use oneOf, with items having a schema.
|
||||||
|
- Use anyOf, with items having a schema.
|
||||||
|
|
||||||
Join them together in that case, like `type|other_type`.
|
Join them together in that case, like `type|other_type`.
|
||||||
*/}}
|
*/}}
|
||||||
|
@ -174,6 +178,10 @@ resolve-additional-types.)
|
||||||
{{ range .oneOf }}
|
{{ range .oneOf }}
|
||||||
{{ $types = $types | append (partial "property-type" .) }}
|
{{ $types = $types | append (partial "property-type" .) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ else if .anyOf }}
|
||||||
|
{{ range .anyOf }}
|
||||||
|
{{ $types = $types | append (partial "property-type" .) }}
|
||||||
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ range .type }}
|
{{ range .type }}
|
||||||
{{ $types = $types | append (htmlEscape .) }}
|
{{ $types = $types | append (htmlEscape .) }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue