diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php
index aac6f38..004f4bb 100644
--- a/Annotation/ApiDoc.php
+++ b/Annotation/ApiDoc.php
@@ -126,7 +126,9 @@ class ApiDoc
}
if (isset($data['statusCodes'])) {
- $this->statusCodes = $data['statusCodes'];
+ foreach ($data['statusCodes'] as $statusCode => $description) {
+ $this->addStatusCode($statusCode, $description);
+ }
}
}
@@ -139,6 +141,15 @@ class ApiDoc
$this->filters[$name] = $filter;
}
+ /**
+ * @param string $statusCode
+ * @param mixed $description
+ */
+ public function addStatusCode($statusCode, $description)
+ {
+ $this->statusCodes[$statusCode] = !is_array($description) ? array($description) : $description;
+ }
+
/**
* @param string $name
* @param array $requirement
diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig
index e623f13..1b93832 100644
--- a/Resources/views/method.html.twig
+++ b/Resources/views/method.html.twig
@@ -136,24 +136,30 @@
{% endif %}
- {% if data.statusCodes is defined and data.statusCodes is not empty %}
-
Status Codes
-
-
+ {% if data.statusCodes is defined and data.statusCodes is not empty %}
+ Status Codes
+
+
Status Code |
Description |
-
-
- {% for status_code, description in data.statusCodes %}
-
- {{ status_code }} |
- {{ description }} |
-
+
+
+ {% for status_code, descriptions in data.statusCodes %}
+
+ {{ status_code }} |
+
+
+ {% for description in descriptions %}
+ - {{ description }}
+ {% endfor %}
+
+ |
+
{% endfor %}
-
-
+
+
{% endif %}
diff --git a/Tests/Annotation/ApiDocTest.php b/Tests/Annotation/ApiDocTest.php
index c03b280..a285e68 100644
--- a/Tests/Annotation/ApiDocTest.php
+++ b/Tests/Annotation/ApiDocTest.php
@@ -174,13 +174,17 @@ class ApiDocTest extends TestCase
$this->assertEquals($data['input'], $annot->getInput());
}
- public function testConstructWithHTTPResponseCodes()
+ public function testConstructWithStatusCodes()
{
$data = array(
'description' => 'Heya',
'statusCodes' => array(
200 => "Returned when successful",
- 403 => "Returned when the user is not authorized"
+ 403 => "Returned when the user is not authorized",
+ 404 => array(
+ "Returned when the user is not found",
+ "Returned when when something else is not found"
+ )
)
);
@@ -190,7 +194,7 @@ class ApiDocTest extends TestCase
$this->assertTrue(is_array($array));
$this->assertTrue(is_array($array['statusCodes']));
foreach ($data['statusCodes'] as $code => $message) {
- $this->assertEquals($array['statusCodes'][$code], $message);
+ $this->assertEquals($array['statusCodes'][$code], !is_array($message) ? array($message) : $message);
}
}
}