freedomcore/laravel-swagger
Composer 安装命令:
composer require freedomcore/laravel-swagger
包简介
Swagger documentation generator for Laravel
README 文档
README
Simple to use OAS3 compatible documentation generator.
Also includes Swagger UI.
About
This package is heavily inspired by the mtrajano/laravel-swagger and DarkaOnLine/L5-Swagger.
Usage is pretty similar to the mtrajano/laravel-swagger with the difference being:
- OAS3 support
- "Custom decorators" inspired by Nest.JS
- Automatic generation (assuming relevant configuration option is turned on)
- Inclusion of Swagger UI
I've spent a couple of hours making this package to suit my needs, and it does so far.
All I am trying to say is - I don't think I will be actively maintaining this package unless people will have interest in it.
Requirements
This package developed on Laravel 8.11.2, but it might work on the previous releases.
All other requirements are inherited from the Laravel 8.
Installation
Install package through composer
composer require freedomcore/laravel-swagger
Publish configuration files and views
php artisan vendor:publish --provider "FreedomCore\Swagger\SwaggerServiceProvider"
Edit the swagger.php configuration file for your liking
Usage
@Request() decorator
You can have only one @Request() decorator.
/** * You can also do this, first line will be "summary" * * And anything 1 * apart from the "summary" will count as "description" * * @Request({ * summary: Title of the route, * description: This is a longer description for the route which will be visible once the panel is expanded, * tags: Authentication,Users * }) */ public function someMethod(Request $request) {}
@Response() decorator
You can have multiple @Response decorators
/** * @Response({ * code: 302 * description: Redirect * }) * @Response({ * code: 400 * description: Bad Request * }) * @Response({ * code: 500 * description: Internal Server Error * }) */ public function someMethod(Request $request) {}
Custom Validators
These validators are made purely for visual purposes, however, some of them can actually do validation
swagger_default
$rules = [ 'locale' => 'swagger_default:en_GB' ];
swagger_min
$rules = [ 'page' => 'swagger_default:1|swagger_min:1', // This will simply display the 'minimum' value in the documentation 'page' => 'swagger_default:1|swagger_min:1:fail' // This will also fail if the `page` parameter will be less than 1 ];
swagger_max
$rules = [ 'take' => 'swagger_default:1|swagger_min:1|swagger_max:50', // This will simply display the 'maximum' value in the documentation 'take' => 'swagger_default:1|swagger_min:1|swagger_max:50:fail' // This will also fail if the `take` parameter will be greater than 50 ];
freedomcore/laravel-swagger 适用场景与选型建议
freedomcore/laravel-swagger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 339 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 freedomcore/laravel-swagger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 freedomcore/laravel-swagger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 339
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-24