@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DeriveDataTypeable #-}
23{-# LANGUAGE DeriveGeneric #-}
34{-# LANGUAGE DeriveTraversable #-}
@@ -10,8 +11,12 @@
1011{-# LANGUAGE ScopedTypeVariables #-}
1112{-# LANGUAGE StandaloneDeriving #-}
1213{-# LANGUAGE UndecidableInstances #-}
14+#include "overlapping-compat.h"
1315module Data.Swagger.Internal where
1416
17+import Prelude ()
18+import Prelude.Compat
19+
1520import Control.Applicative
1621import Control.Monad
1722import Data.Aeson
@@ -334,10 +339,11 @@ data SwaggerItems t where
334339 SwaggerItemsPrimitive :: Maybe (CollectionFormat t) -> ParamSchema t -> SwaggerItems t
335340 SwaggerItemsObject :: Referenced Schema -> SwaggerItems Schema
336341 SwaggerItemsArray :: [Referenced Schema] -> SwaggerItems Schema
342+ deriving (Typeable)
337343
338344deriving instance Eq (SwaggerItems t)
339345deriving instance Show (SwaggerItems t)
340−deriving instance Typeable (SwaggerItems t)
346+--deriving instance Typeable (SwaggerItems t)
341347
342348swaggerItemsPrimitiveConstr :: Constr
343349swaggerItemsPrimitiveConstr = mkConstr swaggerItemsDataType "SwaggerItemsPrimitive" [] Prefix
@@ -345,7 +351,7 @@ swaggerItemsPrimitiveConstr = mkConstr swaggerItemsDataType "SwaggerItemsPrimiti
345351swaggerItemsDataType :: DataType
346352swaggerItemsDataType = mkDataType "Data.Swagger.SwaggerItems" [swaggerItemsPrimitiveConstr]
347353
348−instance {-# OVERLAPPABLE #-} Data t => Data (SwaggerItems t) where
354+instance OVERLAPPABLE_ Data t => Data (SwaggerItems t) where
349355 gunfold k z c = case constrIndex c of
350356 1 -> k (k (z SwaggerItemsPrimitive))
351357 _ -> error $ "Data.Data.gunfold: Constructor " ++ show c ++ " is not of type (SwaggerItems t)."
@@ -363,10 +369,10 @@ data SwaggerType t where
363369 SwaggerFile :: SwaggerType ParamOtherSchema
364370 SwaggerNull :: SwaggerType Schema
365371 SwaggerObject :: SwaggerType Schema
372+ deriving (Typeable)
366373
367374deriving instance Eq (SwaggerType t)
368375deriving instance Show (SwaggerType t)
369−deriving instance Typeable (SwaggerType t)
370376
371377swaggerTypeConstr :: Data (SwaggerType t) => SwaggerType t -> Constr
372378swaggerTypeConstr t = mkConstr (dataTypeOf t) (show t) [] Prefix
@@ -387,17 +393,17 @@ swaggerTypeConstrs :: [Constr]
387393swaggerTypeConstrs = map swaggerTypeConstr (swaggerCommonTypes :: [SwaggerType Schema])
388394 ++ [swaggerTypeConstr SwaggerFile, swaggerTypeConstr SwaggerNull, swaggerTypeConstr SwaggerObject]
389395
390−instance {-# OVERLAPPABLE #-} Typeable t => Data (SwaggerType t) where
396+instance OVERLAPPABLE_ Typeable t => Data (SwaggerType t) where
391397 gunfold = gunfoldEnum "SwaggerType" swaggerCommonTypes
392398 toConstr = swaggerTypeConstr
393399 dataTypeOf = swaggerTypeDataType
394400
395−instance {-# OVERLAPPING #-} Data (SwaggerType ParamOtherSchema) where
401+instance OVERLAPPABLE_ Data (SwaggerType ParamOtherSchema) where
396402 gunfold = gunfoldEnum "SwaggerType ParamOtherSchema" swaggerParamTypes
397403 toConstr = swaggerTypeConstr
398404 dataTypeOf = swaggerTypeDataType
399405
400−instance {-# OVERLAPPING #-} Data (SwaggerType Schema) where
406+instance OVERLAPPABLE_ Data (SwaggerType Schema) where
401407 gunfold = gunfoldEnum "SwaggerType Schema" swaggerSchemaTypes
402408 toConstr = swaggerTypeConstr
403409 dataTypeOf = swaggerTypeDataType
@@ -438,10 +444,10 @@ data CollectionFormat t where
438444 -- instead of multiple values for a single instance @foo=bar&foo=baz@.
439445 -- This is valid only for parameters in @'ParamQuery'@ or @'ParamFormData'@.
440446 CollectionMulti :: CollectionFormat ParamOtherSchema
447+ deriving (Typeable)
441448
442449deriving instance Eq (CollectionFormat t)
443450deriving instance Show (CollectionFormat t)
444−deriving instance Typeable (CollectionFormat t)
445451
446452collectionFormatConstr :: CollectionFormat t -> Constr
447453collectionFormatConstr cf = mkConstr collectionFormatDataType (show cf) [] Prefix
@@ -453,12 +459,12 @@ collectionFormatDataType = mkDataType "Data.Swagger.CollectionFormat" $
453459collectionCommonFormats :: [CollectionFormat t]
454460collectionCommonFormats = [ CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes ]
455461
456−instance {-# OVERLAPPABLE #-} Data t => Data (CollectionFormat t) where
462+instance OVERLAPPABLE_ Data t => Data (CollectionFormat t) where
457463 gunfold = gunfoldEnum "CollectionFormat" collectionCommonFormats
458464 toConstr = collectionFormatConstr
459465 dataTypeOf _ = collectionFormatDataType
460466
461−deriving instance {-# OVERLAPPING #-} Data (CollectionFormat ParamOtherSchema)
467+deriving instance OVERLAPPABLE_ Data (CollectionFormat ParamOtherSchema)
462468
463469type ParamName = Text
464470
@@ -788,7 +794,7 @@ instance SwaggerMonoid ParamLocation where
788794 swaggerMempty = ParamQuery
789795 swaggerMappend _ y = y
790796
791−instance SwaggerMonoid (HashMap FilePath PathItem) where
797+instance OVERLAPPING_ SwaggerMonoid (HashMap FilePath PathItem) where
792798 swaggerMempty = HashMap.empty
793799 swaggerMappend = HashMap.unionWith mappend
794800
@@ -1051,12 +1057,12 @@ instance FromJSON Schema where
10511057instance FromJSON Header where
10521058 parseJSON = genericParseJSONWithSub "paramSchema" (jsonPrefix "header")
10531059
1054−instance {-# OVERLAPPABLE #-} (FromJSON (CollectionFormat t), FromJSON (ParamSchema t)) => FromJSON (SwaggerItems t) where
1055− parseJSON (Object o) = SwaggerItemsPrimitive
1060+instance OVERLAPPABLE_ (FromJSON (CollectionFormat t), FromJSON (ParamSchema t)) => FromJSON (SwaggerItems t) where
1061+ parseJSON = withObject "SwaggerItemsPrimitive" $ \o -> SwaggerItemsPrimitive
10561062 <$> o .:? "collectionFormat"
10571063 <*> (o .: "items" >>= parseJSON)
10581064
1059−instance {-# OVERLAPPING #-} FromJSON (SwaggerItems Schema) where
1065+instance OVERLAPPABLE_ FromJSON (SwaggerItems Schema) where
10601066 parseJSON js@(Object _) = SwaggerItemsObject <$> parseJSON js
10611067 parseJSON js@(Array _) = SwaggerItemsArray <$> parseJSON js
10621068 parseJSON _ = empty
@@ -1128,6 +1134,7 @@ referencedParseJSON prefix js@(Object o) = do
11281134 case Text.stripPrefix prefix s of
11291135 Nothing -> fail $ "expected $ref of the form \"" <> Text.unpack prefix <> "*\", but got " <> show s
11301136 Just suffix -> pure (Reference suffix)
1137+referencedParseJSON _ _ = fail "referenceParseJSON: not an object"
11311138
11321139instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
11331140instance FromJSON (Referenced Param) where parseJSON = referencedParseJSON "#/parameters/"
@@ -1142,10 +1149,10 @@ instance FromJSON (SwaggerType Schema) where
11421149instance FromJSON (SwaggerType ParamOtherSchema) where
11431150 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerFile]
11441151
1145−instance {-# OVERLAPPABLE #-} FromJSON (SwaggerType t) where
1152+instance OVERLAPPABLE_ FromJSON (SwaggerType t) where
11461153 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
11471154
1148−instance {-# OVERLAPPABLE #-} FromJSON (CollectionFormat t) where
1155+instance OVERLAPPABLE_ FromJSON (CollectionFormat t) where
11491156 parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]
11501157
11511158instance FromJSON (CollectionFormat ParamOtherSchema) where