| name | scribe-openapi |
| description | Scribe OpenAPI generation patterns for the Laravel API. Use when adding or updating API documentation annotations, regenerating openapi.json, or configuring Scribe. Triggers on tasks involving @group, @bodyParam, @response, @authenticated, openapi.json updates, or the api-client drift gate. |
| frameworks | ["laravel","scribe"] |
| languages | ["php"] |
| category | api |
| updated | "2026-04-29T00:00:00.000Z" |
Scribe OpenAPI Skill
Quick Reference
When to Use: Adding endpoint docs, regenerating openapi.json, or updating Scribe config
Output: apps/laravel/openapi.json — consumed by packages/api-client and the CI drift gate
Regenerate command: pnpm -F @repo/laravel openapi:generate
Annotation Reference
Controller-Level (@group)
class TodoController extends Controller
Endpoint Annotations
public function index(Request $request): AnonymousResourceCollection
public function store(StoreTodoRequest $request): TodoResource
URL Parameters
public function show(int $id): TodoResource
Auth Groups
Full Endpoint Example
class TicketController extends Controller
{
public function index(): AnonymousResourceCollection
{
return TicketResource::collection(Ticket::latest()->get());
}
public function store(StoreTicketRequest $request): TicketResource
{
$this->authorize('create', Ticket::class);
return new TicketResource(Ticket::create($request->validated()));
}
}
Regenerating openapi.json
pnpm -F @repo/laravel openapi:generate
After regenerating, always commit openapi.json alongside the code change. The CI drift gate (packages/e2e-web or .github/workflows/ci.yml) will fail if openapi.json is stale.
Scribe Config (config/scribe.php)
Key settings:
return [
'type' => 'laravel',
'auth' => [
'enabled' => true,
'in' => 'bearer',
'name' => 'token',
],
'routes' => [
[
'match' => [
'prefixes' => ['api/*'],
'domains' => ['*'],
],
],
],
'postman' => ['enabled' => false],
'openapi' => ['enabled' => true],
'output_path' => 'public/docs',
];
CI Drift Gate
The CI pipeline has a job that:
- Calls
pnpm -F @repo/laravel openapi:generate
- Diffs the output against the committed
openapi.json
- Fails if there are any changes (schema drift)
This ensures openapi.json is always in sync with the running API.
Adding New Endpoint Checklist
- Implement controller method with appropriate HTTP verb and route
- Add Scribe annotations:
@group, @bodyParam, @urlParam, @response (happy + error)
- Add
@authenticated if the route uses auth:sanctum
- Run
pnpm -F @repo/laravel openapi:generate
- Commit the updated
openapi.json
- Run
pnpm -F @repo/api-client generate to update TypeScript hooks