matrix-doc/scripts/templating/matrix_templates/templates/http-api.tmpl

91 lines
1.7 KiB
Cheetah
Raw Permalink Normal View History

{% import 'tables.tmpl' as tables -%}
2015-06-01 11:03:42 +00:00
``{{endpoint.method}} {{endpoint.path}}``
{{(5 + (endpoint.path | length) + (endpoint.method | length)) * title_kind}}
2015-12-10 14:47:14 +00:00
{% if "deprecated" in endpoint and endpoint.deprecated -%}
.. WARNING::
This API is deprecated and will be removed from a future release.
{% endif -%}
2015-06-01 11:03:42 +00:00
{{endpoint.desc}}
{{":Rate-limited: Yes." if endpoint.rate_limited else "" }}
{{":Requires auth: Yes." if endpoint.requires_auth else "" }}
2018-08-31 12:55:27 +00:00
.. class:: httpheaders
Request format:
2015-11-11 11:39:40 +00:00
{% if (endpoint.req_param_by_loc | length) %}
{{ tables.split_paramtable(endpoint.req_param_by_loc) }}
2016-01-07 22:46:22 +00:00
{% if (endpoint.req_body_tables) %}
{% for table in endpoint.req_body_tables -%}
2018-08-30 16:01:27 +00:00
{{ tables.paramtable(table.rows, caption=(table.title or "")) }}
2018-08-29 15:38:59 +00:00
{% endfor -%}
{% endif -%}
2016-01-07 22:46:22 +00:00
2015-11-11 11:39:40 +00:00
{% else %}
`No parameters`
{% endif %}
2015-06-01 11:03:42 +00:00
{% if endpoint.res_headers is not none -%}
2018-08-31 12:55:27 +00:00
.. class:: httpheaders
Response headers:
{{ tables.paramtable(endpoint.res_headers.rows) }}
{% endif -%}
{% if endpoint.res_tables|length > 0 -%}
2018-08-31 12:55:27 +00:00
.. class:: httpheaders
Response format:
{% for table in endpoint.res_tables -%}
2018-08-30 16:01:27 +00:00
{{ tables.paramtable(table.rows, caption=(table.title or "")) }}
2018-08-29 15:38:59 +00:00
{% endfor %}
{% endif -%}
2018-08-31 12:55:27 +00:00
.. class:: httpheaders
Example request:
.. code:: http
{{endpoint.example.req | indent_block(2)}}
{% if endpoint.responses|length > 0 -%}
2018-08-31 12:55:27 +00:00
.. class:: httpheaders
Response{{"s" if endpoint.responses|length > 1 else "" }}:
{% endif -%}
{% for res in endpoint.responses -%}
**Status code {{res["code"]}}:**
{{res["description"]}}
{% if res["example"] -%}
2018-08-31 12:55:27 +00:00
.. class:: httpheaders
Example
.. code:: json
{{res["example"] | indent_block(2)}}
{% endif -%}
{% endfor %}