Giter Site home page Giter Site logo

yii2-swagger's Introduction

Swagger Module for Yii 2

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)

yii2-swagger's People

Contributors

dell- avatar golcinho avatar littlefuntik avatar tahiaji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-swagger's Issues

Can't read swagger JSON from http://localhost/connect/swagger/default/json

exception 'yii\web\NotFoundHttpException' in D:\xampp\htdocs\connect\vendor\gbksoft\yii2-swagger\controllers\DefaultController.php:154 Stack trace: #0 [internal function]: gbksoft\modules\swagger\controllers\DefaultController->actionJson() #1 D:\xampp\htdocs\connect\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array) #2 D:\xampp\htdocs\connect\vendor\yiisoft\yii2\base\Controller.php(156): yii\base\InlineAction->runWithParams(Array) #3 D:\xampp\htdocs\connect\vendor\yiisoft\yii2\base\Module.php(523): yii\base\Controller->runAction('json', Array) #4 D:\xampp\htdocs\connect\vendor\yiisoft\yii2\web\Application.php(102): yii\base\Module->runAction('swagger/default...', Array) #5 D:\xampp\htdocs\connect\vendor\yiisoft\yii2\base\Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request)) #6 D:\xampp\htdocs\connect\index.php(12): yii\base\Application->run() #7 {main}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.