HCESrl / laravel-swagger-api

A Laravel integration with Swagger UI.
MIT License
68 stars 9 forks source link

Breaks tests #18

Open stebogit opened 1 year ago

stebogit commented 1 year ago

Hey, I'm using the Api class in my routes/api.php file, but that broke my tests as if no routes were defined, e.g.

Symfony\Component\Routing\Exception\RouteNotFoundException : Route [api.weather.daily] not defined.

I tried building the Api resources before or after the Route:: definitions, but the result is the same; I have to skip the swagger stuff if the tests are running

if (!app()->environment('testing')) {
    Api::get('/some', [ApiController::class, 'some']);
    ...
}

Any clue?

Using version 1.4.0 on Laravel 9.x.

stebogit commented 1 year ago

Actually, after further playing around with it it seems the Api definitions actually break the Auth pattern, that is the Sanctum guard is skipped entirely.