Added 'type' to API item if applicable.

This commit is contained in:
Bez Hermoso 2014-07-24 12:18:33 -07:00
parent 9d3c0a8c29
commit abaeb374e8
2 changed files with 7 additions and 0 deletions

View File

@ -246,6 +246,8 @@ class SwaggerFormatter implements FormatterInterface
); );
} }
$type = isset($responseMessages[200]['responseModel']) ? $responseMessages[200]['responseModel'] : null;
foreach ($apiDoc->getRoute()->getMethods() as $method) { foreach ($apiDoc->getRoute()->getMethods() as $method) {
$operation = array( $operation = array(
'method' => $method, 'method' => $method,
@ -255,6 +257,10 @@ class SwaggerFormatter implements FormatterInterface
'responseMessages' => array_values($responseMessages), 'responseMessages' => array_values($responseMessages),
); );
if ($type !== null) {
$operation['type'] = $type;
}
$apiBag[$path][] = $operation; $apiBag[$path][] = $operation;
} }
} }

View File

@ -237,6 +237,7 @@ class SwaggerFormatterTest extends WebTestCase
'responseModel' => 'Nelmio.ApiDocBundle.Tests.Fixtures.Model.JmsNested', 'responseModel' => 'Nelmio.ApiDocBundle.Tests.Fixtures.Model.JmsNested',
), ),
), ),
'type' => 'Nelmio.ApiDocBundle.Tests.Fixtures.Model.JmsNested',
), ),
), ),
), ),