huijiewei/yii2-swagger Swagger 扩展

yii2-swagger

Yii2 Swagger 扩展

安装

composer require huijiewei/yii2-swagger

用法

Controller 里面集成 Action:
public function actions()
{
    return [
        'ui' => [
            'class' => 'huijiewei\swagger\actions\SwaggerUiAction',
            'apiUrl' => \yii\helpers\Url::to(['/site/api'], true),
        ],
        'api' => [
            'class' => 'huijiewei\swagger\actions\SwaggerApiAction',
            'scanDir' => '扫描的目录,可以是数组,支持 yii 的 alias',
        ],
    ];
}
Module 里面集成 Controller:
public function init()
{
    parent::init();

    $this->controllerMap = [
        'swagger' => [
            'class' => 'huijiewei\swagger\SwaggerController',
            'apiOptions' => [
                'scanDir' => '扫描的目录,可以是数组,支持 yii 的 alias',
                'defines' => [ // 可以定义一些常量,具体查阅 swagger-php 文档
                    'API_HOST' => 'API_HOST',
                    'API_BASE_PATH' => 'BASE_PATH'
                ]
            ],
            'uiOptions' => [
                'apiUrlRoute' => 'swagger/api'
            ]
        ],
    ];
}

更多文档

查阅 Swagger PHP 文档.

查阅 Swagger UI 文档.

感谢 swagger-php swagger-ui

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



3.0.2 is the latest of 5 releases



MIT license
Stats
2 github stars & 0 github forks
0 downloads in the last day
0 downloads in the last 30 days
103 total downloads