Skip to content
Add swagger compliant documentation to your maru API
Elixir
Latest commit 4cfe6fd Jun 22, 2016 @falood update travis config
Failed to load latest commit information.
config
lib
test
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
mix.exs use buildin UnitTest Jun 22, 2016

README.md

MaruSwagger

Build status hex.pm Version Hex downloads

Usage

GOTCHA: Please keep swagger DSL out of version!

def deps do
  [ {:maru_swagger, github: "falood/maru_swagger"} ]
end

defmodule Router do
  version "v1"
  ...
end

defmodule API do
  use Maru.Router
  use MaruSwagger

  plug Plug.Logger

  swagger at:      "/swagger",         # (required) the mount point for the URL
          pretty:  true,               # (optional) should JSON be pretty-printed?
          only:    [:dev],             # (optional) the environments swagger works
          except:  [:prod],            # (optional) the environments swagger NOT works

          swagger_inject: [            # (optional) this will be directly injected into the root Swagger JSON
            host: "myapi.com",
            basePath: "/api",
            schemes:  [ "http" ],
            consumes: [ "application/json" ],
            produces: [
              "application/json",
              "application/vnd.api+json"
            ]
          ]

  mount Router
end

and then you can get json response from curl http://127.0.0.1:4000/swagger.

open Swagger Petstore in your borwser and fill in http://127.0.0.1:4000/swagger and enjoy maru_swagger.

Thanks

Something went wrong with that request. Please try again.