Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elixir-maru/maru_swagger
Add swagger compliant documentation to your maru API
https://github.com/elixir-maru/maru_swagger
Last synced: 8 days ago
JSON representation
Add swagger compliant documentation to your maru API
- Host: GitHub
- URL: https://github.com/elixir-maru/maru_swagger
- Owner: elixir-maru
- License: bsd-3-clause
- Created: 2015-06-01T10:12:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-17T08:09:30.000Z (over 4 years ago)
- Last Synced: 2024-10-02T13:08:26.295Z (about 1 month ago)
- Language: Elixir
- Size: 91.8 KB
- Stars: 57
- Watchers: 4
- Forks: 17
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Add swagger compliant documentation to your maru API. (Documentation)
README
MaruSwagger
===========[![Build status](https://img.shields.io/travis/elixir-maru/maru_swagger.svg?style=flat-square)](https://travis-ci.org/elixir-maru/maru_swagger)
[![hex.pm Version](https://img.shields.io/hexpm/v/maru_swagger.svg?style=flat-square)](https://hex.pm/packages/maru_swagger)
[![Hex downloads](https://img.shields.io/hexpm/dt/maru_swagger.svg?style=flat-square)](https://hex.pm/packages/maru_swagger)## Usage
GOTCHA: Please keep `swagger` DSL out of `version`!
```elixir
def deps do
[ {:maru_swagger, github: "elixir-maru/maru_swagger"} ]
enddefmodule Router do
version "v1"
...
enddefmodule API do
use Maru.Router
use MaruSwaggerplug 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
force_json: true, # (optional) force JSON for all params instead of formDataswagger_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](http://petstore.swagger.io) in your borwser and fill in `http://127.0.0.1:4000/swagger` and enjoy maru_swagger.
## Thanks
* [Cifer](https://github.com/Cifer-Y)
* [Roman Heinrich](https://github.com/mindreframer)