Generated OpenAPI Specs
b10cks generates OpenAPI 3.0 specifications for its APIs from the code — routes, form requests, API resources, and filter classes are analyzed so the reference never drifts from the implementation.
Generating
php artisan docs:generate # all configured prefixes
php artisan docs:generate --prefix=api/v1 # one prefix
php artisan docs:generate --format=yaml # YAML instead of JSON
php artisan docs:generate --output=/some/dir # custom output directoryBy default one spec file per API prefix is written to docs/public/specs/, from where the documentation build serves them at /docs/specs/:
| File | API | Browsable reference |
|---|---|---|
api_v1.json | Data API | Data API Reference |
mgmt_v1.json | Management API | Management API Reference |
auth_v1.json | Auth API | Auth API Reference |
The reference pages are rendered from the specs by the documentation site itself, so a running instance serves its own interactive reference at https://your-instance/docs/api/reference/data-api. The raw specs are available at https://your-instance/docs/specs/api_v1.json (etc.) for tooling and code generation.
What the generator derives
- Operations — every route under the configured prefixes (
config/docs.php→routes.prefixes), with per-prefix security schemes (query token for the Data API, Bearer for management). - Summaries & descriptions — from the controller method's doc block (falling back to the class doc block for single-action controllers, then to a verb+resource summary). Write normal PHPDoc text on a controller method and it appears in the spec.
- Tags — from the route's resource segment (tenancy scopes like
spaces/{space}are skipped), so operations group by resource in spec browsers. - Query parameters — from
Filterclasses (one parameter per filter method, honoring@filterDescription,@filterType,@filterFormat,@filterExampleannotations, plus asortenum from$sortableColumns) and from validation rules inFormRequestclasses on GET routes. - Request bodies — from
FormRequestvalidation rules on write routes. - Response schemas — from API
Resource/ResourceCollectionclasses, discovered via return types and@responseannotations (e.g.@response ContentResourceCollection<LengthAwarePaginator<ContentResource>>). Shared schemas are emitted once undercomponents/schemasand referenced. - Operation IDs — stable, collision-free IDs derived from the method and full path (
get_contents,delete_spaces_tokens_by_token).
Annotating code for better docs
When adding an endpoint:
- Write a doc block on the controller method — the first sentence becomes the summary, the whole text the description.
- Type your responses — return a dedicated Resource, or add
@responsewhen the return type alone is ambiguous. - Document filters — on filter methods, add
@filterDescription/@filterType/@filterFormat/@filterExample; class-level@filterDescriptionand@sortDescriptioncover the general case. - Regenerate with
php artisan docs:generateand check the output indocs/public/specs/.
Configuration
config/docs.php controls the output directory, per-prefix titles/descriptions/security, security scheme definitions, resource discovery directories, default response descriptions, and pagination defaults.