Use table subsections for param locations instead of an extra column.

pull/977/head
Kegan Dougal 10 years ago
parent ba6ce16509
commit f6c98f41e9

@ -107,7 +107,7 @@ paths:
type: object
example: |-
{
"avatar_url": "mxc:/matrix.org/wefh34uihSDRGhw34"
"avatar_url": "mxc://matrix.org/wefh34uihSDRGhw34"
}
properties:
avatar_url:

@ -8,14 +8,17 @@
Request format:
================== ================= =========== ===============================
Parameter Param Location Param Type Description
================== ================= =========== ===============================
{% for param in endpoint.req_params -%}
{{param.name}}{{param.loc|indent(19-param.name|length)}}{{param.type|indent(37-19-
param.loc|length)}}{{param.desc|indent(12-param.type|length)|wrap(31)|indent_block(49)}}
================== ================= ===========================================
Parameter Value Description
================== ================= ===========================================
{% for loc in endpoint.req_param_by_loc -%}
**{{loc}} parameters**
--------------------------------------------------------------------------------
{% for param in endpoint.req_param_by_loc[loc] -%}
{{param.name}}{{param.type|indent(19-param.name|length)}}{{param.desc|indent(18-param.type|length)|wrap(43)|indent_block(37)}}
{% endfor %}
================== ================= =========== ===============================
{% endfor %}
================== ================= ===========================================
Example request::

@ -112,9 +112,6 @@ class MatrixUnits(Units):
"requires_auth": "security" in single_api,
"rate_limited": 429 in single_api.get("responses", {}),
"req_params": [],
"responses": [
# { code: 200, [ {row_info} ]}
],
"example": {
"req": "",
"res": ""
@ -164,35 +161,24 @@ class MatrixUnits(Units):
for key in json_body:
endpoint["req_params"].append({
"name": key,
"loc": "JSON",
"loc": "JSON body",
"type": json_body[key]["type"],
"desc": json_body[key]["description"]
})
# endfor[param]
# add main response format first.
res200 = single_api["responses"][200]
res200params = []
if res200["schema"].get("type") != "object":
res200params = [{
"title": "Response",
"rows": [{
"key": res200["schema"]["name"],
"type": res200["schema"]["type"],
"desc": res200["schema"].get("description", "")
}]
}]
elif res200["schema"].get("properties"):
res200params = get_json_schema_object_fields(
res200["schema"]
)
ok_res = {
"code": 200,
"http": "200 OK",
"desc": res200["description"],
"params": res200params
# group params by location to ease templating
endpoint["req_param_by_loc"] = {
# path: [...], query: [...], body: [...]
}
for p in endpoint["req_params"]:
if p["loc"] not in endpoint["req_param_by_loc"]:
endpoint["req_param_by_loc"][p["loc"]] = []
endpoint["req_param_by_loc"][p["loc"]].append(p)
# add example response if it has one
endpoint["example"]["res"] = res200.get("examples", {}).get(
res = single_api["responses"][200] # get the 200 OK response
endpoint["example"]["res"] = res.get("examples", {}).get(
"application/json", ""
)
# form example request if it has one. It "has one" if all params
@ -227,9 +213,8 @@ class MatrixUnits(Units):
"The following parameters are missing examples :( \n %s" %
[ p["name"] for p in params_missing_examples ]
)
endpoint["responses"].append(ok_res)
endpoints.append(endpoint)
return {
"base": api.get("basePath"),
"group": group_name,

Loading…
Cancel
Save