From 770bbd01a070c262f3dc0da927f59d2db4b8d5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Thu, 8 Jun 2023 21:52:34 +0200 Subject: [PATCH] Fix definition of response of POST /_matrix/federation/v1/user/keys/claim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixes the rendering of nested OneOf. Signed-off-by: Kévin Commaille --- data/api/server-server/user_keys.yaml | 38 ++++++++++--------- .../json-schema/resolve-additional-types.html | 14 +++++++ .../partials/openapi/render-object-table.html | 4 +- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/data/api/server-server/user_keys.yaml b/data/api/server-server/user_keys.yaml index 60995a74..fb598e94 100644 --- a/data/api/server-server/user_keys.yaml +++ b/data/api/server-server/user_keys.yaml @@ -71,26 +71,28 @@ paths: type: object # Key additionalProperties: - type: object - title: KeyObject - properties: - key: - type: string - description: The key, encoded using unpadded base64. - signatures: - type: object - title: Signatures - additionalProperties: - type: object - additionalProperties: + oneOf: + - type: string + - type: object + title: KeyObject + properties: + key: type: string - description: |- - Signature of the key object. + description: The key, encoded using unpadded base64. + signatures: + type: object + title: Signatures + additionalProperties: + 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: diff --git a/layouts/partials/json-schema/resolve-additional-types.html b/layouts/partials/json-schema/resolve-additional-types.html index 58710076..08ef7619 100644 --- a/layouts/partials/json-schema/resolve-additional-types.html +++ b/layouts/partials/json-schema/resolve-additional-types.html @@ -91,6 +91,20 @@ {{ end }} {{ end }} +{{ if and $this_object.oneOf (reflect.IsSlice $this_object.oneOf) }} + {{ range $idx, $item := $this_object.oneOf }} + /* although we expect resolve-allof to be called on the input, resolve-allof does not recurse into + * nested objects, so we have to call it again. + */ + {{ $item = partial "json-schema/resolve-allof" $item }} + {{ $additional_objects = partial "json-schema/resolve-additional-types" (dict + "schema" $item + "anchor_base" $anchor_base + "name" (printf "%s.oneOf[%d]" $name $idx)) + }} + {{ end }} +{{ end }} + {{ return $additional_objects }} diff --git a/layouts/partials/openapi/render-object-table.html b/layouts/partials/openapi/render-object-table.html index 5c38be87..8873ebfb 100644 --- a/layouts/partials/openapi/render-object-table.html +++ b/layouts/partials/openapi/render-object-table.html @@ -36,7 +36,7 @@ {{ $property := partial "json-schema/resolve-allof" $property }} {{ $type := $property.type }} - {{ if eq $property.type "object" }} + {{ if or (eq $property.type "object") (and $property.oneOf (reflect.IsSlice .oneOf)) }} {{ $type = partial "type-or-title" $property }} {{ end }} @@ -108,7 +108,7 @@ {{ $types := slice }} {{ range .oneOf }} - {{ $types = $types | append .type }} + {{ $types = $types | append (partial "type-or-title" .) }} {{ end }} {{ $type = delimit $types "|" }}