From 5672bdbab7b7a9246a6097e777cb7785a14dea29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Wed, 27 Sep 2023 14:29:14 +0200 Subject: [PATCH] Fix enum types in JSON schemas (#1634) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `type: enum` does not exist, as an enum can be of any type. Signed-off-by: Kévin Commaille --- changelogs/internal/newsfragments/1634.clarification | 1 + data/api/client-server/definitions/sso_login_flow.yaml | 2 +- .../definitions/event-schemas/m.device_list_update.yaml | 2 +- .../definitions/event-schemas/m.direct_to_device.yaml | 2 +- .../definitions/event-schemas/m.presence.yaml | 4 ++-- .../definitions/event-schemas/m.receipt.yaml | 2 +- .../definitions/event-schemas/m.signing_key_update.yaml | 2 +- .../definitions/event-schemas/m.typing.yaml | 2 +- layouts/partials/openapi/render-object-table.html | 9 +-------- 9 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 changelogs/internal/newsfragments/1634.clarification diff --git a/changelogs/internal/newsfragments/1634.clarification b/changelogs/internal/newsfragments/1634.clarification new file mode 100644 index 000000000..b4d1ce395 --- /dev/null +++ b/changelogs/internal/newsfragments/1634.clarification @@ -0,0 +1 @@ +Fix enum types in JSON schemas. diff --git a/data/api/client-server/definitions/sso_login_flow.yaml b/data/api/client-server/definitions/sso_login_flow.yaml index ca2a66027..e30b18f91 100644 --- a/data/api/client-server/definitions/sso_login_flow.yaml +++ b/data/api/client-server/definitions/sso_login_flow.yaml @@ -15,7 +15,7 @@ type: object title: m.login.sso flow schema properties: type: - type: enum + type: string enum: ["m.login.sso"] description: The string `m.login.sso` example: "m.login.sso" diff --git a/data/api/server-server/definitions/event-schemas/m.device_list_update.yaml b/data/api/server-server/definitions/event-schemas/m.device_list_update.yaml index 81519e661..8bb8a7dd4 100644 --- a/data/api/server-server/definitions/event-schemas/m.device_list_update.yaml +++ b/data/api/server-server/definitions/event-schemas/m.device_list_update.yaml @@ -31,7 +31,7 @@ allOf: - type: object properties: edu_type: - type: enum + type: string enum: ['m.device_list_update'] description: The string `m.device_list_update`. example: "m.device_list_update" diff --git a/data/api/server-server/definitions/event-schemas/m.direct_to_device.yaml b/data/api/server-server/definitions/event-schemas/m.direct_to_device.yaml index f628ebe02..6cb59fdd3 100644 --- a/data/api/server-server/definitions/event-schemas/m.direct_to_device.yaml +++ b/data/api/server-server/definitions/event-schemas/m.direct_to_device.yaml @@ -23,7 +23,7 @@ allOf: - type: object properties: edu_type: - type: enum + type: string enum: ['m.direct_to_device'] description: The string `m.direct_to_device`. example: "m.direct_to_device" diff --git a/data/api/server-server/definitions/event-schemas/m.presence.yaml b/data/api/server-server/definitions/event-schemas/m.presence.yaml index 09d5d0d2d..c79729e0f 100644 --- a/data/api/server-server/definitions/event-schemas/m.presence.yaml +++ b/data/api/server-server/definitions/event-schemas/m.presence.yaml @@ -21,7 +21,7 @@ allOf: - type: object properties: edu_type: - type: enum + type: string enum: ['m.presence'] description: The string `m.presence` example: "m.presence" @@ -44,7 +44,7 @@ allOf: description: The user ID this presence EDU is for. example: "@john:matrix.org" presence: - type: enum + type: string enum: ['offline', 'unavailable', 'online'] description: The presence of the user. example: "online" diff --git a/data/api/server-server/definitions/event-schemas/m.receipt.yaml b/data/api/server-server/definitions/event-schemas/m.receipt.yaml index 0b064ff1f..677dc28d8 100644 --- a/data/api/server-server/definitions/event-schemas/m.receipt.yaml +++ b/data/api/server-server/definitions/event-schemas/m.receipt.yaml @@ -24,7 +24,7 @@ allOf: - type: object properties: edu_type: - type: enum + type: string enum: ['m.receipt'] description: The string `m.receipt` example: "m.receipt" diff --git a/data/api/server-server/definitions/event-schemas/m.signing_key_update.yaml b/data/api/server-server/definitions/event-schemas/m.signing_key_update.yaml index aea99fe08..0748bc35c 100644 --- a/data/api/server-server/definitions/event-schemas/m.signing_key_update.yaml +++ b/data/api/server-server/definitions/event-schemas/m.signing_key_update.yaml @@ -23,7 +23,7 @@ allOf: - type: object properties: edu_type: - type: enum + type: string enum: ['m.signing_key_update'] description: The string `m.signing_update`. example: "m.signing_key_update" diff --git a/data/api/server-server/definitions/event-schemas/m.typing.yaml b/data/api/server-server/definitions/event-schemas/m.typing.yaml index 7f23bae14..fa36a871b 100644 --- a/data/api/server-server/definitions/event-schemas/m.typing.yaml +++ b/data/api/server-server/definitions/event-schemas/m.typing.yaml @@ -20,7 +20,7 @@ allOf: - type: object properties: edu_type: - type: enum + type: string enum: ['m.typing'] description: The string `m.typing` example: "m.typing" diff --git a/layouts/partials/openapi/render-object-table.html b/layouts/partials/openapi/render-object-table.html index 0f5841a4d..0de9d2d16 100644 --- a/layouts/partials/openapi/render-object-table.html +++ b/layouts/partials/openapi/render-object-table.html @@ -53,13 +53,6 @@ {{ $type = delimit (slice "[" $inner_type "]") "" }} {{ end }} - {{/* - If the property is an enum, indicate this. - */}} - {{ if (and (eq $property.type "string") ($property.enum)) }} - {{ $type = "enum" }} - {{ end }} - {{/* Handle two ways of indicating "required", one for simple parameters, the other for request and response body objects. @@ -72,7 +65,7 @@ {{ if $required }}Required: {{end -}} {{ $property.description | markdownify -}} - {{ if eq $type "enum"}}

One of: [{{ delimit $property.enum ", " }}].

{{ end -}} + {{ if $property.enum }}

One of: [{{ delimit $property.enum ", " }}].

{{ end -}} {{ if (index $property "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index $property "x-addedInMatrixVersion")) }}{{ end -}} {{ if (index $property "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index $property "x-changedInMatrixVersion")) }}{{ end -}}