{%- set tag_groups = handler.doc.get('x-tagGroups', []) -%} {%- set all_operations = handler.get_operations() -%} {%- set has_groups = tag_groups | length > 0 -%} {%- set rendered_tags = [] -%} {#- Build ordered render list: (group_name or none, tag, operations) -#} {%- set render_list = [] -%} {%- for group in tag_groups -%} {%- for group_tag in group.tags -%} {%- if group_tag in all_operations -%} {%- set _ = render_list.append({'group': group.name, 'tag': group_tag, 'operations': all_operations[group_tag]}) -%} {%- set _ = rendered_tags.append(group_tag) -%} {%- endif -%} {%- endfor -%} {%- endfor -%} {%- for tag, operations in all_operations.items() -%} {%- if tag not in rendered_tags -%} {%- set _ = render_list.append({'group': none, 'tag': tag, 'operations': operations}) -%} {%- endif -%} {%- endfor -%} {%- set ns = namespace(current_group='__unset__') -%} {%- for entry in render_list -%} {#- Emit group heading when entering a new group -#} {%- if has_groups and entry.group and entry.group != ns.current_group -%} {%- set ns.current_group = entry.group %} ## {{ entry.group }} {% endif -%} {%- if has_groups and entry.group %} ### {{entry.tag}} {%- else %} ## {{entry.tag or "Other"}} {%- endif %} {%- for tag_obj in tags -%} {%- if tag_obj.name == entry.tag %} {{ read_dict(tag_obj, "description", default="") }} {%- endif -%} {%- endfor %} {#- Set heading prefix for endpoints based on whether we're inside a group -#} {%- set ep_heading = '####' if (has_groups and entry.group) else '###' %} {% for path, definition in entry.operations %} {%- for http_method, operation in definition.items() %}
{{ep_heading}} {% if "summary" in operation -%}{{operation.summary}}{%- else -%}{{http_method.upper()}} {{path | route | safe}}{%- endif %}{% if operation.deprecated %} {% endif %} {{http_method.upper()}} [{{path | route | safe}}]({{ servers[0].url if servers else '' }}{{path}}) {%- if operation.deprecated %} /// admonition | Deprecated Endpoint type: warning /// {%- endif %} {%- if operation.description %} {{operation.description | wordwrap(80)}} {% endif %} {%- with parameters = handler.get_parameters(operation) -%} {%- if parameters %} {% include "partial/request-parameters.html" %} {%- endif -%} {%- endwith -%} {%- if operation.requestBody %} {% include "partial/request-body.html" %} {%- endif %} {%- if operation.responses %} {%- include "partial/request-responses.html" %} {%- endif %} {%- set code_samples = operation.get('x-codeSamples') -%} /// details | {{texts.code_samples or 'Code Samples'}} open: True type: example {%- if code_samples %} {% for sample in code_samples -%} //// tab | {{ (sample.label or sample.lang) }} ```{{ sample.lang }} {{ sample.source }} ``` {% if not loop.last %} {% endif -%} //// {% endfor %} {%- else %} {% include "partial/auto-code-samples.html" with context %} {%- endif %} /// {% endfor %} {% endfor %} {%- endfor %}