on master help sign in
Merge pull request #755 from osa1/fix_reqbody_samples
f0eec49Oleg Grenrus
servant-docs/src/Servant/Docs/Internal.hs+8−7
@@ -249,7 +249,7 @@ data Action = Action
249 , _notes :: [DocNote] -- user supplied
249 , _notes :: [DocNote] -- user supplied
250 , _mxParams :: [(String, [DocQueryParam])] -- type collected + user supplied info
250 , _mxParams :: [(String, [DocQueryParam])] -- type collected + user supplied info
251 , _rqtypes :: [M.MediaType] -- type collected
251 , _rqtypes :: [M.MediaType] -- type collected
252− , _rqbody :: [(M.MediaType, ByteString)] -- user supplied
252+ , _rqbody :: [(Text, M.MediaType, ByteString)] -- user supplied
253 , _response :: Response -- user supplied
253 , _response :: Response -- user supplied
254 } deriving (Eq, Ord, Show)
254 } deriving (Eq, Ord, Show)
255
255
@@ -618,7 +618,7 @@ markdown api = unlines $
618
618
619 where values = param ^. paramValues
619 where values = param ^. paramValues
620
620
621− rqbodyStr :: [M.MediaType] -> [(M.MediaType, ByteString)]-> [String]
621+ rqbodyStr :: [M.MediaType] -> [(Text, M.MediaType, ByteString)]-> [String]
622 rqbodyStr [] [] = []
622 rqbodyStr [] [] = []
623 rqbodyStr types s =
623 rqbodyStr types s =
624 ["#### Request:", ""]
624 ["#### Request:", ""]
@@ -630,8 +630,8 @@ markdown api = unlines $
630 <> map (\t -> " - `" <> show t <> "`") ts
630 <> map (\t -> " - `" <> show t <> "`") ts
631 <> [""]
631 <> [""]
632
632
633− formatBody (m, b) =
633+ formatBody (t, m, b) =
634− "- Example: `" <> cs (show m) <> "`" :
634+ "- Example (" <> cs t <> "): `" <> cs (show m) <> "`" :
635 contentStr m b
635 contentStr m b
636
636
637 markdownForType mime_type =
637 markdownForType mime_type =
@@ -805,11 +805,12 @@ instance HasDocs Raw where
805instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
805instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
806 => HasDocs (ReqBody (ct ': cts) a :> api) where
806 => HasDocs (ReqBody (ct ': cts) a :> api) where
807
807
808− docsFor Proxy (endpoint, action) =
808+ docsFor Proxy (endpoint, action) opts@DocOptions{..} =
809− docsFor subApiP (endpoint, action')
809+ docsFor subApiP (endpoint, action') opts
810
810
811 where subApiP = Proxy :: Proxy api
811 where subApiP = Proxy :: Proxy api
812− action' = action & rqbody .~ sampleByteString t p
812+ action' :: Action
813+ action' = action & rqbody .~ take _maxSamples (sampleByteStrings t p)
813 & rqtypes .~ allMime t
814 & rqtypes .~ allMime t
814 t = Proxy :: Proxy (ct ': cts)
815 t = Proxy :: Proxy (ct ': cts)
815 p = Proxy :: Proxy a
816 p = Proxy :: Proxy a