laravel-openapi
laravel-openapi copied to clipboard
Factory class must be instance of ResponseFactory when running openapi:generate
While using php artisan openapi:generate we can run into this exception:

This happens when your response class doesn't extend from Vyuldashev\LaravelOpenApi\Factories\ResponseFactory or straight up doesn't exist in the path you specified in the annotation of your controller method.
My suggestion would be to specify the Factory that generated this error in the exception message so it can help future devs debug their code.
if anyone wonders, changing from
#[OpenApi\Response(factory: AnResponse::class)]
to
#[OpenApi\Response(factory: \App\OpenApi\Responses\AnResponse::class)]
fixes this error for me