lengbin / yii-gii-swagger
This generator generates swagger annotation
Requires
- php: >=5.3.0
README
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 '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.
Screenshots
Entire page
Custom parameter
generate
swagger 2.0(openapi 2.0)
annotation