|
1 | 1 | {% for code, definition in operation.responses.items() %} |
2 | | - |
3 | | -<p class="response-title"> |
4 | | - {% if code == "default" -%} |
5 | | - <strong>{{texts.other_responses}}</strong> |
6 | | - {%- else -%} |
7 | | - <strong>Response <span class="response-code code-{{code}}">{{code}}</span> |
8 | | - {%- with phrase = get_http_status_phrase(code) -%} |
9 | | - {%- if phrase -%} |
10 | | - <span class="status-phrase">{{ phrase }}</span> |
11 | | - {%- endif -%} |
| 2 | +=== "{% if code == "default" %}{{texts.other_responses}}{% else %}{{code}}{% with phrase = get_http_status_phrase(code) %}{% if phrase %} {{ phrase }}{% endif %}{% endwith %}{% endif %}" |
| 3 | + {%- if is_reference(definition) -%} |
| 4 | + {%- with type_name = definition["$ref"].replace("#/components/responses/", "") %} |
| 5 | + <div class="common-response"><p>Refer to the common response description: <a href="#{{type_name.lower() | link}}" class="ref-link">{{type_name}}</a>.</p></div> |
12 | 6 | {%- endwith -%} |
13 | | - </strong> |
14 | | - {%- endif %} |
15 | | -</p> |
16 | | -{%- if is_reference(definition) -%} |
17 | | -{%- with type_name = definition["$ref"].replace("#/components/responses/", "") %} |
18 | | -<div class="common-response"><p>Refer to the common response description: <a href="#{{type_name.lower() | link}}" class="ref-link">{{type_name}}</a>.</p></div> |
19 | | -{%- endwith -%} |
20 | | -{%- endif -%} |
21 | | -{%- if definition.content %} |
22 | | -{%- with content = handler.simplify_content(definition.content) %} |
23 | | -{% for content_type, definition in content.items() %} |
24 | | -=== "{{content_type}}" |
25 | | - {% include "partial/content-examples.html" %} |
26 | | - {% if "alt_types" in definition %}<em class="small-note alt-types">{{texts.other_possible_types}}: {{definition.alt_types | join(", ")}}</em>{% endif %} |
| 7 | + {%- endif -%} |
| 8 | + {%- if definition.content %} |
| 9 | + {%- with content = handler.simplify_content(definition.content) %} |
| 10 | + {% for content_type, definition in content.items() %} |
| 11 | + === "{{content_type}}" |
| 12 | + {% include "partial/content-examples.html" %} |
| 13 | + {% if "alt_types" in definition %}<em class="small-note alt-types">{{texts.other_possible_types}}: {{definition.alt_types | join(", ")}}</em>{% endif %} |
27 | 14 |
|
28 | | - ??? hint "{{texts.schema_of_the_response_body}}" |
29 | | - ```json |
30 | | - {{handler.write_content_schema(definition) | indent(8) | safe}} |
31 | | - ``` |
32 | | -{% endfor %} |
33 | | -{% endwith -%} |
34 | | -{% endif -%} |
35 | | -{%- if definition.headers %} |
36 | | -<div class="response-section"> |
37 | | - <p class="response-headers sub-section-title">{{texts.response_headers}}</p> |
| 15 | + ??? hint "{{texts.schema_of_the_response_body}}" |
| 16 | + ```json |
| 17 | + {{handler.write_content_schema(definition) | indent(12) | safe}} |
| 18 | + ``` |
| 19 | + {% endfor %} |
| 20 | + {% endwith -%} |
| 21 | + {% endif -%} |
| 22 | + {%- if definition.headers %} |
| 23 | + <div class="response-section"> |
| 24 | + <p class="response-headers sub-section-title">{{texts.response_headers}}</p> |
38 | 25 |
|
39 | | - <table> |
40 | | - <thead> |
41 | | - <tr> |
42 | | - <th>{{texts.name}}</th> |
43 | | - <th>{{texts.description}}</th> |
44 | | - <th>{{texts.schema}}</th> |
45 | | - </tr> |
46 | | - </thead> |
47 | | - <tbody> |
48 | | - {%- for header_name, header_definition in definition.headers.items() %} |
49 | | - <tr> |
50 | | - <td><code>{{header_name}}</code></td> |
51 | | - <td>{{header_definition.description}}</td> |
52 | | - <td> |
53 | | - {%- with schema = header_definition.schema %} |
54 | | - {%- include "partial/schema-repr.html" -%} |
55 | | - {% endwith -%} |
56 | | - </td> |
57 | | - </tr> |
58 | | - {%- endfor %} |
59 | | - </tbody> |
60 | | - </table> |
61 | | -</div> |
62 | | -{% endif -%} |
| 26 | + <table> |
| 27 | + <thead> |
| 28 | + <tr> |
| 29 | + <th>{{texts.name}}</th> |
| 30 | + <th>{{texts.description}}</th> |
| 31 | + <th>{{texts.schema}}</th> |
| 32 | + </tr> |
| 33 | + </thead> |
| 34 | + <tbody> |
| 35 | + {%- for header_name, header_definition in definition.headers.items() %} |
| 36 | + <tr> |
| 37 | + <td><code>{{header_name}}</code></td> |
| 38 | + <td>{{header_definition.description}}</td> |
| 39 | + <td> |
| 40 | + {%- with schema = header_definition.schema %} |
| 41 | + {%- include "partial/schema-repr.html" -%} |
| 42 | + {% endwith -%} |
| 43 | + </td> |
| 44 | + </tr> |
| 45 | + {%- endfor %} |
| 46 | + </tbody> |
| 47 | + </table> |
| 48 | + </div> |
| 49 | + {% endif -%} |
63 | 50 | {%- endfor -%} |
0 commit comments