git.iko.soy/typeable/servant
on master help sign in
Don't drop samples in `HasDocs ReqBody` instance
d8dd1cbÖmer Sinan Ağacan
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 =
@@ -801,11 +801,12 @@ instance HasDocs Raw where
801instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
801instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
802 => HasDocs (ReqBody (ct ': cts) a :> api) where
802 => HasDocs (ReqBody (ct ': cts) a :> api) where
803
803
804− docsFor Proxy (endpoint, action) =
804+ docsFor Proxy (endpoint, action) opts@DocOptions{..} =
805− docsFor subApiP (endpoint, action')
805+ docsFor subApiP (endpoint, action') opts
806
806
807 where subApiP = Proxy :: Proxy api
807 where subApiP = Proxy :: Proxy api
808− action' = action & rqbody .~ sampleByteString t p
808+ action' :: Action
809+ action' = action & rqbody .~ take _maxSamples (sampleByteStrings t p)
809 & rqtypes .~ allMime t
810 & rqtypes .~ allMime t
810 t = Proxy :: Proxy (ct ': cts)
811 t = Proxy :: Proxy (ct ': cts)
811 p = Proxy :: Proxy a
812 p = Proxy :: Proxy a