git.iko.soy/typeable/servant
on master help sign in
Merge pull request #755 from osa1/fix_reqbody_samples

Don't drop samples in `HasDocs ReqBody` instance

commitf0eec498a121ba3668b916e0fed9707f085119d2 authorOleg Grenrus <oleg.grenrus@iki.fi> dateFri 19 May 2017, 14:58 (9 years ago) parent1ccb0efd8dd1cb
1 file changed+8−7
servant-docs/src/Servant/Docs/Internal.hs+8−7
servant-docs/src/Servant/Docs/Internal.hs+8−7
@@ -249,7 +249,7 @@ data Action = Action
249249 , _notes :: [DocNote] -- user supplied
250250 , _mxParams :: [(String, [DocQueryParam])] -- type collected + user supplied info
251251 , _rqtypes :: [M.MediaType] -- type collected
252− , _rqbody :: [(M.MediaType, ByteString)] -- user supplied
252+ , _rqbody :: [(Text, M.MediaType, ByteString)] -- user supplied
253253 , _response :: Response -- user supplied
254254 } deriving (Eq, Ord, Show)
255255
@@ -618,7 +618,7 @@ markdown api = unlines $
618618
619619 where values = param ^. paramValues
620620
621− rqbodyStr :: [M.MediaType] -> [(M.MediaType, ByteString)]-> [String]
621+ rqbodyStr :: [M.MediaType] -> [(Text, M.MediaType, ByteString)]-> [String]
622622 rqbodyStr [] [] = []
623623 rqbodyStr types s =
624624 ["#### Request:", ""]
@@ -630,8 +630,8 @@ markdown api = unlines $
630630 <> map (\t -> " - `" <> show t <> "`") ts
631631 <> [""]
632632
633− formatBody (m, b) =
634− "- Example: `" <> cs (show m) <> "`" :
633+ formatBody (t, m, b) =
634+ "- Example (" <> cs t <> "): `" <> cs (show m) <> "`" :
635635 contentStr m b
636636
637637 markdownForType mime_type =
@@ -805,11 +805,12 @@ instance HasDocs Raw where
805805instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
806806 => HasDocs (ReqBody (ct ': cts) a :> api) where
807807
808− docsFor Proxy (endpoint, action) =
809− docsFor subApiP (endpoint, action')
808+ docsFor Proxy (endpoint, action) opts@DocOptions{..} =
809+ docsFor subApiP (endpoint, action') opts
810810
811811 where subApiP = Proxy :: Proxy api
812− action' = action & rqbody .~ sampleByteString t p
812+ action' :: Action
813+ action' = action & rqbody .~ take _maxSamples (sampleByteStrings t p)
813814 & rqtypes .~ allMime t
814815 t = Proxy :: Proxy (ct ': cts)
815816 p = Proxy :: Proxy a