-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathoperation_detail.html
More file actions
206 lines (196 loc) · 12.8 KB
/
Copy pathoperation_detail.html
File metadata and controls
206 lines (196 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{% from "operations/macros.html" import param_type, param_type_simple, x_origin, tags, breadcrumb %}
{% from "operations/schema_table.html" import render_schema_table %}
{% from "operations/examples.html" import render_examples, render_examples_summary %}
{% from "operations/try_it_out.html" import render_try_it_out %}
{% macro render_operation(operation, icons_path='assets/icons') %}
{% set method_class = operation.method|lower %}
<section id="op-{{ operation.operationId }}" class="content-section operation-detail"
data-path="{{ operation.path }}"
data-method="{{ operation.method }}">
{{ breadcrumb(operation.path) }}
{# Title First #}
<div class="operation-title-header">
<h3 class="operation-title">
{{ operation.operationId|titleize_operation }}
<span class="operation-id-inline">{{ operation.operationId }}</span>
</h3>
</div>
{# Method and URL Second #}
<div class="operation-header-detail">
<div class="operation-title-row">
<span class="method method-{{ method_class }}">{{ operation.method }}</span>
<code class="operation-url-bar" data-op-id="{{ operation.operationId }}" data-path="{{ operation.path }}"></code>
{% if operation.deprecated %}<span class="badge badge-deprecated">DEPRECATED</span>{% endif %}
</div>
</div>
<div class="operation-content-wrapper" id="op-container-{{ operation.operationId }}">
<div class="operation-try-panel">
<div class="try-panel-header">
<h4>Try it out</h4>
<div class="try-header-actions">
<span class="try-spinner" id="spinner-{{ operation.operationId }}" style="display:none" aria-live="polite">Sending</span>
<button class="btn-send" onclick="sendRequest('{{ operation.operationId }}', this)">
<img src="{{ icons_path }}/send-icon.svg" alt="" width="13" height="11">
<span>Send</span>
</button>
<button class="btn-copy-curl" onclick="copyCurlCommand('{{ operation.operationId }}', this)">
<img src="{{ icons_path }}/copy-curl-icon.svg" alt="" width="13" height="13">
<span>Copy cURL</span>
</button>
<button class="btn-expand-try" onclick="toggleTryItOutExpand('{{ operation.operationId }}')"
aria-label="Expand try it out panel" title="Expand">
<img src="{{ icons_path }}/expand.svg" alt="" width="16" height="16">
</button>
</div>
</div>
{{ render_try_it_out(operation) }}
</div>
<div class="operation-main-content">
{{ tags(operation.tags|default([])) }}
{% set desc = operation.description|default('') or operation.summary|default('') %}
{% if desc %}
<div class="operation-description">{{ desc|md }}</div>
{% endif %}
{% if operation.parameters %}
{% set params_by_location = {} %}
{% for param in operation.parameters %}
{% set param_in = param['in'] %}
{% if param_in not in params_by_location %}
{% set _ = params_by_location.__setitem__(param_in, []) %}
{% endif %}
{% set _ = params_by_location[param_in].append(param) %}
{% endfor %}
{% set param_order = ['path', 'query', 'header', 'cookie'] %}
{% for location in param_order %}
{% if location in params_by_location %}
<div class="operation-subsection">
<h4>{{ location|capitalize }} Parameters</h4>
<div class="params-list">
{% for param in params_by_location[location] %}
{% set param_desc = param.description|md if param.description else '' %}
{% set param_xorigin = x_origin(param) %}
{% set full_desc = param_desc ~ param_xorigin %}
{% set schema = param.schema|default({}) %}
{% set has_constraints = schema.minimum is defined or schema.maximum is defined or schema.minLength is defined or schema.maxLength is defined or schema.pattern is defined %}
{% set should_collapse = param_desc|should_collapse_description or has_constraints or param.get('x-origin') %}
<div class="param-item{% if should_collapse %} has-collapsible{% endif %}">
<div class="param-header">
{% if should_collapse %}
<button class="param-collapse-toggle" onclick="toggleParamDescription(this)" aria-label="Toggle description">
<svg viewBox="0 0 16 16" fill="none"><path d="M6 4L10 8L6 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
</button>
{% endif %}
<span class="param-name-wrapper">
<code>{{ param.name }}</code>{% if param.required %} <span class="param-required" aria-label="required" title="Required">*</span>{% endif %}:
</span>
<code class="param-type-inline">{{ param_type_simple(schema) }}</code>
</div>
{% if param.description or has_constraints or param.get('x-origin') %}
<div class="param-description-wrapper{% if should_collapse %} collapsed{% endif %}">
{% if param.description %}
<div class="param-description">{{ param_desc|safe }}</div>
{% endif %}
{% if has_constraints %}
<div class="param-constraints">
{%- if schema.minimum is defined -%}min: {{ schema.minimum }}{%- endif -%}
{%- if schema.maximum is defined -%}{% if schema.minimum is defined %}, {% endif %}max: {{ schema.maximum }}{%- endif -%}
{%- if schema.minLength is defined -%}{% if schema.minimum is defined or schema.maximum is defined %}, {% endif %}minLength: {{ schema.minLength }}{%- endif -%}
{%- if schema.maxLength is defined -%}{% if schema.minLength is defined %}, {% endif %}maxLength: {{ schema.maxLength }}{%- endif -%}
{%- if schema.pattern is defined -%}{% if schema.minimum is defined or schema.maximum is defined or schema.minLength is defined or schema.maxLength is defined %}, {% endif %}pattern: <code>{{ schema.pattern }}</code>{%- endif -%}
</div>
{% endif %}
{% if param.get('x-origin') %}
{{ param_xorigin|safe }}
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% if operation.requestBody %}
{% set rb = operation.requestBody %}
<div class="operation-subsection">
<div class="section-header-with-badge">
<h4>Request Body{% if rb.required %} <span class="param-required" aria-label="required" title="Required">*</span>{% endif %}</h4>
{% set content_types = rb.content_types|default([]) %}
{% if 'application/json' in content_types %}
<span class="content-type-badge">json</span>
{% elif content_types %}
<span class="content-type-badge">{{ content_types[0]|replace('application/', '')|replace('text/', '') }}</span>
{% endif %}
</div>
{% for ct, props in rb.schemas|default({})|items %}
{{ render_schema_table(props, '') }}
{% endfor %}
{% if rb.examples %}
<details class="response-examples-section">
<summary class="examples-summary">{{ render_examples_summary() }}</summary>
<div class="examples-container">
{{ render_examples(rb.examples) }}
</div>
</details>
{% endif %}
</div>
{% endif %}
{% if operation.responses %}
<div class="operation-subsection">
{% set first_status = operation.responses.keys()|list|first %}
{% set first_response = operation.responses[first_status] %}
{% set first_response_content_types = first_response.schemas.keys()|list if first_response.schemas else [] %}
<div class="response-header-with-selector">
<h4>Response</h4>
<div class="response-header-controls">
<div class="response-status-selector">
<button class="status-selector-button" onclick="toggleStatusDropdown('{{ operation.operationId }}')" aria-label="Select response status">
<span class="selected-status" id="selected-status-{{ operation.operationId }}">
{% set status_num = first_status|string %}
<span class="status-dot status-dot-{% if status_num.startswith('2') %}2xx{% elif status_num.startswith('4') %}4xx{% else %}default{% endif %}"></span>
{{ first_status }}
</span>
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
<path d="M3 4.5L6 7.5L9 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<div class="status-dropdown-menu" id="status-dropdown-{{ operation.operationId }}" style="display:none">
{% for status in operation.responses.keys()|sort %}
{% set status_num = status|string %}
<button class="status-dropdown-item" onclick="selectResponseStatus('{{ operation.operationId }}', '{{ status }}')">
<span class="status-dot status-dot-{% if status_num.startswith('2') %}2xx{% elif status_num.startswith('4') %}4xx{% else %}default{% endif %}"></span>
{{ status }}
</button>
{% endfor %}
</div>
</div>
<span class="content-type-badge" id="content-type-badge-{{ operation.operationId }}" style="{% if 'application/json' not in first_response_content_types and not first_response_content_types %}display:none{% endif %}">
{% if 'application/json' in first_response_content_types %}json{% elif first_response_content_types %}{{ first_response_content_types[0]|replace('application/', '')|replace('text/', '') }}{% endif %}
</span>
</div>
</div>
{% for status, response in operation.responses|dictsort %}
<div class="response-content" id="response-{{ operation.operationId }}-{{ status }}" data-content-types="{{ response.schemas.keys()|list|tojson|replace('"', '"') }}" {% if not loop.first %}style="display:none"{% endif %}>
{% if response.description %}
<div class="param-description">{{ response.description|md }}</div>
{% endif %}
{% for ct, props in response.schemas|default({})|items %}
{{ render_schema_table(props) }}
{% endfor %}
{% if response.examples %}
<details class="response-examples-section">
<summary class="examples-summary">{{ render_examples_summary() }}</summary>
<div class="examples-container">
{{ render_examples(response.examples) }}
</div>
</details>
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
</section>
{% endmacro %}