From ed3ace3066824c5c9485954311dc58233dc14fe6 Mon Sep 17 00:00:00 2001 From: Ivan Lazar Miljenovic Date: Fri, 6 Oct 2017 13:19:04 +1100 Subject: [PATCH] Handle request/response bodies with empty titles --- servant-docs/src/Servant/Docs/Internal.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index adfe3521..e4bae223 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -719,11 +719,15 @@ markdownWith RenderingOptions{..} api = unlines $ formatBody :: (Text, NonEmpty M.MediaType, ByteString) -> [String] formatBody (t, ms, b) = - "- " <> cs t <> " (" <> mediaList ms <> "):" : + "- " <> title <> " (" <> mediaList ms <> "):" : contentStr (NE.head ms) b where mediaList = fold . NE.intersperse ", " . fmap (\m -> "`" ++ show m ++ "`") + title + | T.null t = "Example" + | otherwise = cs t + markdownForType mime_type = case (M.mainType mime_type, M.subType mime_type) of ("text", "html") -> "html"