All Projects → lichunqiang → Yii2 Swagger

lichunqiang / Yii2 Swagger

Licence: mit
yii2 with swagger-php

Projects that are alternatives of or similar to Yii2 Swagger

Yii2 Twig
Yii 2 Twig extension.
Stars: ✭ 130 (-5.8%)
Mutual labels:  yii2, yii
Ar Position
ActiveRecord behavior, which provides ability for custom records order setup
Stars: ✭ 107 (-22.46%)
Mutual labels:  yii2, yii
Yii2 Aws S3
An Amazon S3 component for Yii2
Stars: ✭ 86 (-37.68%)
Mutual labels:  yii2, yii
Yii2 Schemadump
Generate the schema from an existing database.
Stars: ✭ 78 (-43.48%)
Mutual labels:  yii2, yii
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (-15.94%)
Mutual labels:  yii2, yii
Csv Grid
Yii2 extension for CSV export
Stars: ✭ 83 (-39.86%)
Mutual labels:  yii2, yii
Admin
Admin pack (actions, widgets, etc) for Yii2
Stars: ✭ 100 (-27.54%)
Mutual labels:  yii2, yii
Config
Yii2 application runtime configuration support
Stars: ✭ 54 (-60.87%)
Mutual labels:  yii2, yii
Yii2 Shell
Interactive shell
Stars: ✭ 129 (-6.52%)
Mutual labels:  yii2, yii
Yii2 Swiftmailer
Yii 2 swiftmailer extension.
Stars: ✭ 109 (-21.01%)
Mutual labels:  yii2, yii
Yii2 Smarty
Yii 2 Smarty Extension.
Stars: ✭ 67 (-51.45%)
Mutual labels:  yii2, yii
Yii2 Jui
Yii 2 JQuery UI extension.
Stars: ✭ 120 (-13.04%)
Mutual labels:  yii2, yii
Sitemap
Site map creation support
Stars: ✭ 59 (-57.25%)
Mutual labels:  yii2, yii
Ar Linkmany
ActiveRecord behavior for saving many-to-many relations
Stars: ✭ 83 (-39.86%)
Mutual labels:  yii2, yii
Lang Sc
一本字典
Stars: ✭ 57 (-58.7%)
Mutual labels:  yii2, yii
Yii2 Openapi
REST API application generator for Yii2, openapi 3.0 YAML -> Yii2
Stars: ✭ 99 (-28.26%)
Mutual labels:  yii2, yii
Opensourcewebsite Org
OpenSourceWebsite (OSW) - online community managed by users using electronic voting and modifying source code
Stars: ✭ 834 (+504.35%)
Mutual labels:  yii2, yii
App Basic
Base app on SkeekS CMS (Yii2)
Stars: ✭ 10 (-92.75%)
Mutual labels:  yii2, yii
Rageframe2
一个基于Yii2高级框架的快速开发应用引擎
Stars: ✭ 1,553 (+1025.36%)
Mutual labels:  yii2, yii
Yii2 App Advanced
Yii 2.0 Advanced Application Template
Stars: ✭ 1,569 (+1036.96%)
Mutual labels:  yii2, yii

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 "~1.0.4" --dev

or add

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].