git.iko.soy/typeable/servant
on master help sign in
Add `instance HasDocs EmptyAPI`
commit2cfa71891ba52db6d7c6d567e24132dc5443f23e authorDavid Turner <dave.c.turner@gmail.com> dateTue 16 May 2017, 09:52 (9 years ago) parenta87067a
2 files changed+8−3
doc/tutorial/Docs.lhs+4−3 servant-docs/src/Servant/Docs/Internal.hs+4
doc/tutorial/Docs.lhs+4−3
@@ -38,9 +38,10 @@ Like client function generation, documentation generation amounts to inspecting
3838This time however, we have to assist **servant**. While it is able to deduce a lot of things about our API, it can't magically come up with descriptions of the various pieces of our APIs that are human-friendly and explain what's going on "at the business-logic level". A good example to study for documentation generation is our webservice with the `/position`, `/hello` and `/marketing` endpoints from earlier:
3939
4040``` haskell
41−type ExampleAPI = "position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position
41+type ExampleAPI = ("position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position
4242 :<|> "hello" :> QueryParam "name" String :> Get '[JSON] HelloMessage
43− :<|> "marketing" :> ReqBody '[JSON] ClientInfo :> Post '[JSON] Email
43+ :<|> "marketing" :> ReqBody '[JSON] ClientInfo :> Post '[JSON] Email)
44+ :<|> EmptyAPI
4445
4546exampleAPI :: Proxy ExampleAPI
4647exampleAPI = Proxy
@@ -220,7 +221,7 @@ api :: Proxy DocsAPI
220221api = Proxy
221222
222223server :: Server DocsAPI
223−server = Server.server3 :<|> Tagged serveDocs where
224+server = (Server.server3 :<|> emptyAPIServer) :<|> Tagged serveDocs where
224225 serveDocs _ respond =
225226 respond $ responseLBS ok200 [plain] docsBS
226227 plain = ("Content-Type", "text/plain")
servant-docs/src/Servant/Docs/Internal.hs+4
@@ -683,6 +683,10 @@ instance OVERLAPPABLE_
683683 p2 :: Proxy b
684684 p2 = Proxy
685685
686+-- | The generated docs for @'EmptyAPI'@ are empty.
687+instance HasDocs EmptyAPI where
688+ docsFor Proxy _ _ = emptyAPI
689+
686690-- | @"books" :> 'Capture' "isbn" Text@ will appear as
687691-- @/books/:isbn@ in the docs.
688692instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs api)