Skip to content

Commit b413b1b

Browse files
Group response objects in tabs for pymdownx #35 (#68)
* Group response codes in tab group on MkDocs output (issue #35) Each HTTP response code is now rendered as a pymdownx.tabbed tab (e.g. '=== "200 OK"') instead of a flat list, reducing vertical page length for APIs with many response codes. Content-type tabs are preserved nested inside each response tab. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Minor version bump * Add CHANGELOG entry for issue #35 under 1.4.0 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9eb7114 commit b413b1b

File tree

7 files changed

+1382
-1537
lines changed

7 files changed

+1382
-1537
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.3.1] - 2026-03-??
8+
## [1.4.0] - 2026-03-??
99

1010
- Add OAS 3.1 support, cross-version warnings, and fix nullable spacing, by @dcode.
1111
- Fix MARKDOWN style table separators to use minimum 3 hyphens (issue #39), reported by @michael-nok.
1212
- Fix [#45](https://github.com/Neoteroi/essentials-openapi/issues/45): add support for displaying descriptions of schema properties, reported by @Maia-Everett.
1313
- Fix [#30](https://github.com/Neoteroi/essentials-openapi/issues/30): raise an error
1414
when trying to generate output from an older Swagger v2 specification file (these were
1515
never supported as there was never a `/mk/v2/` namespace, intentionally).
16+
- Fix [#35](https://github.com/Neoteroi/essentials-openapi/issues/35): group response
17+
codes in a tab group on MkDocs output, reported by @Andre601.
1618

1719
## [1.3.0] - 2025-11-19
1820

openapidocs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "1.3.1"
1+
__version__ = "1.4.0"
22
VERSION = __version__
Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,50 @@
11
{% 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-
&nbsp;<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>
126
{%- 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 %}
2714

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>
3825

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 -%}
6350
{%- endfor -%}

0 commit comments

Comments
 (0)