Merge pull request #2245 from quotient-im/kitsune-map-to-enum-support
Render enums inside additionalProps as one more table
This commit is contained in:
commit
500db6fa2c
3 changed files with 13 additions and 3 deletions
|
@ -96,6 +96,7 @@ paths:
|
||||||
example: "1"
|
example: "1"
|
||||||
available:
|
available:
|
||||||
type: object
|
type: object
|
||||||
|
title: AvailableRoomVersions
|
||||||
description: |-
|
description: |-
|
||||||
A detailed description of the room versions the server supports.
|
A detailed description of the room versions the server supports.
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
|
|
1
changelogs/client_server/2245.clarification
Normal file
1
changelogs/client_server/2245.clarification
Normal file
|
@ -0,0 +1 @@
|
||||||
|
List available enum values for the room versions capability.
|
|
@ -211,9 +211,17 @@ def get_json_schema_object_fields(obj, enforce_title=False):
|
||||||
|
|
||||||
key_type = additionalProps.get("x-pattern", "string")
|
key_type = additionalProps.get("x-pattern", "string")
|
||||||
res = process_data_type(additionalProps)
|
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 {
|
return {
|
||||||
"title": "{%s: %s}" % (key_type, res["title"]),
|
"title": "{%s: %s}" % (key_type, val_title),
|
||||||
"tables": res["tables"],
|
"tables": tables,
|
||||||
}
|
}
|
||||||
|
|
||||||
if not props:
|
if not props:
|
||||||
|
@ -338,8 +346,8 @@ def process_data_type(prop, required=False, enforce_title=True):
|
||||||
prop_title = prop_type
|
prop_title = prop_type
|
||||||
|
|
||||||
if prop.get("enum"):
|
if prop.get("enum"):
|
||||||
|
prop_title = prop.get("title", "enum")
|
||||||
if len(prop["enum"]) > 1:
|
if len(prop["enum"]) > 1:
|
||||||
prop_title = "enum"
|
|
||||||
enum_desc = (
|
enum_desc = (
|
||||||
"One of: %s" % json.dumps(prop["enum"])
|
"One of: %s" % json.dumps(prop["enum"])
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue