From ed702f59273da12316c2ee3a8deba65b31e09385 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Thu, 26 May 2016 21:22:11 +0100 Subject: [PATCH] servant-docs support for CaptureAll --- servant-docs/src/Servant/Docs/Internal.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index fad8717c..7b181822 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -702,6 +702,22 @@ instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs api) symP = Proxy :: Proxy sym +-- | @"books" :> 'CaptureAll' "isbn" Text@ will appear as +-- @/books/:isbn@ in the docs. +instance (KnownSymbol sym, ToCapture (CaptureAll sym a), HasDocs sublayout) + => HasDocs (CaptureAll sym a :> sublayout) where + + docsFor Proxy (endpoint, action) = + docsFor sublayoutP (endpoint', action') + + where sublayoutP = Proxy :: Proxy sublayout + captureP = Proxy :: Proxy (CaptureAll sym a) + + action' = over captures (|> toCapture captureP) action + endpoint' = over path (\p -> p ++ [":" ++ symbolVal symP]) endpoint + symP = Proxy :: Proxy sym + + instance OVERLAPPABLE_ (ToSample a, AllMimeRender (ct ': cts) a, KnownNat status , ReflectMethod method)