mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
74d30d9e39
Sometimes required parameters are not used through routing but still they are mandatory. I wanted to have API with resource.json?foo=bar&something=else format, that was possible through QueryParam annotation or requirements in routing BUT! There was no way to set dataType or description This PR solves problem for me. Side note: if you want to declare e.g. _format requirement through Annotation or any other param that is used in url ({foo} format) then it won't work. Because Bundle still overrides requirements and parameters after the constuctor in ApiDoc is called. This might be solved in separate PR by adding check if given requirements or parameters was already defined.
296 lines
13 KiB
Twig
296 lines
13 KiB
Twig
<li class="{{ data.method|lower }} operation" id="{{ data.id }}">
|
|
<a class="heading toggler{% if data.deprecated %} deprecated{% endif %}" href="#{{ data.id }}">
|
|
<h3>
|
|
<span class="http_method">
|
|
<i>{{ data.method|upper }}</i>
|
|
</span>
|
|
|
|
{% if data.deprecated %}
|
|
<span class="deprecated">
|
|
<i>DEPRECATED</i>
|
|
</span>
|
|
{% endif %}
|
|
|
|
{% if data.https %}
|
|
<span class="icon lock" title="HTTPS"></span>
|
|
{% endif %}
|
|
{% if data.authentication %}
|
|
<span class="icon keys" title="Needs authentication"></span>
|
|
{% endif %}
|
|
|
|
<span class="path">
|
|
{% if data.host is defined -%}
|
|
{{ data.https ? 'https://' : 'http://' -}}
|
|
{{ data.host -}}
|
|
{% endif -%}
|
|
{{ data.uri }}
|
|
</span>
|
|
</h3>
|
|
<ul class="options">
|
|
{% if data.description is defined %}
|
|
<li>{{ data.description }}</li>
|
|
{% endif %}
|
|
</ul>
|
|
</a>
|
|
|
|
<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.link is defined and data.link is not empty %}
|
|
<h4>Link</h4>
|
|
<div><a href="{{ data.link }}" target="_blank">{{ data.link }}</a></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>Format</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for name, infos in data.parameters %}
|
|
{% if not infos.readonly %}
|
|
<tr>
|
|
<td>{{ name }}</td>
|
|
<td>{{ infos.dataType is defined ? infos.dataType : '' }}</td>
|
|
<td>{{ infos.required ? 'true' : 'false' }}</td>
|
|
<td>{{ infos.format }}</td>
|
|
<td>{{ infos.description is defined ? 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>Versions</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for name, infos in data.response %}
|
|
<tr>
|
|
<td>{{ name }}</td>
|
|
<td>{{ infos.dataType }}</td>
|
|
<td>{% include 'NelmioApiDocBundle:Components:version.html.twig' with {'sinceVersion': infos.sinceVersion, 'untilVersion': infos.untilVersion} only %}</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, descriptions in data.statusCodes %}
|
|
<tr>
|
|
<td><a href="http://en.wikipedia.org/wiki/HTTP_{{ status_code }}" target="_blank">{{ status_code }}<a/></td>
|
|
<td>
|
|
<ul>
|
|
{% for description in descriptions %}
|
|
<li>{{ description }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% endif %}
|
|
|
|
{% if data.cache is defined and data.cache is not empty %}
|
|
<h4>Cache</h4>
|
|
<div>{{ data.cache }}s</div>
|
|
{% 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.format %}{{ infos.format }}{% 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>
|
|
|
|
{% if acceptType %}
|
|
<p class="tuple">
|
|
<input type="text" class="key" value="Accept" />
|
|
<span>=</span>
|
|
<input type="text" class="value" value="{{ acceptType }}" /> <span class="remove">-</span>
|
|
</p>
|
|
{% endif %}
|
|
|
|
<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>
|