benjamincrozat / lumen-swagger
Generate API documentation with swag.
Installs: 2 535
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 3
Type:project
Requires
- php: >=7.1
- illuminate/console: ^5.5
- zircote/swagger-php: ^2.0
Requires (Dev)
- orchestra/testbench: ^3.5
- phpunit/phpunit: ^6.0
README
Lumen Swagger
Generate API documentation with swag.
Installation
Lumen
composer require benjamincrozat/lumen-swagger
Add the following line in your bootstrap/app.php
:
$app->register(BC\LumenSwagger\ServiceProvider::class);
Laravel
If you wish to run this package on Laravel, you can easily do it. Just install it via Composer and you're done, thanks to its automatic package discovery.
composer require benjamincrozat/lumen-swagger
Usage
Once you annotated your models and controllers (see documentation here), using the command is pretty straightforward:
php artisan swagger
Generated at "/path/to/project/swagger.json"
You can also specify a custom path:
php artisan swagger --path whatever/documentation.json
Generated at "/path/to/project/whatever/documentation.json"
And even change the scanned location:
php artisan swagger --scan whatever
Generated at "/path/to/project/swagger.json"
Tip
In my own opinion, I think annotations are great for this use case, but messy. Writing API specs in your code isn't the cleanest thing to do. Your files quickly get unecessarly bloated. In Lumen Boilerplate, I opted for a single file config/swagger.php
. Just run the following command to scan the config
directory:
php artisan swagger --scan config