gbksoft / yii2-swagger
Yii 2 wrapper for Swagger
Installs: 7 575
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 7
Forks: 3
Open Issues: 2
Language:JavaScript
Type:yii2-extension
Requires
- yiisoft/yii2: >=2.0.4
Requires (Dev)
- phpunit/phpunit: 4.8
This package is not auto-updated.
Last update: 2024-10-01 03:13:41 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require gbksoft/yii2-swagger
or add
"gbksoft/yii2-swagger": "~1.0.0"
to the require section of your composer.json
file.
Usage
...
'modules' => [
'swagger' => [
'class' => 'gbksoft\modules\swagger\Module',
'swaggerUrl' => '/api/web/swagger/swagger.json',
'swaggerPath' => __DIR__ . '/../../api/web/swagger/swagger.json',
'on beforeJson' => function($event) {
// Replace response content (swagger.json)
$event->responseText = mb_ereg_replace('{{http_host}}', \Yii::$app->request->hostInfo, $event->responseText);
$event->responseText = mb_ereg_replace('{{apiversion}}', \Yii::$app->params['apiversion'], $event->responseText);
},
],
],
...
Module url rules
swagger/ <== Main swagger page
swagger/default/json <== Get swagger.json file with replacements
swagger/default/history <== Get git logs history (included in bottom on main swagger page)