New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't drop samples in `HasDocs ReqBody` instance #755

Merged
merged 1 commit into from May 19, 2017
Jump to file or symbol
Failed to load files and symbols.
+8 −7
Diff settings

Always

Just for now

@@ -249,7 +249,7 @@ data Action = Action
, _notes :: [DocNote] -- user supplied
, _mxParams :: [(String, [DocQueryParam])] -- type collected + user supplied info
, _rqtypes :: [M.MediaType] -- type collected
, _rqbody :: [(M.MediaType, ByteString)] -- user supplied
, _rqbody :: [(Text, M.MediaType, ByteString)] -- user supplied
, _response :: Response -- user supplied
} deriving (Eq, Ord, Show)
@@ -618,7 +618,7 @@ markdown api = unlines $
where values = param ^. paramValues
rqbodyStr :: [M.MediaType] -> [(M.MediaType, ByteString)]-> [String]
rqbodyStr :: [M.MediaType] -> [(Text, M.MediaType, ByteString)]-> [String]
rqbodyStr [] [] = []
rqbodyStr types s =
["#### Request:", ""]
@@ -630,8 +630,8 @@ markdown api = unlines $
<> map (\t -> " - `" <> show t <> "`") ts
<> [""]
formatBody (m, b) =
"- Example: `" <> cs (show m) <> "`" :
formatBody (t, m, b) =
"- Example (" <> cs t <> "): `" <> cs (show m) <> "`" :
contentStr m b
markdownForType mime_type =
@@ -801,11 +801,12 @@ instance HasDocs Raw where
instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
=> HasDocs (ReqBody (ct ': cts) a :> api) where
docsFor Proxy (endpoint, action) =
docsFor subApiP (endpoint, action')
docsFor Proxy (endpoint, action) opts@DocOptions{..} =
docsFor subApiP (endpoint, action') opts
where subApiP = Proxy :: Proxy api
action' = action & rqbody .~ sampleByteString t p
action' :: Action
action' = action & rqbody .~ take _maxSamples (sampleByteStrings t p)
& rqtypes .~ allMime t
t = Proxy :: Proxy (ct ': cts)
p = Proxy :: Proxy a
ProTip! Use n and p to navigate between commits in a pull request.