Swagger 2.0 for Lumen 5
对 SwaggerLume 进行封装。 使其支持YAML文档。
composer require --dev soliangd/lumen-yaml-swagger
- 去掉门面注释:
$app->withFacades();
- 复制配置并加载:
$app->configure('yaml-swagger');
- 注册服务:
$app->register(\Soocoo\Swagger\SwaggerLumenServiceProvider::class);
- 配置YAML目录
config/yaml-swagger.php
:[ "paths" => [ "yaml_annotations" => [base_path('docs')] // 默认目录 ] ]
- 路由重定向
注意nginx配置时将 swagger路由重定向 swagger文档支持 location ~ /(swagger-ui-assets) { index index.php; try_files $uri $uri/ /index.php?$query_string; } ````php