From 3b54ec5f9660d81041760137bad90cae8e8ec41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sat, 10 Jun 2023 11:58:45 +0200 Subject: [PATCH] Allow null in room_types for POST /publicRooms endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- data/api/client-server/list_public_rooms.yaml | 2 +- data/api/server-server/public_rooms.yaml | 2 +- layouts/partials/openapi/render-object-table.html | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/data/api/client-server/list_public_rooms.yaml b/data/api/client-server/list_public_rooms.yaml index e4f0551b..ba816b06 100644 --- a/data/api/client-server/list_public_rooms.yaml +++ b/data/api/client-server/list_public_rooms.yaml @@ -214,7 +214,7 @@ paths: type: array x-addedInMatrixVersion: "1.4" items: - type: string + type: ["string", "null"] description: |- An optional list of [room types](/client-server-api/#types) to search for. To include rooms without a room type, specify `null` within this diff --git a/data/api/server-server/public_rooms.yaml b/data/api/server-server/public_rooms.yaml index dd909f8f..c81789ae 100644 --- a/data/api/server-server/public_rooms.yaml +++ b/data/api/server-server/public_rooms.yaml @@ -107,7 +107,7 @@ paths: type: array x-addedInMatrixVersion: "1.4" items: - type: string + type: ["string", "null"] description: |- An optional list of [room types](/client-server-api/#types) to search for. To include rooms without a room type, specify `null` within this diff --git a/layouts/partials/openapi/render-object-table.html b/layouts/partials/openapi/render-object-table.html index 5c38be87..4fc5ac76 100644 --- a/layouts/partials/openapi/render-object-table.html +++ b/layouts/partials/openapi/render-object-table.html @@ -102,11 +102,24 @@ internal structure, handle this with a bit of recursion */}} {{ $type = delimit (slice "{string: " (partial "type-or-title" .additionalProperties) "}" ) "" }} - {{ else if and .oneOf (reflect.IsSlice .oneOf) }} + {{ else if reflect.IsSlice .type }} {{/* It's legal to specify an array of types. Join them together in that case */}} {{ $types := slice }} + {{ range .type }} + {{ $types = $types | append . }} + {{ end }} + + {{ $type = delimit $types "|" }} + {{ else if and .oneOf (reflect.IsSlice .oneOf) }} + {{/* + This is like an array of types except some of the types probably have a schema. + Join them together too. + */}} + + {{ $types := slice }} + {{ range .oneOf }} {{ $types = $types | append .type }} {{ end }}