Merge pull request #755 from osa1/fix_reqbody_samples
Don't drop samples in `HasDocs ReqBody` instance
This commit is contained in:
commit
f0eec498a1
1 changed files with 8 additions and 7 deletions
|
@ -249,7 +249,7 @@ data Action = Action
|
||||||
, _notes :: [DocNote] -- user supplied
|
, _notes :: [DocNote] -- user supplied
|
||||||
, _mxParams :: [(String, [DocQueryParam])] -- type collected + user supplied info
|
, _mxParams :: [(String, [DocQueryParam])] -- type collected + user supplied info
|
||||||
, _rqtypes :: [M.MediaType] -- type collected
|
, _rqtypes :: [M.MediaType] -- type collected
|
||||||
, _rqbody :: [(M.MediaType, ByteString)] -- user supplied
|
, _rqbody :: [(Text, M.MediaType, ByteString)] -- user supplied
|
||||||
, _response :: Response -- user supplied
|
, _response :: Response -- user supplied
|
||||||
} deriving (Eq, Ord, Show)
|
} deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ markdown api = unlines $
|
||||||
|
|
||||||
where values = param ^. paramValues
|
where values = param ^. paramValues
|
||||||
|
|
||||||
rqbodyStr :: [M.MediaType] -> [(M.MediaType, ByteString)]-> [String]
|
rqbodyStr :: [M.MediaType] -> [(Text, M.MediaType, ByteString)]-> [String]
|
||||||
rqbodyStr [] [] = []
|
rqbodyStr [] [] = []
|
||||||
rqbodyStr types s =
|
rqbodyStr types s =
|
||||||
["#### Request:", ""]
|
["#### Request:", ""]
|
||||||
|
@ -630,8 +630,8 @@ markdown api = unlines $
|
||||||
<> map (\t -> " - `" <> show t <> "`") ts
|
<> map (\t -> " - `" <> show t <> "`") ts
|
||||||
<> [""]
|
<> [""]
|
||||||
|
|
||||||
formatBody (m, b) =
|
formatBody (t, m, b) =
|
||||||
"- Example: `" <> cs (show m) <> "`" :
|
"- Example (" <> cs t <> "): `" <> cs (show m) <> "`" :
|
||||||
contentStr m b
|
contentStr m b
|
||||||
|
|
||||||
markdownForType mime_type =
|
markdownForType mime_type =
|
||||||
|
@ -805,11 +805,12 @@ instance HasDocs Raw where
|
||||||
instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
|
instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
|
||||||
=> HasDocs (ReqBody (ct ': cts) a :> api) where
|
=> HasDocs (ReqBody (ct ': cts) a :> api) where
|
||||||
|
|
||||||
docsFor Proxy (endpoint, action) =
|
docsFor Proxy (endpoint, action) opts@DocOptions{..} =
|
||||||
docsFor subApiP (endpoint, action')
|
docsFor subApiP (endpoint, action') opts
|
||||||
|
|
||||||
where subApiP = Proxy :: Proxy api
|
where subApiP = Proxy :: Proxy api
|
||||||
action' = action & rqbody .~ sampleByteString t p
|
action' :: Action
|
||||||
|
action' = action & rqbody .~ take _maxSamples (sampleByteStrings t p)
|
||||||
& rqtypes .~ allMime t
|
& rqtypes .~ allMime t
|
||||||
t = Proxy :: Proxy (ct ': cts)
|
t = Proxy :: Proxy (ct ': cts)
|
||||||
p = Proxy :: Proxy a
|
p = Proxy :: Proxy a
|
||||||
|
|
Loading…
Reference in a new issue