mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-13 04:59:24 +03:00
Fix
This commit is contained in:
parent
4c882d3c8c
commit
2422156f27
@ -20,6 +20,7 @@ use Nelmio\ApiDocBundle\Util\ControllerReflector;
|
|||||||
use Swagger\Analysis;
|
use Swagger\Analysis;
|
||||||
use Swagger\Annotations as SWG;
|
use Swagger\Annotations as SWG;
|
||||||
use Swagger\Context;
|
use Swagger\Context;
|
||||||
|
use Swagger\Annotations\AbstractAnnotation;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
|
|
||||||
final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelRegistryAwareInterface
|
final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelRegistryAwareInterface
|
||||||
@ -86,10 +87,13 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
|||||||
'method' => $method->name,
|
'method' => $method->name,
|
||||||
'filename' => $method->getFileName(),
|
'filename' => $method->getFileName(),
|
||||||
]);
|
]);
|
||||||
|
$nestedContext = clone $context;
|
||||||
|
$nestedContext->nested = true;
|
||||||
$implicitAnnotations = [];
|
$implicitAnnotations = [];
|
||||||
$tags = [];
|
$tags = [];
|
||||||
foreach ($annotations as $annotation) {
|
foreach ($annotations as $annotation) {
|
||||||
$annotation->_context = $context;
|
$annotation->_context = $context;
|
||||||
|
$this->updateNestedAnnotations($annotation, $nestedContext);
|
||||||
|
|
||||||
if ($annotation instanceof Operation) {
|
if ($annotation instanceof Operation) {
|
||||||
foreach ($httpMethods as $httpMethod) {
|
foreach ($httpMethods as $httpMethod) {
|
||||||
@ -170,4 +174,16 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
|||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function updateNestedAnnotations($value, Context $context) {
|
||||||
|
if ($value instanceof AbstractAnnotation) {
|
||||||
|
$value->_context = $context;
|
||||||
|
} elseif (!is_array($value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($value as $v) {
|
||||||
|
$this->updateNestedAnnotations($v, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ class ApiController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/test/{user}", methods={"GET"}, schemes={"https"}, requirements={"user"="/foo/"})
|
* @Route("/test/{user}", methods={"GET"}, schemes={"https"}, requirements={"user"="/foo/"})
|
||||||
|
* @Operation(
|
||||||
|
* @SWG\Response(response=200, description="sucessful")
|
||||||
|
* )
|
||||||
*/
|
*/
|
||||||
public function userAction()
|
public function userAction()
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,7 @@ class FunctionalTest extends WebTestCase
|
|||||||
$this->assertEmpty($operation->getSummary());
|
$this->assertEmpty($operation->getSummary());
|
||||||
$this->assertEmpty($operation->getDescription());
|
$this->assertEmpty($operation->getDescription());
|
||||||
$this->assertNull($operation->getDeprecated());
|
$this->assertNull($operation->getDeprecated());
|
||||||
|
$this->assertTrue($operation->getResponses()->has(200));
|
||||||
|
|
||||||
$parameters = $operation->getParameters();
|
$parameters = $operation->getParameters();
|
||||||
$this->assertTrue($parameters->has('user', 'path'));
|
$this->assertTrue($parameters->has('user', 'path'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user