-
-
Notifications
You must be signed in to change notification settings - Fork 880
Open
Labels
Description
Version
v5.5.0
Description
I want to add response in documentation for all routes with my custom attribute. When I have single action with my attribute code works fine.
Problem occurs when I have more than one actions (separated classes).
Auth Warning: Multiple @OA\Response() with the same response="200":
<?php
final readonly class SuccessResponseRouteDescriber implements RouteDescriberInterface
{
use RouteDescriberTrait;
public function describe(OpenApi $api, Route $route, \ReflectionMethod $reflectionMethod): void
{
$attributes = $reflectionMethod->getDeclaringClass()->getAttributes(SuccessResponse::class);
if (!$attributes) {
return;
}
/** @var SuccessResponse $attribute */
$attribute = $attributes[0]->newInstance();
$model = new Model(type: $attribute->modelClass, groups: $attribute->groups);
$response = new OA\Response(...);
foreach ($this->getOperations($api, $route) as $operation) {
$operation->merge([$response]);
}
}
}
I found related issue #1900 but solution as I see was for old version and used class for reset context does not exist.
JSON OpenApi
JSON OpenApi
Replace this text with your JSON (`bin/console nelmio:apidoc:dump`)
Additional context
No response