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

1.2.0 2017-11-08 13:02 UTC

This package is not auto-updated.

Last update: 2024-11-12 03:38:26 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)