承接 light/yii2-swagger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

light/yii2-swagger

最新稳定版本:3.0.6

Composer 安装命令:

composer require light/yii2-swagger

包简介

swagger intergation with yii2

README 文档

README

Yii2 Swagger Extension


version Download Issues

swagger-php integration with yii2.

Integration swagger-ui with swagger-php.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist light/yii2-swagger "~3.0" --dev

or add

"light/yii2-swagger": "~3.0"

to the require section of your composer.json file.

Usage

Configure two action as below:

public function actions()
{
    return [
        //The document preview addesss:http://api.yourhost.com/site/doc
        'doc' => [
            'class' => 'light\swagger\SwaggerAction',
            'restUrl' => \yii\helpers\Url::to(['/site/api'], true),
        ],
        //The resultUrl action.
        'api' => [
            'class' => 'light\swagger\SwaggerApiAction',
            //The scan directories, you should use real path there.
            'scanDir' => [
                Yii::getAlias('@api/modules/v1/swagger'),
                Yii::getAlias('@api/modules/v1/controllers'),
                Yii::getAlias('@api/modules/v1/models'),
                Yii::getAlias('@api/models'),
            ],
            //The security key
            'api_key' => 'balbalbal',
        ],
    ];
}

For security, you can config api key for protection.

Caching

public function actions()
{
    return [
        // ...
        'api' => [
            // ...
            'cache' => 'cache',
            'cacheKey' => 'api-swagger-cache', // default is 'api-swagger-cache'
        ],
    ];
}

Clear cache

Access clear cache url YOUR_API_URL?clear-cache or YOUR_API_URL?api_key=YOUR_API_KEY&clear-cache

Example: curl 'http://localhost/v1/swagger/api?clear-cache'

you will see: Succeed clear swagger api cache.

Finally

If there also some confused, you can refer the Demo.

License

MIT

统计信息

  • 总下载量: 760.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 155
  • 点击次数: 1
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 154
  • Watchers: 10
  • Forks: 48
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-07