Merge pull request #1 from haskell-servant/jkarni/encodePretty

Switch to encodePretty in sampleByteString.
This commit is contained in:
Julian Arni 2014-12-20 22:09:28 +01:00
commit 87b7c8e376
4 changed files with 25 additions and 13 deletions

View file

@ -3,6 +3,7 @@
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
import Data.Aeson
import Data.Proxy
import Data.Text
@ -60,4 +61,4 @@ docsGreet :: API
docsGreet = docs testApi
main :: IO ()
main = putStrLn $ markdown docsGreet
main = putStrLn $ markdown docsGreet

View file

@ -1,52 +1,61 @@
POST /greet
-----------
**Request Body**:
**Request Body**:
``` javascript
{"msg":"Hello, haskeller!"}
{
"msg": "Hello, haskeller!"
}
```
**Response**:
**Response**:
- Status code 201
- Response body as below.
``` javascript
{"msg":"Hello, haskeller!"}
{
"msg": "Hello, haskeller!"
}
```
GET /hello/:name
----------------
**Captures**:
**Captures**:
- *name*: name of the person to greet
**GET Parameters**:
**GET Parameters**:
- capital
- **Values**: *true, false*
- **Description**: Get the greeting message in uppercase (true) or not (false). Default is false.
**Response**:
**Response**:
- Status code 200
- Response body as below.
``` javascript
{"msg":"Hello, haskeller!"}
{
"msg": "Hello, haskeller!"
}
```
DELETE /greet/:greetid
----------------------
**Captures**:
**Captures**:
- *greetid*: identifier of the greet msg to remove
**Response**:
**Response**:
- Status code 204
- No response body

View file

@ -26,6 +26,7 @@ library
build-depends:
base >=4.7 && <5
, aeson
, aeson-pretty < 0.8
, bytestring
, hashable
, lens

View file

@ -109,6 +109,7 @@ module Servant.Docs
import Control.Lens hiding (Action)
import Data.Aeson
import Data.Aeson.Encode.Pretty (encodePretty)
import Data.ByteString.Lazy.Char8 (ByteString)
import Data.Hashable
import Data.HashMap.Strict (HashMap)
@ -333,7 +334,7 @@ instance ToSample () where
toSample = Just ()
sampleByteString :: forall a . ToSample a => Proxy a -> Maybe ByteString
sampleByteString Proxy = fmap encode (toSample :: Maybe a)
sampleByteString Proxy = fmap encodePretty (toSample :: Maybe a)
-- | The class that helps us automatically get documentation
-- for GET parameters.
@ -605,4 +606,4 @@ toHtml md =
"</pre>" ++
"</body>" ++
"</html>"
-}
-}