on master help sign in
Add instances for new combinators
ec0431dCatherine Galkina
servant-client/src/Servant/Client.hs+12
@@ -263,6 +263,18 @@ instance HasClient api
263 clientWithRoute Proxy =
263 clientWithRoute Proxy =
264 clientWithRoute (Proxy :: Proxy api)
264 clientWithRoute (Proxy :: Proxy api)
265
265
266+-- | Ignore @'Summary'@ in client functions.
267+instance HasClient api => HasClient (Summary desc :> api) where
268+ type Client (Summary desc :> api) = Client api
269+
270+ clientWithRoute _ = clientWithRoute (Proxy :: Proxy api)
271+
272+-- | Ignore @'Description'@ in client functions.
273+instance HasClient api => HasClient (Description desc :> api) where
274+ type Client (Description desc :> api) = Client api
275+
276+ clientWithRoute _ = clientWithRoute (Proxy :: Proxy api)
277+
266-- | If you use a 'QueryParam' in one of your endpoints in your API,
278-- | If you use a 'QueryParam' in one of your endpoints in your API,
267-- the corresponding querying function will automatically take
279-- the corresponding querying function will automatically take
268-- an additional argument of the type specified by your 'QueryParam',
280-- an additional argument of the type specified by your 'QueryParam',
servant-docs/src/Servant/Docs/Internal.hs+21
@@ -798,6 +798,27 @@ instance HasDocs Raw where
798 docsFor _proxy (endpoint, action) _ =
798 docsFor _proxy (endpoint, action) _ =
799 single endpoint action
799 single endpoint action
800
800
801+
802+instance (KnownSymbol desc, HasDocs api)
803+ => HasDocs (Description desc :> api) where
804+
805+ docsFor Proxy (endpoint, action) =
806+ docsFor subApiP (endpoint, action')
807+
808+ where subApiP = Proxy :: Proxy api
809+ action' = over notes (|> note) action
810+ note = DocNote (symbolVal (Proxy :: Proxy desc)) []
811+
812+instance (KnownSymbol desc, HasDocs api)
813+ => HasDocs (Summary desc :> api) where
814+
815+ docsFor Proxy (endpoint, action) =
816+ docsFor subApiP (endpoint, action')
817+
818+ where subApiP = Proxy :: Proxy api
819+ action' = over notes (|> note) action
820+ note = DocNote (symbolVal (Proxy :: Proxy desc)) []
821+
801-- TODO: We use 'AllMimeRender' here because we need to be able to show the
822-- TODO: We use 'AllMimeRender' here because we need to be able to show the
802-- example data. However, there's no reason to believe that the instances of
823-- example data. However, there's no reason to believe that the instances of
803-- 'AllMimeUnrender' and 'AllMimeRender' actually agree (or to suppose that
824-- 'AllMimeUnrender' and 'AllMimeRender' actually agree (or to suppose that
servant-foreign/src/Servant/Foreign/Internal.hs+14
@@ -350,6 +350,20 @@ instance HasForeign lang ftype api
350 foreignFor lang ftype Proxy req =
350 foreignFor lang ftype Proxy req =
351 foreignFor lang ftype (Proxy :: Proxy api) req
351 foreignFor lang ftype (Proxy :: Proxy api) req
352
352
353+instance HasForeign lang ftype api
354+ => HasForeign lang ftype (Summary desc :> api) where
355+ type Foreign ftype (Summary desc :> api) = Foreign ftype api
356+
357+ foreignFor lang ftype Proxy req =
358+ foreignFor lang ftype (Proxy :: Proxy api) req
359+
360+instance HasForeign lang ftype api
361+ => HasForeign lang ftype (Description desc :> api) where
362+ type Foreign ftype (Description desc :> api) = Foreign ftype api
363+
364+ foreignFor lang ftype Proxy req =
365+ foreignFor lang ftype (Proxy :: Proxy api) req
366+
353-- | Utility class used by 'listFromAPI' which computes
367-- | Utility class used by 'listFromAPI' which computes
354-- the data needed to generate a function for each endpoint
368-- the data needed to generate a function for each endpoint
355-- and hands it all back in a list.
369-- and hands it all back in a list.
servant-server/src/Servant/Server/Internal.hs+14−1
@@ -58,7 +58,8 @@ import Servant.API ((:<|>) (..), (:>), BasicAuth, Capt
58 IsSecure(..), Header, QueryFlag,
58 IsSecure(..), Header, QueryFlag,
59 QueryParam, QueryParams, Raw,
59 QueryParam, QueryParams, Raw,
60 RemoteHost, ReqBody, Vault,
60 RemoteHost, ReqBody, Vault,
61− WithNamedContext)
61+ WithNamedContext,
62+ Description, Summary)
62import Servant.API.ContentTypes (AcceptHeader (..),
63import Servant.API.ContentTypes (AcceptHeader (..),
63 AllCTRender (..),
64 AllCTRender (..),
64 AllCTUnrender (..),
65 AllCTUnrender (..),
@@ -533,6 +534,18 @@ instance HasServer api context => HasServer (HttpVersion :> api) context where
533 route Proxy context subserver =
534 route Proxy context subserver =
534 route (Proxy :: Proxy api) context (passToServer subserver httpVersion)
535 route (Proxy :: Proxy api) context (passToServer subserver httpVersion)
535
536
537+-- | Ignore @'Summary'@ in server handlers.
538+instance HasServer api ctx => HasServer (Summary desc :> api) ctx where
539+ type ServerT (Summary desc :> api) m = ServerT api m
540+
541+ route _ = route (Proxy :: Proxy api)
542+
543+-- | Ignore @'Description'@ in server handlers.
544+instance HasServer api ctx => HasServer (Description desc :> api) ctx where
545+ type ServerT (Description desc :> api) m = ServerT api m
546+
547+ route _ = route (Proxy :: Proxy api)
548+
536-- | Singleton type representing a server that serves an empty API.
549-- | Singleton type representing a server that serves an empty API.
537data EmptyServer = EmptyServer deriving (Typeable, Eq, Show, Bounded, Enum)
550data EmptyServer = EmptyServer deriving (Typeable, Eq, Show, Bounded, Enum)
538
551