Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response attribute must not be repeated error #31

Closed
hansensalim opened this issue Feb 16, 2021 · 1 comment
Closed

Response attribute must not be repeated error #31

hansensalim opened this issue Feb 16, 2021 · 1 comment

Comments

@hansensalim
Copy link

Hi, I have just upgraded to v1.0.2 from v0 and I'm unable to generate the API doc when there is multiple responses in a single controller method. My code looks like this:

#[OpenApi\Operation(id: 'invitationAccept', tags: ['Invitation'])]
#[OpenApi\Parameters(factory: DefaultHeaderParameters::class)]
#[OpenApi\Response(factory: SuccessResponse::class, statusCode: 200)]
#[OpenApi\Response(factory: BadRequestResponse::class, statusCode: 400)]
public function accept(Invitation $invitation)
{
   ...
}

And I get this error when running the openapi:generate command:

  Attribute "Vyuldashev\LaravelOpenApi\Attributes\Response" must not be repeated

  at vendor/vyuldashev/laravel-openapi/src/RouteInformation.php:84
     80▕             $controllerAttributes = collect($reflectionClass->getAttributes())
     81▕                 ->map(fn(ReflectionAttribute $attribute) => $attribute->newInstance());
     82▕ 
     83▕             $actionAttributes = collect($reflectionMethod->getAttributes())
  ➜  84▕                 ->map(fn(ReflectionAttribute $attribute) => $attribute->newInstance());
     85▕ 
     86▕             $instance->domain = $route->domain();
     87▕             $instance->method = $method;
     88▕             $instance->uri = Str::start($route->uri(), '/');

      +4 vendor frames 
  5   [internal]:0
      Vyuldashev\LaravelOpenApi\Builders\PathsBuilder::Vyuldashev\LaravelOpenApi\Builders\{closure}()

      +18 vendor frames 
  24  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

My current project is on PHP 8.0, Laravel 8, laravel-openapi 1.0.2. I haven't tested this issue on a fresh laravel installation yet.

@vyuldashev
Copy link
Owner

Fixed in v1.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants