yii-gii-swagger [ 2.0 版本 ]
Yii2 generate swagger annotation
This extension provides a Web-based code generator, called Gii, for Yii framework 2.0 applications.
You can use Gii to quickly generate swagger 2.0(openapi 2.0)
annotation.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
composer require lengbin/yii-gii-swagger
or add
"lengbin/yii-gii-swagger": *
to the require-dev section of your composer.json
file.
Usage
Once the extension is installed, simply modify your application configuration at your application\config\main_local.php
as follows:
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'generators' => [
'swagger' => [
'class' => 'lengbin\gii\swagger\Generator', //class
'parameters' => [ //set default request parameters
'parameterName' => ['X-Api-Token'],
'parameterDescription' => ['token'],
'parameterIn' => ['header'],
'parameterType' => ['string'],
'parameterRequired' => ['true'],
],
'responses' => [ //set default respons parameters
'responseStatus' => [200, 'default'],
'responseDescription' => ['success', '请求失败, http status 强行转为200, 通过code判断'],
'ref' => ['SuccessDefault', 'ErrorDefault'],
],
],
//...
],
];
//...
You can then access Gii through the following URL:
http://localhost/path/to/index.php?r=gii
or if you have enabled pretty URLs, you may use the following URL:
http://localhost/path/to/index.php/gii
extension
You can use swagger doc extension yii-swagger.
ice
注册时间:2016-05-30
最后登录:2019-09-18
在线时长:2小时52分
最后登录:2019-09-18
在线时长:2小时52分
- 粉丝0
- 金钱115
- 威望10
- 积分235
共 0 条评论