@@ -1,3 +1,4 @@
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DeriveTraversable #-}
4{-# LANGUAGE DeriveTraversable #-}
@@ -10,8 +11,12 @@
10{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE StandaloneDeriving #-}
12{-# LANGUAGE StandaloneDeriving #-}
12{-# LANGUAGE UndecidableInstances #-}
13{-# LANGUAGE UndecidableInstances #-}
14+#include "overlapping-compat.h"
13module Data.Swagger.Internal where
15module Data.Swagger.Internal where
15import Control.Applicative
20import Control.Applicative
16import Control.Monad
21import Control.Monad
17import Data.Aeson
22import Data.Aeson
@@ -334,10 +339,11 @@ data SwaggerItems t where
334 SwaggerItemsPrimitive :: Maybe (CollectionFormat t) -> ParamSchema t -> SwaggerItems t
339 SwaggerItemsPrimitive :: Maybe (CollectionFormat t) -> ParamSchema t -> SwaggerItems t
335 SwaggerItemsObject :: Referenced Schema -> SwaggerItems Schema
340 SwaggerItemsObject :: Referenced Schema -> SwaggerItems Schema
336 SwaggerItemsArray :: [Referenced Schema] -> SwaggerItems Schema
341 SwaggerItemsArray :: [Referenced Schema] -> SwaggerItems Schema
338deriving instance Eq (SwaggerItems t)
344deriving instance Eq (SwaggerItems t)
339deriving instance Show (SwaggerItems t)
345deriving instance Show (SwaggerItems t)
340−deriving instance Typeable (SwaggerItems t)
346+--deriving instance Typeable (SwaggerItems t)
342swaggerItemsPrimitiveConstr :: Constr
348swaggerItemsPrimitiveConstr :: Constr
343swaggerItemsPrimitiveConstr = mkConstr swaggerItemsDataType "SwaggerItemsPrimitive" [] Prefix
349swaggerItemsPrimitiveConstr = mkConstr swaggerItemsDataType "SwaggerItemsPrimitive" [] Prefix
@@ -345,7 +351,7 @@ swaggerItemsPrimitiveConstr = mkConstr swaggerItemsDataType "SwaggerItemsPrimiti
345swaggerItemsDataType :: DataType
351swaggerItemsDataType :: DataType
346swaggerItemsDataType = mkDataType "Data.Swagger.SwaggerItems" [swaggerItemsPrimitiveConstr]
352swaggerItemsDataType = mkDataType "Data.Swagger.SwaggerItems" [swaggerItemsPrimitiveConstr]
348−instance {-# OVERLAPPABLE #-} Data t => Data (SwaggerItems t) where
354+instance OVERLAPPABLE_ Data t => Data (SwaggerItems t) where
349 gunfold k z c = case constrIndex c of
355 gunfold k z c = case constrIndex c of
350 1 -> k (k (z SwaggerItemsPrimitive))
356 1 -> k (k (z SwaggerItemsPrimitive))
351 _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type (SwaggerItems t)."
357 _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type (SwaggerItems t)."
@@ -363,10 +369,10 @@ data SwaggerType t where
363 SwaggerFile :: SwaggerType ParamOtherSchema
369 SwaggerFile :: SwaggerType ParamOtherSchema
364 SwaggerNull :: SwaggerType Schema
370 SwaggerNull :: SwaggerType Schema
365 SwaggerObject :: SwaggerType Schema
371 SwaggerObject :: SwaggerType Schema
367deriving instance Eq (SwaggerType t)
374deriving instance Eq (SwaggerType t)
368deriving instance Show (SwaggerType t)
375deriving instance Show (SwaggerType t)
369−deriving instance Typeable (SwaggerType t)
371swaggerTypeConstr :: Data (SwaggerType t) => SwaggerType t -> Constr
377swaggerTypeConstr :: Data (SwaggerType t) => SwaggerType t -> Constr
372swaggerTypeConstr t = mkConstr (dataTypeOf t) (show t) [] Prefix
378swaggerTypeConstr t = mkConstr (dataTypeOf t) (show t) [] Prefix
@@ -387,17 +393,17 @@ swaggerTypeConstrs :: [Constr]
387swaggerTypeConstrs = map swaggerTypeConstr (swaggerCommonTypes :: [SwaggerType Schema])
393swaggerTypeConstrs = map swaggerTypeConstr (swaggerCommonTypes :: [SwaggerType Schema])
388 ++ [swaggerTypeConstr SwaggerFile, swaggerTypeConstr SwaggerNull, swaggerTypeConstr SwaggerObject]
394 ++ [swaggerTypeConstr SwaggerFile, swaggerTypeConstr SwaggerNull, swaggerTypeConstr SwaggerObject]
390−instance {-# OVERLAPPABLE #-} Typeable t => Data (SwaggerType t) where
396+instance OVERLAPPABLE_ Typeable t => Data (SwaggerType t) where
391 gunfold = gunfoldEnum "SwaggerType" swaggerCommonTypes
397 gunfold = gunfoldEnum "SwaggerType" swaggerCommonTypes
392 toConstr = swaggerTypeConstr
398 toConstr = swaggerTypeConstr
393 dataTypeOf = swaggerTypeDataType
399 dataTypeOf = swaggerTypeDataType
395−instance {-# OVERLAPPING #-} Data (SwaggerType ParamOtherSchema) where
401+instance OVERLAPPABLE_ Data (SwaggerType ParamOtherSchema) where
396 gunfold = gunfoldEnum "SwaggerType ParamOtherSchema" swaggerParamTypes
402 gunfold = gunfoldEnum "SwaggerType ParamOtherSchema" swaggerParamTypes
397 toConstr = swaggerTypeConstr
403 toConstr = swaggerTypeConstr
398 dataTypeOf = swaggerTypeDataType
404 dataTypeOf = swaggerTypeDataType
400−instance {-# OVERLAPPING #-} Data (SwaggerType Schema) where
406+instance OVERLAPPABLE_ Data (SwaggerType Schema) where
401 gunfold = gunfoldEnum "SwaggerType Schema" swaggerSchemaTypes
407 gunfold = gunfoldEnum "SwaggerType Schema" swaggerSchemaTypes
402 toConstr = swaggerTypeConstr
408 toConstr = swaggerTypeConstr
403 dataTypeOf = swaggerTypeDataType
409 dataTypeOf = swaggerTypeDataType
@@ -438,10 +444,10 @@ data CollectionFormat t where
438 -- instead of multiple values for a single instance @foo=bar&foo=baz@.
444 -- instead of multiple values for a single instance @foo=bar&foo=baz@.
439 -- This is valid only for parameters in @'ParamQuery'@ or @'ParamFormData'@.
445 -- This is valid only for parameters in @'ParamQuery'@ or @'ParamFormData'@.
440 CollectionMulti :: CollectionFormat ParamOtherSchema
446 CollectionMulti :: CollectionFormat ParamOtherSchema
442deriving instance Eq (CollectionFormat t)
449deriving instance Eq (CollectionFormat t)
443deriving instance Show (CollectionFormat t)
450deriving instance Show (CollectionFormat t)
444−deriving instance Typeable (CollectionFormat t)
446collectionFormatConstr :: CollectionFormat t -> Constr
452collectionFormatConstr :: CollectionFormat t -> Constr
447collectionFormatConstr cf = mkConstr collectionFormatDataType (show cf) [] Prefix
453collectionFormatConstr cf = mkConstr collectionFormatDataType (show cf) [] Prefix
@@ -453,12 +459,12 @@ collectionFormatDataType = mkDataType "Data.Swagger.CollectionFormat" $
453collectionCommonFormats :: [CollectionFormat t]
459collectionCommonFormats :: [CollectionFormat t]
454collectionCommonFormats = [ CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes ]
460collectionCommonFormats = [ CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes ]
456−instance {-# OVERLAPPABLE #-} Data t => Data (CollectionFormat t) where
462+instance OVERLAPPABLE_ Data t => Data (CollectionFormat t) where
457 gunfold = gunfoldEnum "CollectionFormat" collectionCommonFormats
463 gunfold = gunfoldEnum "CollectionFormat" collectionCommonFormats
458 toConstr = collectionFormatConstr
464 toConstr = collectionFormatConstr
459 dataTypeOf _ = collectionFormatDataType
465 dataTypeOf _ = collectionFormatDataType
461−deriving instance {-# OVERLAPPING #-} Data (CollectionFormat ParamOtherSchema)
467+deriving instance OVERLAPPABLE_ Data (CollectionFormat ParamOtherSchema)
463type ParamName = Text
469type ParamName = Text
@@ -788,7 +794,7 @@ instance SwaggerMonoid ParamLocation where
788 swaggerMempty = ParamQuery
794 swaggerMempty = ParamQuery
789 swaggerMappend _ y = y
795 swaggerMappend _ y = y
791−instance SwaggerMonoid (HashMap FilePath PathItem) where
797+instance OVERLAPPING_ SwaggerMonoid (HashMap FilePath PathItem) where
792 swaggerMempty = HashMap.empty
798 swaggerMempty = HashMap.empty
793 swaggerMappend = HashMap.unionWith mappend
799 swaggerMappend = HashMap.unionWith mappend
@@ -1051,12 +1057,12 @@ instance FromJSON Schema where
1051instance FromJSON Header where
1057instance FromJSON Header where
1052 parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "header")
1058 parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "header")
1054−instance {-# OVERLAPPABLE #-} (FromJSON (CollectionFormat t), FromJSON (ParamSchema t)) => FromJSON (SwaggerItems t) where
1060+instance OVERLAPPABLE_ (FromJSON (CollectionFormat t), FromJSON (ParamSchema t)) => FromJSON (SwaggerItems t) where
1055− parseJSON (Object o) = SwaggerItemsPrimitive
1061+ parseJSON = withObject "SwaggerItemsPrimitive" $ \o -> SwaggerItemsPrimitive
1056 <$> o .:? "collectionFormat"
1062 <$> o .:? "collectionFormat"
1057 <*> (o .: "items" >>= parseJSON)
1063 <*> (o .: "items" >>= parseJSON)
1059−instance {-# OVERLAPPING #-} FromJSON (SwaggerItems Schema) where
1065+instance OVERLAPPABLE_ FromJSON (SwaggerItems Schema) where
1060 parseJSON js@(Object _) = SwaggerItemsObject <$> parseJSON js
1066 parseJSON js@(Object _) = SwaggerItemsObject <$> parseJSON js
1061 parseJSON js@(Array _) = SwaggerItemsArray <$> parseJSON js
1067 parseJSON js@(Array _) = SwaggerItemsArray <$> parseJSON js
1062 parseJSON _ = empty
1068 parseJSON _ = empty
@@ -1128,6 +1134,7 @@ referencedParseJSON prefix js@(Object o) = do
1128 case Text.stripPrefix prefix s of
1134 case Text.stripPrefix prefix s of
1129 Nothing -> fail $ "expected $ref of the form \"" <> Text.unpack prefix <> "*\", but got " <> show s
1135 Nothing -> fail $ "expected $ref of the form \"" <> Text.unpack prefix <> "*\", but got " <> show s
1130 Just suffix -> pure (Reference suffix)
1136 Just suffix -> pure (Reference suffix)
1137+referencedParseJSON _ _ = fail "referenceParseJSON: not an object"
1132instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
1139instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
1133instance FromJSON (Referenced Param) where parseJSON = referencedParseJSON "#/parameters/"
1140instance FromJSON (Referenced Param) where parseJSON = referencedParseJSON "#/parameters/"
@@ -1142,10 +1149,10 @@ instance FromJSON (SwaggerType Schema) where
1142instance FromJSON (SwaggerType ParamOtherSchema) where
1149instance FromJSON (SwaggerType ParamOtherSchema) where
1143 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerFile]
1150 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerFile]
1145−instance {-# OVERLAPPABLE #-} FromJSON (SwaggerType t) where
1152+instance OVERLAPPABLE_ FromJSON (SwaggerType t) where
1146 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
1153 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
1148−instance {-# OVERLAPPABLE #-} FromJSON (CollectionFormat t) where
1155+instance OVERLAPPABLE_ FromJSON (CollectionFormat t) where
1149 parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]
1156 parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]
1151instance FromJSON (CollectionFormat ParamOtherSchema) where
1158instance FromJSON (CollectionFormat ParamOtherSchema) where