Merge pull request #1 from haskell-servant/jkarni/encodePretty
Switch to encodePretty in sampleByteString.
This commit is contained in:
commit
87b7c8e376
4 changed files with 25 additions and 13 deletions
|
@ -3,6 +3,7 @@
|
|||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
import Data.Aeson
|
||||
import Data.Proxy
|
||||
import Data.Text
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
POST /greet
|
||||
-----------
|
||||
|
||||
**Request Body**:
|
||||
|
||||
``` javascript
|
||||
{"msg":"Hello, haskeller!"}
|
||||
{
|
||||
"msg": "Hello, haskeller!"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**:
|
||||
|
@ -13,7 +16,9 @@ POST /greet
|
|||
- Response body as below.
|
||||
|
||||
``` javascript
|
||||
{"msg":"Hello, haskeller!"}
|
||||
{
|
||||
"msg": "Hello, haskeller!"
|
||||
}
|
||||
```
|
||||
|
||||
GET /hello/:name
|
||||
|
@ -36,7 +41,9 @@ GET /hello/:name
|
|||
- Response body as below.
|
||||
|
||||
``` javascript
|
||||
{"msg":"Hello, haskeller!"}
|
||||
{
|
||||
"msg": "Hello, haskeller!"
|
||||
}
|
||||
```
|
||||
|
||||
DELETE /greet/:greetid
|
||||
|
@ -50,3 +57,5 @@ DELETE /greet/:greetid
|
|||
|
||||
- Status code 204
|
||||
- No response body
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ library
|
|||
build-depends:
|
||||
base >=4.7 && <5
|
||||
, aeson
|
||||
, aeson-pretty < 0.8
|
||||
, bytestring
|
||||
, hashable
|
||||
, lens
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue