ak279642 / openapi-generator-laravel
Laravel package for automatic OpenAPI documentation generation from routes, controllers, Form Requests, and API resources, with Swagger UI and Scalar support.
Package info
github.com/Ak279642/openapi-generator-laravel
pkg:composer/ak279642/openapi-generator-laravel
Requires
- php: ^8.2
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/routing: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- laravel/framework: ^10.0|^11.0|^12.0|^13.0
- nikic/php-parser: ^5.0
- symfony/yaml: ^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.0|^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel package for automatic OpenAPI 3.1 documentation generation from application routes, controllers, Form Requests, and JSON Resources.
Requirements
- PHP 8.2+
- Laravel 10, 11, or 12
Installation
composer require ak279642/openapi-generator-laravel php artisan vendor:publish --tag=openapi-generator-config php artisan openapi:generate
Documentation UIs
- Swagger UI:
/docs/swagger - Scalar:
/docs/scalar - JSON specification:
/docs/openapi.json - YAML specification:
/docs/openapi.yaml
The route prefix and middleware are configurable.
Generation
php artisan openapi:generate php artisan openapi:generate --format=json php artisan openapi:generate --format=yaml php artisan openapi:generate --format=both php artisan openapi:generate --check php artisan openapi:generate --no-cache
--output may point to a file for a single format or to a directory for both.
Configuration
Publish config/openapi-generator.php and configure:
- OpenAPI metadata and servers
- API route prefixes and exclusions
- security detection and bearer scheme
- generated file locations
- schema depth
- Swagger/Scalar branding
- documentation middleware
Application conventions
The generator is intentionally convention-light. It reads the Laravel route collection and uses reflection/AST inspection where possible. Form Requests can expose conditional or documentation-specific metadata through an openApiDocs() method when your application uses that convention.
JSON Resources are inspected to build reusable component schemas and nested resource references are protected against recursion.
Publishing views
php artisan vendor:publish --tag=openapi-generator-views
Published views live under resources/views/vendor/openapi-generator.
License
MIT