Sha256: 0131a98b956c4d117b90cccf0c99e4222a3a4ae746766c2240c15d7669ee6bf9

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# InstaSwag


InstaSwag provides lighting-fast, dynamically generated [swagger-documentation](https://github.com/wordnik/swagger-core) for [grape APIs](https://github.com/intridea/grape)

## Mounting

Mounting swagger had never been easier. The ``::for`` takes in 2 arguments. The first
is your API class that inherits from ``Grape::API`` and a hash of settings to [customise the swagger documentation](https://github.com/tim-vandecasteele/grape-swagger#configure). Which returns
an instance of ``Rack::Builder``

### Sample usage

Given the settings:

```ruby
# config.ru

settings = { :prefix => "/reports-api" }

run InstaSwag.for(Api, settings)
```

Will make your documentation available at ```http://hostname:3000/reports/documentation/index.html```

![](mounted-swagger.png)

## Default values

All the settings passed will be merged with the default values to populate the mounting of the swagger documentation:

```ruby
# ./lib/insta_swag.rb

def self.for(klass, settings = {})
  settings   = Settings.new klass, settings

  Rack::Builder.new do
    map settings.assets_path, &InstaSwag::AssetsApp
    map settings.prefix_path, &DocumentationApp.create(klass, settings)
    map settings.index_path,  &StaticFiles.create(settings)
  end
end

```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
insta_swag-0.1.1 README.md