2017 © Pedro Peláez
 

extension auto-swagger-ui

Want the swagger ui without having to set it up. Just install this package.

image

kevupton/auto-swagger-ui

Want the swagger ui without having to set it up. Just install this package.

  • Thursday, November 30, 2017
  • by kevupton
  • Repository
  • 1 Watchers
  • 4 Stars
  • 956 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 7 Versions
  • 45 % Grown

The README.md

auto-swagger-ui

Give your project some swagger docs in a matter of seconds. Simply just install the package and service providers, optionally adding the configuration file, then BAM you now have a swagger ui endpoint., (*1)

Also integrates with swagger php annotations, allowing you scan your annotations and generate a json object at a specified endpoint. 1, 2, 3, too much swag. ;), (*2)

Install

composer require kevupton/auto-swagger-ui

Setup

Add to the Service Providers:

Laravel:

In config/app.php , providers add, (*3)

\Kevupton\AutoSwaggerUI\Providers\AutoSwaggerUIServiceProvider::class,

Lumen:

In bootstrap/app.php add, (*4)

$app->register(\Kevupton\AutoSwaggerUI\Providers\AutoSwaggerUIServiceProvider::class);

Run

Once you have registered the service provider, you will be able to access the swagger page at:, (*5)

http://{my-host}/api/swagger

Or the json at, (*6)

http://{my-host}/api/swagger.json

Config

The package can be configured by publishing the config or copying the config from the vendor files. To publish:, (*7)

php artisan vendor:publish

The config:, (*8)

<?php

return array(
    // whether or not the swagger ui is enabled
    'ui_enabled' => env('SWAGGER_UI_ENABLED', true),

    // the path to the swagger ui implementation. By default will use its own swagger ui
    'path' => env('SWAGGER_UI_PATH'),

    'urls' => [
        // where the swagger ui will be located
        'ui' => env('SWAGGER_UI_URL', '/api/swagger'),

        // where the json will be located
        'json' => env('SWAGGER_JSON_URL', '/api/swagger.json')
    ],

    // whether or not to enable the swagger scanner
    'scanner_enabled' => env('SWAGGER_SCAN_ENABLED', true),

    'scanner' => [
        // if you want to enable swagger scan then specify an endpoint
        'output_url' => env('SWAGGER_SCANNER_OUTPUT_URL', '/api/swagger.json'),

        // the directory to scan
        'paths' => env('SWAGGER_SCANNER_PATH', '/app/Http/Controllers'),

        // the default scanner which passes the json
        'handler' => env('SWAGGER_SCANNER_HANDLER', '\Kevupton\LaravelSwagger\scan'),

        // the options that is passed into the scanner
        'options' => [

            // the models to include in the scan
            'models' => []
        ],

        // how long to save the scanned json for
        'cache_duration' => env('SWAGGER_SCANNER_CACHE_DURATION', null),

        // headers in the JSON response (for CORS)
        'headers' => [
            'Access-Control-Allow-Origin: *',
            'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE',
            'Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization'
        ]
    ]

);

Note: Lumen will probably need to copy the config from the config file in this package, to swagger.php and register the configuration $app->configure('swagger'); in the bootstrap/app.js., (*9)

NGINX You may need to adjust your config file so that redirects for files not found using this line:, (*10)

try_files $uri /index.php;, (*11)

Example:, (*12)

    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)$ {
      try_files $uri /index.php;
      expires 1M;
      access_log off;
      add_header Cache-Control "public";
    }

    location ~* \.(?:css|js)$ {
      try_files $uri /index.php;
      expires 7d;
      access_log off;
      add_header Cache-Control "public";
    }

The Versions

30/11 2017

dev-master

9999999-dev

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui

11/10 2017

v0.1.3

0.1.3.0

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui

11/10 2017

v0.1.2

0.1.2.0

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui

11/10 2017

v0.1.1

0.1.1.0

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui

11/10 2017

v0.1.0

0.1.0.0

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui

29/11 2016

v0.0.2

0.0.2.0

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui

29/11 2016

v0.0.1

0.0.1.0

Want the swagger ui without having to set it up. Just install this package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kevin Upton

php swagger-ui