Partially handle representing top-level array responses
If an HTTP API returned a top-level array response, the templating system would fail to create a table for it. This is now partially fixed by pulling out the type of the elements (no recursion is done to populate nested tables)
This commit is contained in:
parent
98d91d0c2b
commit
056b5eba22
1 changed files with 20 additions and 1 deletions
|
@ -247,7 +247,8 @@ class MatrixUnits(Units):
|
||||||
"rows": [{
|
"rows": [{
|
||||||
"key": good_response["schema"].get("name", ""),
|
"key": good_response["schema"].get("name", ""),
|
||||||
"type": res_type,
|
"type": res_type,
|
||||||
"desc": res.get("description", "")
|
"desc": res.get("description", ""),
|
||||||
|
"req_str": ""
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
elif res_type and Units.prop(good_response, "schema/properties"):
|
elif res_type and Units.prop(good_response, "schema/properties"):
|
||||||
|
@ -257,6 +258,24 @@ class MatrixUnits(Units):
|
||||||
for table in res_tables:
|
for table in res_tables:
|
||||||
if "no-table" not in table:
|
if "no-table" not in table:
|
||||||
endpoint["res_tables"].append(table)
|
endpoint["res_tables"].append(table)
|
||||||
|
elif res_type and Units.prop(good_response, "schema/items"):
|
||||||
|
# response is an array:
|
||||||
|
# FIXME: Doesn't recurse at all.
|
||||||
|
schema = good_response["schema"]
|
||||||
|
array_type = Units.prop(schema, "items/type")
|
||||||
|
if Units.prop(schema, "items/allOf"):
|
||||||
|
array_type = (
|
||||||
|
Units.prop(schema, "items/title")
|
||||||
|
)
|
||||||
|
endpoint["res_tables"].append({
|
||||||
|
"title": schema.get("title", ""),
|
||||||
|
"rows": [{
|
||||||
|
"key": "N/A",
|
||||||
|
"type": ("[%s]" % array_type),
|
||||||
|
"desc": schema.get("description", ""),
|
||||||
|
"req_str": ""
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
endpoints.append(endpoint)
|
endpoints.append(endpoint)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue