3[](http://travis-ci.org/haskell-servant/servant-docs)
5
7Generate API docs for your *servant* webservice. Feel free to also take a look at [servant-pandoc](https://github.com/mpickering/servant-pandoc) which uses this package to target a broad range of output formats using the excellent **pandoc**.
11See [here](https://github.com/haskell-servant/servant-docs/blob/master/example/greet.md) for the output of the following program.
14{-# LANGUAGE DataKinds #-}
15{-# LANGUAGE PolyKinds #-}
16{-# LANGUAGE TypeFamilies #-}
17{-# LANGUAGE DeriveGeneric #-}
18{-# LANGUAGE TypeOperators #-}
19{-# LANGUAGE FlexibleInstances #-}
20{-# LANGUAGE OverloadedStrings #-}
26-- our type for a Greeting message
27data Greet = Greet { _msg :: Text }
28 deriving (Generic, Show)
30-- we get our JSON serialization for free
31instance FromJSON Greet
34-- we provide a sample value for the 'Greet' type
35instance ToSample Greet where
38 where g = Greet "Hello, haskeller!"
40instance ToParam (QueryParam "capital" Bool) where
42 DocQueryParam "capital"
44 "Get the greeting message in uppercase (true) or not (false). Default is false."
46instance ToCapture (Capture "name" Text) where
47 toCapture _ = DocCapture "name" "name of the person to greet"
49instance ToCapture (Capture "greetid" Text) where
50 toCapture _ = DocCapture "greetid" "identifier of the greet msg to remove"
54 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
55 :<|> "greet" :> RQBody Greet :> Post Greet
56 :<|> "delete" :> Capture "greetid" Text :> Delete
58testApi :: Proxy TestApi
61-- Generate the Documentation's ADT
63greetDocs = docs testApi
66main = putStrLn $ markdown greetDocs
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list