@@ -49,9 +49,9 @@ apiAlias n ls = TypeDecl noLoc n [] alias
4949
5050-- type Method = :> ...
5151verbAlias :: Name -> Method Solved -> Decl
52−verbAlias n m = TypeDecl noLoc n [] alias
52+verbAlias n m = TypeDecl noLoc n [] (alias (path ++ qry ++ media))
5353 where
54− alias = foldr' (\l r -> TyInfix l (UnQual (sym ":>")) r) verb (path ++ qry)
54+ alias = foldr' (\l r -> TyInfix l (UnQual (sym ":>")) r) verb
5555
5656 -- FIXME: rather than using 'terminal' to get the terminal type,
5757 -- write a custom 'Link' for servant to specify required params.
@@ -85,7 +85,16 @@ verbAlias n m = TypeDecl noLoc n [] alias
8585 Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
8686 Path -> Nothing
8787
88− params = _mParameters m
88+ media :: [Type]
89+ media | Just b <- _mRequest m =
90+ let g = ref b
91+ in if _mSupportsMediaUpload m
92+ then [TyApp (TyApp (TyCon "Multipart") typ) (parts g)]
93+ else [TyApp (TyApp (TyCon "ReqBody") typ) (tycon g)]
94+ | otherwise = []
95+ where
96+ parts g = TyCon (UnQual (name (Text.unpack ("'[" <> global g <> ", Body]"))))
97+ typ = TyCon "'[JSON]"
8998
9099 verb :: Type
91100 verb = TyApp (TyApp meth typ) res
@@ -94,6 +103,8 @@ verbAlias n m = TypeDecl noLoc n [] alias
94103 typ = TyCon "'[JSON]"
95104 res = maybe (TyCon "()") (tycon . ref) (_mResponse m)
96105
106+ params = _mParameters m
107+
97108requestDecl :: Global
98109 -> Prefix
99110 -> Name