@@ -49,9 +49,9 @@ apiAlias n ls = TypeDecl noLoc n [] alias
50-- type Method = :> ...
50-- type Method = :> ...
51verbAlias :: Name -> Method Solved -> Decl
51verbAlias :: Name -> Method Solved -> Decl
52−verbAlias n m = TypeDecl noLoc n [] alias
52+verbAlias n m = TypeDecl noLoc n [] (alias (path ++ qry ++ media))
54− alias = foldr' (\l r -> TyInfix l (UnQual (sym ":>")) r) verb (path ++ qry)
54+ alias = foldr' (\l r -> TyInfix l (UnQual (sym ":>")) r) verb
56 -- FIXME: rather than using 'terminal' to get the terminal type,
56 -- FIXME: rather than using 'terminal' to get the terminal type,
57 -- write a custom 'Link' for servant to specify required params.
57 -- write a custom 'Link' for servant to specify required params.
@@ -85,7 +85,16 @@ verbAlias n m = TypeDecl noLoc n [] alias
85 Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
85 Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
86 Path -> Nothing
86 Path -> Nothing
88− params = _mParameters m
88+ media :: [Type]
89+ media | Just b <- _mRequest m =
91+ in if _mSupportsMediaUpload m
92+ then [TyApp (TyApp (TyCon "Multipart") typ) (parts g)]
93+ else [TyApp (TyApp (TyCon "ReqBody") typ) (tycon g)]
96+ parts g = TyCon (UnQual (name (Text.unpack ("'[" <> global g <> ", Body]"))))
97+ typ = TyCon "'[JSON]"
90 verb :: Type
99 verb :: Type
91 verb = TyApp (TyApp meth typ) res
100 verb = TyApp (TyApp meth typ) res
@@ -94,6 +103,8 @@ verbAlias n m = TypeDecl noLoc n [] alias
94 typ = TyCon "'[JSON]"
103 typ = TyCon "'[JSON]"
95 res = maybe (TyCon "()") (tycon . ref) (_mResponse m)
104 res = maybe (TyCon "()") (tycon . ref) (_mResponse m)
106+ params = _mParameters m
97requestDecl :: Global
108requestDecl :: Global
98 -> Prefix
109 -> Prefix