{%- 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() %}