Troubleshooting
Start with php artisan openapi:inspect <route> and php artisan openapi:generate -v: the diagnostics usually name
the cause. See Diagnostics.
It is not matched by routes.include (api/* by default), or it is excluded: routes.exclude, #[Exclude], a
redirect or view route, the fallback route, or an internal route of Laravel or of a package (routes.internal).
php artisan openapi:inspect <route> tells whether it is in the document. See
Choose the routes.
The action has no return type, or returns an untyped JsonResponse. Type the return (@return for the details), or
declare #[Response(type: 'array{…}')]. openapi:generate -v lists these cases.
toArray() failed on the sampled model: the warning says why. Give the model a factory, @property tags or casts, or
give the resource a #[ResourceFactory]. See Sampling.
A key computed with when(), whenLoaded() or mergeWhen() is optional; a plain value is required. Change the
resource, not the document.
The rules are not in a form request ($request->validate() in the controller is not read), or the method is GET,
HEAD or DELETE, whose fields go to the query. Move the rules to a form request, or declare #[RequestBody].
The return type does not tell the paginator. Declare
#[Response(resource: BookResource::class, paginator: LengthAwarePaginator::class)].
Add the middleware to the route, or declare #[Security('scheme')]. Declare custom schemes in security_schemes. See
Security & errors.
It uses a 3.1 or 3.2 feature (webhooks, Tag.parent, $self) in a strict document. Set strict to false, set
vendor_extensions to redoc, or write another version. See
OpenAPI version.
Factories run inside a transaction rolled back at the end, opened on the default connection only, when its driver is in
sampling.connections. Models of another connection, or of a driver not listed, are only made, never saved. Set
sampling.transactions to false to never write.
No. Write the document where a viewer can read it (a public disk, a static site) and point a dedicated package or a static viewer to the file. See Output.
Every run rewrites it. Change the code, the attributes or config/openapi.php; for a change over the whole document,
write a pass.