diff --git a/doc/tutorial/Docs.lhs b/doc/tutorial/Docs.lhs index 67f6f60c..9dae710c 100644 --- a/doc/tutorial/Docs.lhs +++ b/doc/tutorial/Docs.lhs @@ -38,9 +38,10 @@ Like client function generation, documentation generation amounts to inspecting This 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: ``` haskell -type ExampleAPI = "position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position +type ExampleAPI = ("position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position :<|> "hello" :> QueryParam "name" String :> Get '[JSON] HelloMessage - :<|> "marketing" :> ReqBody '[JSON] ClientInfo :> Post '[JSON] Email + :<|> "marketing" :> ReqBody '[JSON] ClientInfo :> Post '[JSON] Email) + :<|> EmptyAPI exampleAPI :: Proxy ExampleAPI exampleAPI = Proxy @@ -220,7 +221,7 @@ api :: Proxy DocsAPI api = Proxy server :: Server DocsAPI -server = Server.server3 :<|> Tagged serveDocs where +server = (Server.server3 :<|> emptyAPIServer) :<|> Tagged serveDocs where serveDocs _ respond = respond $ responseLBS ok200 [plain] docsBS plain = ("Content-Type", "text/plain") diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index 2884473c..b5088f7a 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -683,6 +683,10 @@ instance OVERLAPPABLE_ p2 :: Proxy b p2 = Proxy +-- | The generated docs for @'EmptyAPI'@ are empty. +instance HasDocs EmptyAPI where + docsFor Proxy _ _ = emptyAPI + -- | @"books" :> 'Capture' "isbn" Text@ will appear as -- @/books/:isbn@ in the docs. instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs api)