kr0lik / laravel-dto-to-swagger
Generate swagger from dto and return type from action.
Installs: 1 116
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- laravel/framework: ^10.0|^11.0
- phpdocumentor/reflection-docblock: ^5.3
- zircote/swagger-php: ^4.8
Requires (Dev)
- icanhazstring/composer-unused: ^0.8.11
- kr0lik/php-cs-fixer: ^2.0
- kr0lik/phpstan-rules: ^2.0
Suggests
- spatie/laravel-data: ^3.11
README
Auto generation swagger from Laravel routing and strongly typed data for routes (Use DTO for request and response data).
*You can use laravel-dto-to-swagger togather with spatie/laravel-data packege and swagger will be fully automated and very simple.
Install
$ composer require kr0lik/laravel-dto-to-swagger
Setup is extremely simple, just add the service provider to your app.php config.
Kr0lik\DtoToSwagger\DtoToSwaggerServiceProvider::class,
You also need publish the config:
$ php artisan vendor:publish --provider="Kr0lik\DtoToSwagger\DtoToSwaggerServiceProvider"
Use
- Update the config/swagger.php file according to your needs.
- Check ot fix your Controller/Action to string types and DTO
- Run the following command to automatically generate the Swagger documentation:
$ php artisan swagger:generate
This command will generate a swagger.yaml file according with the Swagger documentation.
Example
See example folder