lengbin / yii-swagger
swagger ui 3.0 intergation with yii2
1.4
2019-08-10 04:03 UTC
Requires
- php: >=5.3.0
- bower-asset/swagger-ui: 2.2.10
- swagger-api/swagger-ui: ^3.22
- yiisoft/yii2: ^2.0.0
- zircote/swagger-php: ^2.0
README
Yii2 Swagger Ui 3.0 Extension
swagger-php intergation with yii2.
Integration swagger-ui with swagger-php.
Installation
The preferred way to install this extension is through composer.
Either run
composer require lengbin/yii2-swagger "*"
or add
"lengbin/yii2-swagger": "*"
to the require section of your composer.json
file.
Usage
Configure two action as below:
//The scan directories, you should use real path there.
DocController.php
public function actions()
{
return [
'doc' => [
'class' => 'lengbin\swagger\SwaggerAction',
'url' => \yii\helpers\Url::to(['/doc/api'], true),
// support swagger ui 2 and 3
'version' => \lengbin\swagger\SwaggerAction::SWAGGER_VERSION_DEFAULT,
//if more url
'urls' => [
\yii\helpers\Url::to(['/doc/api'], true),
['name' => 'api', 'url' => '\yii\helpers\Url::to(['/doc/api2'], true)'],
],
//'httpAuth' => ['account' => 'password'], // http auth
],
'api' => [
'class' => 'light\swagger\SwaggerApiAction',
'scanDir' => [
Yii::getAlias('@api/swagger'),
Yii::getAlias('@api/modules/v1/controllers'),
],
],
];
}
extension
You can use Gii to quickly generate swaager openapi 2.0 extension yii-gii-swagger.