mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-11 18:16:13 +03:00
Fix a regression about manual paths in operation no longer being taken into account
This commit is contained in:
parent
ba3fe1cdfa
commit
42365c71cc
@ -87,6 +87,13 @@ final class OpenApiPhpDescriber
|
||||
}
|
||||
|
||||
if ($annotation instanceof OA\Operation) {
|
||||
if (!in_array($annotation->method, $httpMethods, true)) {
|
||||
continue;
|
||||
}
|
||||
if (OA\UNDEFINED !== $annotation->path && $path->path !== $annotation->path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$operation = Util::getOperation($path, $annotation->method);
|
||||
$operation->mergeProperties($annotation);
|
||||
|
||||
|
@ -54,6 +54,14 @@ class ApiController
|
||||
* @Operation(
|
||||
* @OA\Response(response="201", description="An example resource")
|
||||
* )
|
||||
* @OA\Get(
|
||||
* path="/api/swagger2",
|
||||
* @OA\Parameter(name="Accept-Version", in="header", @OA\Schema(type="string"))
|
||||
* )
|
||||
* @OA\Post(
|
||||
* path="/api/swagger2",
|
||||
* @OA\Response(response="203", description="but 203 is not actually allowed (wrong method)")
|
||||
* )
|
||||
*/
|
||||
public function swaggerAction()
|
||||
{
|
||||
|
@ -80,6 +80,18 @@ class FunctionalTest extends WebTestCase
|
||||
return [['/api/swagger'], ['/api/swagger2']];
|
||||
}
|
||||
|
||||
public function testAnnotationWithManualPath()
|
||||
{
|
||||
$path = $this->getPath('/api/swagger2');
|
||||
$this->assertSame(OA\UNDEFINED, $path->post);
|
||||
|
||||
$operation = $this->getOperation('/api/swagger', 'get');
|
||||
$this->assertNotHasParameter('Accept-Version', 'header', $operation);
|
||||
|
||||
$operation = $this->getOperation('/api/swagger2', 'get');
|
||||
$this->assertHasParameter('Accept-Version', 'header', $operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider implicitSwaggerActionMethodsProvider
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user