forked from nelmio/NelmioApiDocBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
method.html.twig
254 lines (231 loc) · 11.1 KB
/
method.html.twig
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<li class="{{ data.method|lower }} operation">
<div class="heading toggler">
<h3>
<span class="http_method">
<a>{{ data.method|upper }}</a>
</span>
{% if data.https %}
<img src="{{ asset('bundles/nelmioapidoc/image/lock.png') }}" class="padlock" />
{% endif %}
<span class="path">
{{ data.uri }}
</span>
</h3>
<ul class="options">
{% if data.description is defined %}
<li>{{ data.description }}</li>
{% endif %}
</ul>
</div>
<div class="content" style="display: {% if displayContent is defined and displayContent == true %}display{% else %}none{% endif %};">
<ul class="tabs">
<li class="selected" data-pane="content">Documentation</li>
{% if enableSandbox %}
<li data-pane="sandbox">Sandbox</li>
{% endif %}
</ul>
<div class="panes">
<div class="pane content selected">
{% if data.documentation is defined and data.documentation is not empty %}
<h4>Documentation</h4>
<div>{{ data.documentation|extra_markdown }}</div>
{% endif %}
{% if data.requirements is defined and data.requirements is not empty %}
<h4>Requirements</h4>
<table class="fullwidth">
<thead>
<tr>
<th>Name</th>
<th>Requirement</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for name, infos in data.requirements %}
<tr>
<td>{{ name }}</td>
<td>{{ infos.requirement }}</td>
<td>{{ infos.dataType }}</td>
<td>{{ infos.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if data.filters is defined and data.filters is not empty %}
<h4>Filters</h4>
<table class="fullwidth">
<thead>
<tr>
<th>Name</th>
<th>Information</th>
</tr>
</thead>
<tbody>
{% for name, infos in data.filters %}
<tr>
<td>{{ name }}</td>
<td>
<table>
{% for key, value in infos %}
<tr>
<td>{{ key|title }}</td>
<td>{{ value|json_encode|replace({'\\\\': '\\'})|trim('"') }}</td>
</tr>
{% endfor %}
</table>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if data.parameters is defined and data.parameters is not empty %}
<h4>Parameters</h4>
<table class='fullwidth'>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required?</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for name, infos in data.parameters %}
{% if not infos.readonly %}
<tr>
<td>{{ name }}</td>
<td>{{ infos.dataType }}</td>
<td>{{ infos.required ? 'true' : 'false' }}</td>
<td>{{ infos.description }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% endif %}
{% if data.response is defined and data.response is not empty %}
<h4>Return</h4>
<table class='fullwidth'>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for name, infos in data.response %}
<tr>
<td>{{ name }}</td>
<td>{{ infos.dataType }}</td>
<td>{{ infos.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if data.statusCodes is defined and data.statusCodes is not empty %}
<h4>Status Codes</h4>
<table class="fullwidth">
<thead>
<tr>
<th>Status Code</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for status_code, description in data.statusCodes %}
<tr>
<td><a href="http://en.wikipedia.org/wiki/HTTP_{{ status_code }}" target="_blank">{{ status_code }}<a/></td>
<td>{{ description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% if enableSandbox %}
<div class="pane sandbox">
<form method="{{ data.method|upper }}" action="{{ data.uri }}">
<fieldset class="parameters">
<legend>Input</legend>
{% if data.requirements is defined %}
<h4>Requirements</h4>
{% for name, infos in data.requirements %}
<p class="tuple">
<input type="text" class="key" value="{{ name }}" placeholder="Key" />
<span>=</span>
<input type="text" class="value" placeholder="{% if infos.description is defined %}{{ infos.description }}{% else %}Value{% endif %}" /> <span class="remove">-</span>
</p>
{% endfor %}
{% endif %}
{% if data.filters is defined %}
<h4>Filters</h4>
{% for name, infos in data.filters %}
<p class="tuple">
<input type="text" class="key" value="{{ name }}" placeholder="Key" />
<span>=</span>
<input type="text" class="value" placeholder="{% if infos.description is defined %}{{ infos.description }}{% else %}Value{% endif %}" /> <span class="remove">-</span>
</p>
{% endfor %}
{% endif %}
{% if data.parameters is defined %}
<h4>Parameters</h4>
{% for name, infos in data.parameters %}
{% if not infos.readonly %}
<p class="tuple">
<input type="text" class="key" value="{{ name }}" placeholder="Key" />
<span>=</span>
<input type="text" class="value" placeholder="{% if infos.dataType %}[{{ infos.dataType }}] {% endif %}{% if infos.description %}{{ infos.description }}{% else %}Value{% endif %}" /> <span class="remove">-</span>
</p>
{% endif %}
{% endfor %}
<button class="add">New parameter</button>
{% endif %}
</fieldset>
<fieldset class="headers">
<legend>Headers</legend>
<p class="tuple">
<input type="text" class="key" placeholder="Key" />
<span>=</span>
<input type="text" class="value" placeholder="Value" /> <span class="remove">-</span>
</p>
<button class="add">New header</button>
</fieldset>
<fieldset class="request-content">
<legend>Content</legend>
<textarea class="content" placeholder="Content set here will override the parameters that do not match the url"></textarea>
<p class="tuple">
<input type="text" class="key content-type" value="Content-Type" disabled="disabled" />
<span>=</span>
<input type="text" class="value" placeholder="Value" />
<button class="set-content-type">Set header</button> <small>Replaces header if set</small>
</p>
</fieldset>
<div class="buttons">
<input type="submit" value="Try!" />
</div>
</form>
<script type="text/x-tmpl" class="tuple_template">
<p class="tuple">
<input type="text" class="key" placeholder="Key" />
<span>=</span>
<input type="text" class="value" placeholder="Value" /> <span class="remove">-</span>
</p>
</script>
<div class="result">
<h4>Request URL</h4>
<pre class="url"></pre>
<h4>Response Headers <small>[<a href="" class="to-expand">Expand</a>]</small></h4>
<pre class="headers to-expand"></pre>
<h4>Response Body <small>[<a href="" class="to-raw">Raw</a>]</small></h4>
<pre class="response prettyprint"></pre>
</div>
</div>
{% endif %}
</div>
</div>
</li>