From ca8f1e1f67e9773519dbf85c963a6d8894c9718a Mon Sep 17 00:00:00 2001 From: Martijn Jacobs Date: Fri, 18 Oct 2019 16:46:18 +0200 Subject: [PATCH] Also render examples with a body field --- .../apistar/templates/layout/examples.html | 38 +++++++++---------- .../themes/apistar/templates/layout/link.html | 15 +++++++- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/apistar/themes/apistar/templates/layout/examples.html b/apistar/themes/apistar/templates/layout/examples.html index 87c8d40b..5cd478bc 100644 --- a/apistar/themes/apistar/templates/layout/examples.html +++ b/apistar/themes/apistar/templates/layout/examples.html @@ -1,20 +1,18 @@ -{% for field in fields %} - {% if field.examples %} -

Examples

-

parameter: {{ field.name }} - - - - - - {% for name, example in field.examples.items() %} - - - - - - {% endfor %} - -
NameValueSummary
{{ name }}{{ example.value|pprint }}{% if example.summary %}{{ example.summary }}{% endif %}
- {% endif %} -{% endfor %} +{% if examples %} +

Examples

+

parameter: {{ field.name }} + + + + + + {% for name, example in examples.items() %} + + + + + + {% endfor %} + +
NameValueSummary
{{ name }}{{ example.value|pprint }}{% if example.summary %}{{ example.summary }}{% endif %}
+{% endif %} \ No newline at end of file diff --git a/apistar/themes/apistar/templates/layout/link.html b/apistar/themes/apistar/templates/layout/link.html index cffbfc15..602d0a33 100644 --- a/apistar/themes/apistar/templates/layout/link.html +++ b/apistar/themes/apistar/templates/layout/link.html @@ -24,7 +24,11 @@

Path Parameters

{% endfor %} - {% include 'apistar/layout/examples.html' %} + {% for field in fields %} + {% with examples=field.examples %} + {% include 'apistar/layout/examples.html' %} + {% endwith %} + {% endfor %} {% endwith %} {% endif %} {% if link.get_query_fields() %} @@ -41,7 +45,11 @@

Query Parameters

{% endfor %} - {% include 'apistar/layout/examples.html' %} + {% for field in fields %} + {% with examples=field.examples %} + {% include 'apistar/layout/examples.html' %} + {% endwith %} + {% endfor %} {% endwith %} {% endif %} {% if link.get_body_field() %} @@ -63,6 +71,9 @@

Request Body

{% endif %} + {% with examples=field.examples %} + {% include 'apistar/layout/examples.html' %} + {% endwith %} {% endif %}