Combine rendering of code samples for request/response bodies

This does mean that the "Example" portion for reqeust bodies is lost
though.
This commit is contained in:
Ivan Lazar Miljenovic 2017-10-05 14:48:20 +11:00
parent 4f8df0ebe2
commit 41d75b4de8

View file

@ -632,15 +632,18 @@ markdown api = unlines $
rqbodyStr types s =
["#### Request:", ""]
<> formatTypes types
<> concatMap formatBody s
<> formatBodies s
formatTypes [] = []
formatTypes ts = ["- Supported content types are:", ""]
<> map (\t -> " - `" <> show t <> "`") ts
<> [""]
formatBodies :: [(Text, M.MediaType, ByteString)] -> [String]
formatBodies = concatMap formatBody
formatBody (t, m, b) =
"- Example (" <> cs t <> "): `" <> cs (show m) <> "`" :
"- " <> cs t <> " (`" <> cs (show m) <> "`):" :
contentStr m b
markdownForType mime_type =
@ -676,7 +679,7 @@ markdown api = unlines $
[] -> ["- No response body\n"]
[("", t, r)] -> "- Response body as below." : contentStr t r
xs ->
concatMap (\(ctx, t, r) -> ("- " <> T.unpack ctx <> " (`" <> cs (show t) <> "`)") : contentStr t r) xs
formatBodies xs
-- * Instances