Merge pull request #791 from Padam87/response-map

Use the response map in the html view
This commit is contained in:
William Durand 2016-02-24 17:49:33 +01:00
commit 364ef73680
4 changed files with 41 additions and 16 deletions

View File

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

View File

@ -129,6 +129,12 @@ abstract class AbstractFormatter implements FormatterInterface
$annotation['response'] = $this->compressNestedParameters($annotation['response']); $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']); $annotation['id'] = strtolower($annotation['method']).'-'.str_replace('/', '-', $annotation['uri']);
return $annotation; return $annotation;

View File

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

View File

@ -139,7 +139,7 @@
</table> </table>
{% endif %} {% 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> <h4>Return</h4>
<table class='fullwidth'> <table class='fullwidth'>
<thead> <thead>
@ -150,8 +150,19 @@
<th>Description</th> <th>Description</th>
</tr> </tr>
</thead> </thead>
{% for status_code, response in data.parsedResponseMap %}
<tbody> <tbody>
{% for name, infos in data.response %} <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> <tr>
<td>{{ name }}</td> <td>{{ name }}</td>
<td>{{ infos.dataType }}</td> <td>{{ infos.dataType }}</td>
@ -160,6 +171,7 @@
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
{% endfor %}
</table> </table>
{% endif %} {% endif %}