Implement nested tables for HTTP APIs. It even works(!)
This commit is contained in:
parent
0275c2ffa0
commit
14d004146b
3 changed files with 30 additions and 16 deletions
|
@ -113,7 +113,7 @@ class MatrixUnits(Units):
|
|||
"requires_auth": "security" in single_api,
|
||||
"rate_limited": 429 in single_api.get("responses", {}),
|
||||
"req_params": [],
|
||||
"res_params": [],
|
||||
"res_tables": [],
|
||||
"example": {
|
||||
"req": "",
|
||||
"res": ""
|
||||
|
@ -219,16 +219,19 @@ class MatrixUnits(Units):
|
|||
res_type = Units.prop(res, "schema/type")
|
||||
if res_type and res_type not in ["object", "array"]:
|
||||
# response is a raw string or something like that
|
||||
endpoint["res_params"].append({
|
||||
"key": res["schema"].get("name", ""),
|
||||
"type": res_type,
|
||||
"desc": res.get("description", "")
|
||||
endpoint["res_tables"].append({
|
||||
"title": None,
|
||||
"rows": [{
|
||||
"key": res["schema"].get("name", ""),
|
||||
"type": res_type,
|
||||
"desc": res.get("description", "")
|
||||
}]
|
||||
})
|
||||
elif res_type and Units.prop(res, "schema/properties"): # object
|
||||
res_tables = get_json_schema_object_fields(res["schema"])
|
||||
# TODO: Is this good enough or should we be doing multiple
|
||||
# tables for HTTP responses?!
|
||||
endpoint["res_params"] = res_tables[0]["rows"]
|
||||
for table in res_tables:
|
||||
if "no-table" not in table:
|
||||
endpoint["res_tables"].append(table)
|
||||
|
||||
endpoints.append(endpoint)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue