Use the response map in the html view

This commit is contained in:
Adam Prager 2016-01-26 04:21:08 +01:00
parent 5d9c47bbad
commit 7919b24971
4 changed files with 41 additions and 16 deletions

View File

@ -675,6 +675,10 @@ class ApiDoc
$data['response'] = $response;
}
if ($parsedResponseMap = $this->parsedResponseMap) {
$data['parsedResponseMap'] = $parsedResponseMap;
}
if ($statusCodes = $this->statusCodes) {
$data['statusCodes'] = $statusCodes;
}

View File

@ -129,6 +129,12 @@ abstract class AbstractFormatter implements FormatterInterface
$annotation['response'] = $this->compressNestedParameters($annotation['response']);
}
if (isset($annotation['parsedResponseMap'])) {
foreach ($annotation['parsedResponseMap'] as $statusCode => &$data) {
$data['model'] = $this->compressNestedParameters($data['model']);
}
}
$annotation['id'] = strtolower($annotation['method']).'-'.str_replace('/', '-', $annotation['uri']);
return $annotation;

View File

@ -30,7 +30,10 @@ class SimpleFormatter extends AbstractFormatter
{
$array = array();
foreach ($collection as $coll) {
$array[$coll['resource']][] = $coll['annotation']->toArray();
$annotationArray = $coll['annotation']->toArray();
unset($annotationArray['parsedResponseMap']);
$array[$coll['resource']][] = $annotationArray;
}
return $array;

View File

@ -139,27 +139,39 @@
</table>
{% endif %}
{% if data.response is defined and data.response is not empty %}
{% if data.parsedResponseMap is defined and data.parsedResponseMap is not empty %}
<h4>Return</h4>
<table class='fullwidth'>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Versions</th>
<th>Description</th>
</tr>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Versions</th>
<th>Description</th>
</tr>
</thead>
{% for status_code, response in data.parsedResponseMap %}
<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 %}
<tr>
<td>
<h4>
{{ status_code }}
{% if data.statusCodes[status_code] is defined %}
- {{ data.statusCodes[status_code]|join(', ') }}
{% endif %}
</h4>
</td>
</tr>
{% for name, infos in response.model %}
<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>
{% endfor %}
</table>
{% endif %}