mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +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\Annotations as SWG;
|
||||
use Swagger\Context;
|
||||
use Swagger\Annotations\AbstractAnnotation;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelRegistryAwareInterface
|
||||
@ -86,10 +87,13 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
||||
'method' => $method->name,
|
||||
'filename' => $method->getFileName(),
|
||||
]);
|
||||
$nestedContext = clone $context;
|
||||
$nestedContext->nested = true;
|
||||
$implicitAnnotations = [];
|
||||
$tags = [];
|
||||
foreach ($annotations as $annotation) {
|
||||
$annotation->_context = $context;
|
||||
$this->updateNestedAnnotations($annotation, $nestedContext);
|
||||
|
||||
if ($annotation instanceof Operation) {
|
||||
foreach ($httpMethods as $httpMethod) {
|
||||
@ -170,4 +174,16 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
||||
|
||||
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/"})
|
||||
* @Operation(
|
||||
* @SWG\Response(response=200, description="sucessful")
|
||||
* )
|
||||
*/
|
||||
public function userAction()
|
||||
{
|
||||
|
@ -92,6 +92,7 @@ class FunctionalTest extends WebTestCase
|
||||
$this->assertEmpty($operation->getSummary());
|
||||
$this->assertEmpty($operation->getDescription());
|
||||
$this->assertNull($operation->getDeprecated());
|
||||
$this->assertTrue($operation->getResponses()->has(200));
|
||||
|
||||
$parameters = $operation->getParameters();
|
||||
$this->assertTrue($parameters->has('user', 'path'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user