on master help sign in
Add content-type params to type constructors
commit3c14343b8889495eff7d0c4d7b9d1522c206b11e authorThomas Sutton <me@thomas-sutton.id.au> dateThu 19 Feb 2015, 10:59 (12 years ago) parent2ea8a48
2 files changed+9−9
example/greet.hs+2−2 src/Servant/Docs.hs+7−7
example/greet.hs+2−2
@@ -66,11 +66,11 @@ intro2 = DocIntro "This title is below the last"
6666-- API specification
6767type TestApi =
6868 -- GET /hello/:name?capital={true, false} returns a Greet as JSON
69− "hello" :> MatrixParam "lang" String :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
69+ "hello" :> MatrixParam "lang" String :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON] Greet
7070
7171 -- POST /greet with a Greet as JSON in the request body,
7272 -- returns a Greet as JSON
73− :<|> "greet" :> ReqBody Greet :> Post Greet
73+ :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
7474
7575 -- DELETE /greet/:greetid
7676 :<|> "greet" :> Capture "greetid" Text :> Delete
src/Servant/Docs.hs+7−7
@@ -102,11 +102,11 @@
102102-- > -- API specification
103103-- > type TestApi =
104104-- > -- GET /hello/:name?capital={true, false} returns a Greet as JSON
105−-- > "hello" :> MatrixParam "lang" String :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
105+-- > "hello" :> MatrixParam "lang" String :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON] Greet
106106-- >
107107-- > -- POST /greet with a Greet as JSON in the request body,
108108-- > -- returns a Greet as JSON
109−-- > :<|> "greet" :> ReqBody Greet :> Post Greet
109+-- > :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
110110-- >
111111-- > -- DELETE /greet/:greetid
112112-- > :<|> "greet" :> Capture "greetid" Text :> Delete
@@ -154,7 +154,7 @@ module Servant.Docs
154154 , module Data.Monoid
155155 ) where
156156
157−import Control.Lens hiding (Action)
157+import Control.Lens
158158import Data.Aeson
159159import Data.Aeson.Encode.Pretty (encodePretty)
160160import Data.Ord(comparing)
@@ -641,7 +641,7 @@ instance HasDocs Delete where
641641 action' = action & response.respBody .~ []
642642 & response.respStatus .~ 204
643643
644−instance ToSample a => HasDocs (Get a) where
644+instance ToSample a => HasDocs (Get cts a) where
645645 docsFor Proxy (endpoint, action) =
646646 single endpoint' action'
647647
@@ -658,7 +658,7 @@ instance (KnownSymbol sym, HasDocs sublayout)
658658 action' = over headers (|> headername) action
659659 headername = pack $ symbolVal (Proxy :: Proxy sym)
660660
661−instance ToSample a => HasDocs (Post a) where
661+instance ToSample a => HasDocs (Post cts a) where
662662 docsFor Proxy (endpoint, action) =
663663 single endpoint' action'
664664
@@ -669,7 +669,7 @@ instance ToSample a => HasDocs (Post a) where
669669
670670 p = Proxy :: Proxy a
671671
672−instance ToSample a => HasDocs (Put a) where
672+instance ToSample a => HasDocs (Put cts a) where
673673 docsFor Proxy (endpoint, action) =
674674 single endpoint' action'
675675
@@ -761,7 +761,7 @@ instance HasDocs Raw where
761761 single endpoint action
762762
763763instance (ToSample a, HasDocs sublayout)
764− => HasDocs (ReqBody a :> sublayout) where
764+ => HasDocs (ReqBody cts a :> sublayout) where
765765
766766 docsFor Proxy (endpoint, action) =
767767 docsFor sublayoutP (endpoint, action')