From 65cd10249cb88a81c4caef4bb2164df183b32661 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 24 Aug 2019 21:56:48 +0900 Subject: [PATCH 1/3] Render enums inside additionalProps as one more table Closes #2242. --- api/client-server/capabilities.yaml | 1 + scripts/templating/matrix_templates/units.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api/client-server/capabilities.yaml b/api/client-server/capabilities.yaml index a50908f7..0d6b0677 100644 --- a/api/client-server/capabilities.yaml +++ b/api/client-server/capabilities.yaml @@ -96,6 +96,7 @@ paths: example: "1" available: type: object + title: AvailableRoomVersions description: |- A detailed description of the room versions the server supports. additionalProperties: diff --git a/scripts/templating/matrix_templates/units.py b/scripts/templating/matrix_templates/units.py index 04e6f8a9..f0d21ed0 100644 --- a/scripts/templating/matrix_templates/units.py +++ b/scripts/templating/matrix_templates/units.py @@ -211,9 +211,17 @@ def get_json_schema_object_fields(obj, enforce_title=False): key_type = additionalProps.get("x-pattern", "string") res = process_data_type(additionalProps) + tables = res["tables"] + val_title = res["title"] + if res.get("enum_desc") and val_title != "enum": + # A map to enum needs another table with enum description + tables.append(TypeTable( + title=val_title, + rows=[TypeTableRow(key="(mapped value)", title="enum", desc=res["desc"])] + )) return { - "title": "{%s: %s}" % (key_type, res["title"]), - "tables": res["tables"], + "title": "{%s: %s}" % (key_type, val_title), + "tables": tables, } if not props: @@ -338,8 +346,8 @@ def process_data_type(prop, required=False, enforce_title=True): prop_title = prop_type if prop.get("enum"): + prop_title = prop.get("title", "enum") if len(prop["enum"]) > 1: - prop_title = "enum" enum_desc = ( "One of: %s" % json.dumps(prop["enum"]) ) From 31c132ec823f8a7f4420c375693716b0e8141996 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 25 Aug 2019 17:39:36 +0900 Subject: [PATCH 2/3] Add changelog --- changelogs/client_server/2245.clarification | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/client_server/2245.clarification diff --git a/changelogs/client_server/2245.clarification b/changelogs/client_server/2245.clarification new file mode 100644 index 00000000..67533d15 --- /dev/null +++ b/changelogs/client_server/2245.clarification @@ -0,0 +1 @@ +List available enum values for the room versions capability From 79f16d40a9b40379a6a4bdd2b50500baf6799a47 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 Oct 2019 08:28:05 +0900 Subject: [PATCH 3/3] Add a full stop Co-Authored-By: Travis Ralston --- changelogs/client_server/2245.clarification | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/client_server/2245.clarification b/changelogs/client_server/2245.clarification index 67533d15..31e5c2df 100644 --- a/changelogs/client_server/2245.clarification +++ b/changelogs/client_server/2245.clarification @@ -1 +1 @@ -List available enum values for the room versions capability +List available enum values for the room versions capability.