on master help sign in
Initial support for matrix parameters. Not complete, not sure how to document them yet, since documentation is focused on endpoints, not individual path fragments.
commit62f8a7f0900d6dd89950c8a544324c59ed9aafe4 authorDaniel Larsson <daniel.j.larsson@gmail.com> dateThu 1 Jan 2015, 23:42 (12 years ago) parent44efc7f
1 file changed+37
src/Servant/Docs.hs+37
src/Servant/Docs.hs+37
@@ -583,6 +583,43 @@ instance (KnownSymbol sym, ToParam (QueryFlag sym), HasDocs sublayout)
583583 paramP = Proxy :: Proxy (QueryFlag sym)
584584 action' = over params (|> toParam paramP) action
585585
586+
587+instance (KnownSymbol sym, {- ToParam (MatrixParam sym a), -} HasDocs sublayout)
588+ => HasDocs (MatrixParam sym a :> sublayout) where
589+
590+ docsFor Proxy (endpoint, action) =
591+ docsFor sublayoutP (endpoint', action)
592+
593+ where sublayoutP = Proxy :: Proxy sublayout
594+
595+ endpoint' = over path (\p -> p++";"++symbolVal symP) endpoint
596+ symP = Proxy :: Proxy sym
597+
598+
599+instance (KnownSymbol sym, {- ToParam (MatrixParams sym a), -} HasDocs sublayout)
600+ => HasDocs (MatrixParams sym a :> sublayout) where
601+
602+ docsFor Proxy (endpoint, action) =
603+ docsFor sublayoutP (endpoint', action)
604+
605+ where sublayoutP = Proxy :: Proxy sublayout
606+
607+ endpoint' = over path (\p -> p++";"++symbolVal symP) endpoint
608+ symP = Proxy :: Proxy sym
609+
610+
611+instance (KnownSymbol sym, {- ToParam (MatrixFlag sym), -} HasDocs sublayout)
612+ => HasDocs (MatrixFlag sym :> sublayout) where
613+
614+ docsFor Proxy (endpoint, action) =
615+ docsFor sublayoutP (endpoint', action)
616+
617+ where sublayoutP = Proxy :: Proxy sublayout
618+
619+ endpoint' = over path (\p -> p++";"++symbolVal symP) endpoint
620+ symP = Proxy :: Proxy sym
621+
622+
586623instance HasDocs Raw where
587624 docsFor _proxy (endpoint, action) =
588625 single endpoint action