[haskell-http-client] bug fixes; path & newtype generation issues (#6638)

* fix path generation/param-substitution issues

* fix newtype de-duplication issues

* refactoring only

* correct version in comments

* prevent duplicate MimeTypes

* sort parameter newtypes
This commit is contained in:
Jon Schoning
2017-10-10 10:01:48 -05:00
committed by wing328
parent dc88ed99ae
commit db67840ded
43 changed files with 4093 additions and 4127 deletions

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}
@@ -233,11 +234,11 @@ testEndpointParameters
-> SwaggerPetstoreRequest TestEndpointParameters contentType res
testEndpointParameters _ (Number number) (ParamDouble double) (PatternWithoutDelimiter patternWithoutDelimiter) (Byte byte) =
_mkRequest "POST" ["/fake"]
`_hasAuthType` (P.Proxy :: P.Proxy AuthBasicHttpBasicTest)
`addForm` toForm ("number", number)
`addForm` toForm ("double", double)
`addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter)
`addForm` toForm ("byte", byte)
`_hasAuthType` (P.Proxy :: P.Proxy AuthBasicHttpBasicTest)
data TestEndpointParameters
@@ -410,8 +411,8 @@ testClassname
-> SwaggerPetstoreRequest TestClassname contentType Client
testClassname _ body =
_mkRequest "PATCH" ["/fake_classname_test"]
`setBodyParam` body
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery)
`setBodyParam` body
data TestClassname
@@ -446,8 +447,8 @@ addPet
-> SwaggerPetstoreRequest AddPet contentType res
addPet _ body =
_mkRequest "POST" ["/pet"]
`setBodyParam` body
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
`setBodyParam` body
data AddPet
@@ -482,7 +483,6 @@ deletePet
-> SwaggerPetstoreRequest DeletePet MimeNoContent res
deletePet (PetId petId) =
_mkRequest "DELETE" ["/pet/",toPath petId]
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
data DeletePet
@@ -510,8 +510,8 @@ findPetsByStatus
-> SwaggerPetstoreRequest FindPetsByStatus MimeNoContent [Pet]
findPetsByStatus (Status status) =
_mkRequest "GET" ["/pet/findByStatus"]
`setQuery` toQueryColl CommaSeparated ("status", Just status)
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
`setQuery` toQueryColl CommaSeparated ("status", Just status)
data FindPetsByStatus
-- | @application/xml@
@@ -535,8 +535,8 @@ findPetsByTags
-> SwaggerPetstoreRequest FindPetsByTags MimeNoContent [Pet]
findPetsByTags (Tags tags) =
_mkRequest "GET" ["/pet/findByTags"]
`setQuery` toQueryColl CommaSeparated ("tags", Just tags)
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
`setQuery` toQueryColl CommaSeparated ("tags", Just tags)
{-# DEPRECATED findPetsByTags "" #-}
@@ -562,7 +562,6 @@ getPetById
-> SwaggerPetstoreRequest GetPetById MimeNoContent Pet
getPetById (PetId petId) =
_mkRequest "GET" ["/pet/",toPath petId]
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey)
data GetPetById
@@ -591,8 +590,8 @@ updatePet
-> SwaggerPetstoreRequest UpdatePet contentType res
updatePet _ body =
_mkRequest "PUT" ["/pet"]
`setBodyParam` body
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
`setBodyParam` body
data UpdatePet
@@ -629,7 +628,6 @@ updatePetWithForm
-> SwaggerPetstoreRequest UpdatePetWithForm contentType res
updatePetWithForm _ (PetId petId) =
_mkRequest "POST" ["/pet/",toPath petId]
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
data UpdatePetWithForm
@@ -670,7 +668,6 @@ uploadFile
-> SwaggerPetstoreRequest UploadFile contentType ApiResponse
uploadFile _ (PetId petId) =
_mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"]
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
data UploadFile
@@ -709,7 +706,6 @@ deleteOrder
-> SwaggerPetstoreRequest DeleteOrder MimeNoContent res
deleteOrder (OrderIdText orderId) =
_mkRequest "DELETE" ["/store/order/",toPath orderId]
data DeleteOrder
-- | @application/xml@
@@ -752,7 +748,6 @@ getOrderById
-> SwaggerPetstoreRequest GetOrderById MimeNoContent Order
getOrderById (OrderId orderId) =
_mkRequest "GET" ["/store/order/",toPath orderId]
data GetOrderById
-- | @application/xml@
@@ -892,7 +887,6 @@ deleteUser
-> SwaggerPetstoreRequest DeleteUser MimeNoContent res
deleteUser (Username username) =
_mkRequest "DELETE" ["/user/",toPath username]
data DeleteUser
-- | @application/xml@
@@ -914,7 +908,6 @@ getUserByName
-> SwaggerPetstoreRequest GetUserByName MimeNoContent User
getUserByName (Username username) =
_mkRequest "GET" ["/user/",toPath username]
data GetUserByName
-- | @application/xml@
@@ -987,7 +980,6 @@ updateUser
-> SwaggerPetstoreRequest UpdateUser contentType res
updateUser _ (Username username) body =
_mkRequest "PUT" ["/user/",toPath username]
`setBodyParam` body
data UpdateUser
@@ -1027,81 +1019,6 @@ class HasOptionalParam req param where
infixl 2 -&-
-- * Request Parameter Types
-- | ApiKey
newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show)
-- | StatusText
newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show)
-- | ParamString
newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Show)
-- | ParamInteger
newtype ParamInteger = ParamInteger { unParamInteger :: Int } deriving (P.Eq, P.Show)
-- | EnumQueryDouble
newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: Double } deriving (P.Eq, P.Show)
-- | Number
newtype Number = Number { unNumber :: Double } deriving (P.Eq, P.Show)
-- | Int32
newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show)
-- | ParamDate
newtype ParamDate = ParamDate { unParamDate :: Date } deriving (P.Eq, P.Show)
-- | EnumFormString
newtype EnumFormString = EnumFormString { unEnumFormString :: Text } deriving (P.Eq, P.Show)
-- | Body
newtype Body = Body { unBody :: [User] } deriving (P.Eq, P.Show, A.ToJSON)
-- | Tags
newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show)
-- | EnumQueryInteger
newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: Int } deriving (P.Eq, P.Show)
-- | ParamFloat
newtype ParamFloat = ParamFloat { unParamFloat :: Float } deriving (P.Eq, P.Show)
-- | Name2
newtype Name2 = Name2 { unName2 :: Text } deriving (P.Eq, P.Show)
-- | Password
newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show)
-- | Status
newtype Status = Status { unStatus :: [Text] } deriving (P.Eq, P.Show)
-- | ParamDouble
newtype ParamDouble = ParamDouble { unParamDouble :: Double } deriving (P.Eq, P.Show)
-- | EnumHeaderString
newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: Text } deriving (P.Eq, P.Show)
-- | Param2
newtype Param2 = Param2 { unParam2 :: Text } deriving (P.Eq, P.Show)
-- | PetId
newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show)
-- | OrderId
newtype OrderId = OrderId { unOrderId :: Integer } deriving (P.Eq, P.Show)
-- | OrderIdText
newtype OrderIdText = OrderIdText { unOrderIdText :: Text } deriving (P.Eq, P.Show)
-- | EnumQueryString
newtype EnumQueryString = EnumQueryString { unEnumQueryString :: Text } deriving (P.Eq, P.Show)
-- | ParamDateTime
newtype ParamDateTime = ParamDateTime { unParamDateTime :: DateTime } deriving (P.Eq, P.Show)
-- | EnumQueryStringArray
newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [Text] } deriving (P.Eq, P.Show)
-- | PatternWithoutDelimiter
newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show)
-- | Callback
newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show)
-- | Username
newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show)
-- | Int64
newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show)
-- | AdditionalMetadata
newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } deriving (P.Eq, P.Show)
-- | Byte
newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show)
-- | ParamBinary
newtype ParamBinary = ParamBinary { unParamBinary :: Binary } deriving (P.Eq, P.Show)
-- | EnumFormStringArray
newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [Text] } deriving (P.Eq, P.Show)
-- | EnumHeaderStringArray
newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [Text] } deriving (P.Eq, P.Show)
-- | Param
newtype Param = Param { unParam :: Text } deriving (P.Eq, P.Show)
-- | File
newtype File = File { unFile :: FilePath } deriving (P.Eq, P.Show)
-- * SwaggerPetstoreRequest
-- | Represents a request. The "req" type variable is the request type. The "res" type variable is the response type.

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}
@@ -65,8 +66,8 @@ data MimeOctetStream = MimeOctetStream deriving (P.Typeable)
data MimeNoContent = MimeNoContent deriving (P.Typeable)
data MimeAny = MimeAny deriving (P.Typeable)
data MimeXmlCharsetutf8 = MimeXmlCharsetutf8 deriving (P.Typeable)
data MimeJsonCharsetutf8 = MimeJsonCharsetutf8 deriving (P.Typeable)
data MimeXmlCharsetutf8 = MimeXmlCharsetutf8 deriving (P.Typeable)
-- ** MimeType Class
@@ -116,16 +117,16 @@ instance MimeType MimeAny where
instance MimeType MimeNoContent where
mimeType _ = Nothing
-- | @application/xml; charset=utf-8@
instance MimeType MimeXmlCharsetutf8 where
mimeType _ = Just $ P.fromString "application/xml; charset=utf-8"
-- | @application/json; charset=utf-8@
instance MimeType MimeJsonCharsetutf8 where
mimeType _ = Just $ P.fromString "application/json; charset=utf-8"
instance A.ToJSON a => MimeRender MimeJsonCharsetutf8 a where mimeRender _ = A.encode
instance A.FromJSON a => MimeUnrender MimeJsonCharsetutf8 a where mimeUnrender _ = A.eitherDecode
-- | @application/xml; charset=utf-8@
instance MimeType MimeXmlCharsetutf8 where
mimeType _ = Just $ P.fromString "application/xml; charset=utf-8"
-- ** MimeRender Class
@@ -182,8 +183,8 @@ instance MimeRender MimeNoContent NoContent where mimeRender _ = P.const BCL.emp
-- instance MimeRender MimeOctetStream Int where mimeRender _ = BB.toLazyByteString . BB.intDec
-- instance MimeRender MimeOctetStream Integer where mimeRender _ = BB.toLazyByteString . BB.integerDec
-- instance MimeRender MimeXmlCharsetutf8 T.Text where mimeRender _ = undefined
-- instance MimeRender MimeJsonCharsetutf8 T.Text where mimeRender _ = undefined
-- instance MimeRender MimeXmlCharsetutf8 T.Text where mimeRender _ = undefined
-- ** MimeUnrender Class
@@ -216,8 +217,8 @@ instance MimeUnrender MimeOctetStream String where mimeUnrender _ = P.Right . BC
-- | @P.Right . P.const NoContent@
instance MimeUnrender MimeNoContent NoContent where mimeUnrender _ = P.Right . P.const NoContent
-- instance MimeUnrender MimeXmlCharsetutf8 T.Text where mimeUnrender _ = undefined
-- instance MimeUnrender MimeJsonCharsetutf8 T.Text where mimeUnrender _ = undefined
-- instance MimeUnrender MimeXmlCharsetutf8 T.Text where mimeUnrender _ = undefined
-- ** Request Consumes

View File

@@ -3,7 +3,8 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
OpenAPI spec version: 2.0
Swagger Petstore API version: 1.0.0
Contact: apiteam@swagger.io
Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
-}
@@ -1398,6 +1399,45 @@ mkDog dogClassName =
}
-- * Parameter newtypes
newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } deriving (P.Eq, P.Show)
newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show)
newtype Body = Body { unBody :: [User] } deriving (P.Eq, P.Show, A.ToJSON)
newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show)
newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show)
newtype EnumFormString = EnumFormString { unEnumFormString :: Text } deriving (P.Eq, P.Show)
newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [Text] } deriving (P.Eq, P.Show)
newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: Text } deriving (P.Eq, P.Show)
newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [Text] } deriving (P.Eq, P.Show)
newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: Double } deriving (P.Eq, P.Show)
newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: Int } deriving (P.Eq, P.Show)
newtype EnumQueryString = EnumQueryString { unEnumQueryString :: Text } deriving (P.Eq, P.Show)
newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [Text] } deriving (P.Eq, P.Show)
newtype File = File { unFile :: FilePath } deriving (P.Eq, P.Show)
newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show)
newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show)
newtype Name2 = Name2 { unName2 :: Text } deriving (P.Eq, P.Show)
newtype Number = Number { unNumber :: Double } deriving (P.Eq, P.Show)
newtype OrderId = OrderId { unOrderId :: Integer } deriving (P.Eq, P.Show)
newtype OrderIdText = OrderIdText { unOrderIdText :: Text } deriving (P.Eq, P.Show)
newtype Param = Param { unParam :: Text } deriving (P.Eq, P.Show)
newtype Param2 = Param2 { unParam2 :: Text } deriving (P.Eq, P.Show)
newtype ParamBinary = ParamBinary { unParamBinary :: Binary } deriving (P.Eq, P.Show)
newtype ParamDate = ParamDate { unParamDate :: Date } deriving (P.Eq, P.Show)
newtype ParamDateTime = ParamDateTime { unParamDateTime :: DateTime } deriving (P.Eq, P.Show)
newtype ParamDouble = ParamDouble { unParamDouble :: Double } deriving (P.Eq, P.Show)
newtype ParamFloat = ParamFloat { unParamFloat :: Float } deriving (P.Eq, P.Show)
newtype ParamInteger = ParamInteger { unParamInteger :: Int } deriving (P.Eq, P.Show)
newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Show)
newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show)
newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show)
newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show)
newtype Status = Status { unStatus :: [Text] } deriving (P.Eq, P.Show)
newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show)
newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show)
newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show)
-- * Utils
-- | Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)