on master help sign in
update examples for servant-docs. fixes #76
46d4894Alp Mestanogullari
servant-docs/README.md+2−2
@@ -32,7 +32,7 @@ instance ToJSON Greet
32
32
33-- We can also implement 'MimeRender' explicitly for additional formats.
33-- We can also implement 'MimeRender' explicitly for additional formats.
34instance MimeRender PlainText Greet where
34instance MimeRender PlainText Greet where
35− toByteString Proxy (Greet s) = "<h1>" <> cs s <> "</h1>"
35+ mimeRender Proxy (Greet s) = "<h1>" <> cs s <> "</h1>"
36
36
37-- we provide a sample value for the 'Greet' type
37-- we provide a sample value for the 'Greet' type
38instance ToSample Greet where
38instance ToSample Greet where
@@ -56,7 +56,7 @@ instance ToCapture (Capture "greetid" Text) where
56type TestApi =
56type TestApi =
57 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON,PlainText] Greet
57 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON,PlainText] Greet
58 :<|> "greet" :> RQBody '[JSON] Greet :> Post '[JSON] Greet
58 :<|> "greet" :> RQBody '[JSON] Greet :> Post '[JSON] Greet
59− :<|> "delete" :> Capture "greetid" Text :> Delete
59+ :<|> "delete" :> Capture "greetid" Text :> Delete '[] ()
60
60
61testApi :: Proxy TestApi
61testApi :: Proxy TestApi
62testApi = Proxy
62testApi = Proxy
servant-docs/src/Servant/Docs.hs+4−3
@@ -30,6 +30,7 @@
30-- > {-# LANGUAGE OverloadedStrings #-}
30-- > {-# LANGUAGE OverloadedStrings #-}
31-- > {-# LANGUAGE TypeOperators #-}
31-- > {-# LANGUAGE TypeOperators #-}
32-- > {-# OPTIONS_GHC -fno-warn-orphans #-}
32-- > {-# OPTIONS_GHC -fno-warn-orphans #-}
33+-- > import Control.Lens
33-- > import Data.Aeson
34-- > import Data.Aeson
34-- > import Data.Proxy
35-- > import Data.Proxy
35-- > import Data.String.Conversions
36-- > import Data.String.Conversions
@@ -51,7 +52,7 @@
51-- >
52-- >
52-- > -- | We can also implement 'MimeRender' for additional formats like 'PlainText'.
53-- > -- | We can also implement 'MimeRender' for additional formats like 'PlainText'.
53-- > instance MimeRender PlainText Greet where
54-- > instance MimeRender PlainText Greet where
54−-- > toByteString Proxy (Greet s) = "\"" <> cs s <> "\""
55+-- > mimeRender Proxy (Greet s) = "\"" <> cs s <> "\""
55-- >
56-- >
56-- > -- We add some useful annotations to our captures,
57-- > -- We add some useful annotations to our captures,
57-- > -- query parameters and request body to make the docs
58-- > -- query parameters and request body to make the docs
@@ -111,7 +112,7 @@
111-- > :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
112-- > :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
112-- >
113-- >
113-- > -- DELETE /greet/:greetid
114-- > -- DELETE /greet/:greetid
114−-- > :<|> "greet" :> Capture "greetid" Text :> Delete
115+-- > :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] ()
115-- >
116-- >
116-- > testApi :: Proxy TestApi
117-- > testApi :: Proxy TestApi
117-- > testApi = Proxy
118-- > testApi = Proxy
@@ -121,7 +122,7 @@
121-- > -- notes.
122-- > -- notes.
122-- > extra :: ExtraInfo TestApi
123-- > extra :: ExtraInfo TestApi
123-- > extra =
124-- > extra =
124−-- > extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete)) $
125+-- > extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete '[JSON] ())) $
125-- > defAction & headers <>~ ["unicorns"]
126-- > defAction & headers <>~ ["unicorns"]
126-- > & notes <>~ [ DocNote "Title" ["This is some text"]
127-- > & notes <>~ [ DocNote "Title" ["This is some text"]
127-- > , DocNote "Second secton" ["And some more"]
128-- > , DocNote "Second secton" ["And some more"]