Skip to content

Example use of SwaggerUiEngine gem inside a Rails API-only project.

Notifications You must be signed in to change notification settings

zuzannast/swagger_ui_engine_api_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This is an example use of SwaggerUiEngine gem inside a Rails API only project.

Versions

SwaggerUIEngine Ruby Rails versions
1.1.1 2.4.0 5.1.5

Config

Gemfile

gem 'swagger_ui_engine'

Initializer

# config/initializers/swagger_ui_engine.rb

SwaggerUiEngine.configure do |config|
  config.swagger_url = {
    v1: '/doc/v1/swagger.yaml',
    v2: '/doc/v2/swagger.yaml'
  }

  config.doc_expansion = 'full'
  config.model_rendering = 'model'
  config.validator_enabled = true
  config.admin_username = 'admin'
  config.admin_password = 'password'
end

Routes

# config/routes.rb

Rails.application.routes.draw do
  mount SwaggerUiEngine::Engine, at: '/'
end

Swagger Petstore minimal YAML documentation

# public/doc/v1/swagger.yaml

---
  swagger: "2.0"
  info:
    version: "1.0.0"
    title: "Swagger Petstore"
  ...

Result

Heroku app

swagger-ui-engine-example

HTTP Basic Auth

SwaggerUiEngine Basic Auth

The username and password for basic auth are: admin and password - as defined in the example configuration.

Index page

SwaggerUiEngine Index Page

Single version page

Swagger Web UI Single version

About

Example use of SwaggerUiEngine gem inside a Rails API-only project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages