bchalier / laravel-openapi-autodoc
Automatic documentation of laravel in OpenApi format.
Installs: 14 249
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/bchalier/laravel-openapi-autodoc
Requires
- php: ^8.1|^8.2|^8.3|^8.4
- doctrine/annotations: ^2.0.1
- goldspecdigital/oooas: ^2.4
- laravel/framework: ^10.0|^11.0|^12.0
- phpdocumentor/reflection-docblock: ^5.1
README
Generates OpenAPI v3 documentation from your Laravel routes, FormRequests and API Resources.
Compatible with Laravel 10–12 and PHP 8.1–8.4.
Install
-
Require the package in your app (Composer path repo supported):
-
Publish the config if you need to customize:
php artisan vendor:publish --tag=config --provider="Bchalier\LaravelOpenapiDoc\App\Providers\LoadingServiceProvider"
Usage
- Generate the JSON file:
php artisan documentation:generate
- Output file:
- Stored on the
public
disk atstorage/app/public/documentation/openapi.json
. - If you’ve run
php artisan storage:link
, it’s available at/storage/documentation/openapi.json
.
- Stored on the
How it works
- Parses route list and filters via
config/documentation.php
. - Infers request schemas from FormRequest validation rules.
- Infers response schemas from return types:
JsonResource
,ResourceCollection
,JsonResponse
. - Uses docblocks for operation summary/description and
@throws
to add error responses.
Notes
- Models instantiated for resources must use
Illuminate\Database\Eloquent\Factories\HasFactory
. - When route names are missing, operationId falls back to
<method>_<uri>
.