Merge pull request #34 from matrix-org/daniel/endpointaliases

Add ability to refer to aliases of endpoints
pull/977/head
Kegsay 9 years ago
commit 8ebe2377fe

@ -1,5 +1,10 @@
``{{endpoint.method}} {{endpoint.path}}`` ``{{endpoint.method}} {{endpoint.path}}``
{{(5 + (endpoint.path | length) + (endpoint.method | length)) * title_kind}} {{(5 + (endpoint.path | length) + (endpoint.method | length)) * title_kind}}
{% if "alias_for_path" in endpoint -%}
``{{endpoint.path}}`` is an alias for `{{endpoint.alias_for_path}}`_.
.. _`{{endpoint.alias_for_path}}`: #{{endpoint.alias_link}}
{% else -%}
{{endpoint.desc | wrap(80)}} {{endpoint.desc | wrap(80)}}
@ -62,3 +67,4 @@ Example::
{{res["example"] | indent_block(2)}} {{res["example"] | indent_block(2)}}
{% endfor %} {% endfor %}
{% endif -%}

@ -105,11 +105,12 @@ class MatrixUnits(Units):
for path in api["paths"]: for path in api["paths"]:
for method in api["paths"][path]: for method in api["paths"][path]:
single_api = api["paths"][path][method] single_api = api["paths"][path][method]
full_path = api.get("basePath", "") + path
endpoint = { endpoint = {
"title": single_api.get("summary", ""), "title": single_api.get("summary", ""),
"desc": single_api.get("description", single_api.get("summary", "")), "desc": single_api.get("description", single_api.get("summary", "")),
"method": method.upper(), "method": method.upper(),
"path": api.get("basePath", "") + path, "path": full_path,
"requires_auth": "security" in single_api, "requires_auth": "security" in single_api,
"rate_limited": 429 in single_api.get("responses", {}), "rate_limited": 429 in single_api.get("responses", {}),
"req_params": [], "req_params": [],
@ -247,6 +248,17 @@ class MatrixUnits(Units):
endpoints.append(endpoint) endpoints.append(endpoint)
aliases = single_api.get("x-alias", None)
if aliases:
alias_link = aliases["canonical-link"]
for alias in aliases["aliases"]:
endpoints.append({
"method": method.upper(),
"path": alias,
"alias_for_path": full_path,
"alias_link": alias_link
})
return { return {
"base": api.get("basePath"), "base": api.get("basePath"),
"group": group_name, "group": group_name,

Loading…
Cancel
Save