lichunqiang / Yii2 Swagger
Licence: mit
yii2 with swagger-php
Stars: ✭ 138
Projects that are alternatives of or similar to Yii2 Swagger
Ar Position
ActiveRecord behavior, which provides ability for custom records order setup
Stars: ✭ 107 (-22.46%)
Mutual labels: yii2, yii
Yii2 Schemadump
Generate the schema from an existing database.
Stars: ✭ 78 (-43.48%)
Mutual labels: yii2, yii
Ar Linkmany
ActiveRecord behavior for saving many-to-many relations
Stars: ✭ 83 (-39.86%)
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
Yii2 App Advanced
Yii 2.0 Advanced Application Template
Stars: ✭ 1,569 (+1036.96%)
Mutual labels: yii2, yii
Yii2 Swagger Extension
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
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].