Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
Also render examples with a body field
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Jacobs committed Oct 18, 2019
1 parent 5784927 commit ca8f1e1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
38 changes: 18 additions & 20 deletions apistar/themes/apistar/templates/layout/examples.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{% for field in fields %}
{% if field.examples %}
<h4>Examples</h4>
<p>parameter: <code>{{ field.name }}</code>
<table class="parameters table table-bordered table-striped">
<thead>
<tr><th>Name</th><th>Value</th><th>Summary</th></tr>
</thead>
<tbody>
{% for name, example in field.examples.items() %}
<tr>
<td>{{ name }}</td>
<td ><code>{{ example.value|pprint }}</code></td>
<td>{% if example.summary %}{{ example.summary }}{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endfor %}
{% if examples %}
<h4>Examples</h4>
<p>parameter: <code>{{ field.name }}</code>
<table class="parameters table table-bordered table-striped">
<thead>
<tr><th>Name</th><th>Value</th><th>Summary</th></tr>
</thead>
<tbody>
{% for name, example in examples.items() %}
<tr>
<td>{{ name }}</td>
<td ><code>{{ example.value|pprint }}</code></td>
<td>{% if example.summary %}{{ example.summary }}{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
15 changes: 13 additions & 2 deletions apistar/themes/apistar/templates/layout/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ <h4>Path Parameters</h4>
{% endfor %}
</tbody>
</table>
{% 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() %}
Expand All @@ -41,7 +45,11 @@ <h4>Query Parameters</h4>
{% endfor %}
</tbody>
</table>
{% 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() %}
Expand All @@ -63,6 +71,9 @@ <h4>Request Body</h4>
{% endif %}
</tbody>
</table>
{% with examples=field.examples %}
{% include 'apistar/layout/examples.html' %}
{% endwith %}
{% endif %}
</div>

Expand Down

0 comments on commit ca8f1e1

Please sign in to comment.