From 46d48946b0482fcaf8e7e7f84bbe7ce9d1ddbcdc Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Thu, 14 May 2015 01:01:41 +0200 Subject: [PATCH] update examples for servant-docs. fixes #76 --- servant-docs/README.md | 4 ++-- servant-docs/src/Servant/Docs.hs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/servant-docs/README.md b/servant-docs/README.md index ed088802..2c81b2a5 100644 --- a/servant-docs/README.md +++ b/servant-docs/README.md @@ -32,7 +32,7 @@ instance ToJSON Greet -- We can also implement 'MimeRender' explicitly for additional formats. instance MimeRender PlainText Greet where - toByteString Proxy (Greet s) = "

" <> cs s <> "

" + mimeRender Proxy (Greet s) = "

" <> cs s <> "

" -- we provide a sample value for the 'Greet' type instance ToSample Greet where @@ -56,7 +56,7 @@ instance ToCapture (Capture "greetid" Text) where type TestApi = "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON,PlainText] Greet :<|> "greet" :> RQBody '[JSON] Greet :> Post '[JSON] Greet - :<|> "delete" :> Capture "greetid" Text :> Delete + :<|> "delete" :> Capture "greetid" Text :> Delete '[] () testApi :: Proxy TestApi testApi = Proxy diff --git a/servant-docs/src/Servant/Docs.hs b/servant-docs/src/Servant/Docs.hs index 627f9593..14f116d1 100644 --- a/servant-docs/src/Servant/Docs.hs +++ b/servant-docs/src/Servant/Docs.hs @@ -30,6 +30,7 @@ -- > {-# LANGUAGE OverloadedStrings #-} -- > {-# LANGUAGE TypeOperators #-} -- > {-# OPTIONS_GHC -fno-warn-orphans #-} +-- > import Control.Lens -- > import Data.Aeson -- > import Data.Proxy -- > import Data.String.Conversions @@ -51,7 +52,7 @@ -- > -- > -- | We can also implement 'MimeRender' for additional formats like 'PlainText'. -- > instance MimeRender PlainText Greet where --- > toByteString Proxy (Greet s) = "\"" <> cs s <> "\"" +-- > mimeRender Proxy (Greet s) = "\"" <> cs s <> "\"" -- > -- > -- We add some useful annotations to our captures, -- > -- query parameters and request body to make the docs @@ -111,7 +112,7 @@ -- > :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet -- > -- > -- DELETE /greet/:greetid --- > :<|> "greet" :> Capture "greetid" Text :> Delete +-- > :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] () -- > -- > testApi :: Proxy TestApi -- > testApi = Proxy @@ -121,7 +122,7 @@ -- > -- notes. -- > extra :: ExtraInfo TestApi -- > extra = --- > extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete)) $ +-- > extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete '[JSON] ())) $ -- > defAction & headers <>~ ["unicorns"] -- > & notes <>~ [ DocNote "Title" ["This is some text"] -- > , DocNote "Second secton" ["And some more"]