@@ -295,7 +295,7 @@ data ParamOtherSchema = ParamOtherSchema
295295 -- Default value is csv.
296296 , _paramOtherSchemaCollectionFormat :: Maybe (CollectionFormat Param)
297297
298− , _paramOtherSchemaCommon :: SchemaCommon Param Items
298+ , _paramOtherSchemaCommon :: SchemaCommon ParamOtherSchema Items
299299 } deriving (Eq, Show, Generic)
300300
301301data SwaggerType t where
@@ -304,7 +304,7 @@ data SwaggerType t where
304304 SwaggerInteger :: SwaggerType t
305305 SwaggerBoolean :: SwaggerType t
306306 SwaggerArray :: SwaggerType t
307− SwaggerFile :: SwaggerType Param
307+ SwaggerFile :: SwaggerType ParamOtherSchema
308308 SwaggerNull :: SwaggerType Schema
309309 SwaggerObject :: SwaggerType Schema
310310
@@ -487,7 +487,7 @@ data Header = Header
487487 -- Default value is @'ItemsCollectionCSV'@.
488488 , _headerCollectionFormat :: Maybe (CollectionFormat Items)
489489
490− , _headerCommon :: SchemaCommon Items Items
490+ , _headerCommon :: SchemaCommon Header Items
491491 } deriving (Eq, Show, Generic)
492492
493493data Example = Example { getExample :: Map MediaType Value }
@@ -968,10 +968,10 @@ instance FromJSON Xml where
968968instance FromJSON (SwaggerType Schema) where
969969 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerNull, SwaggerObject]
970970
971−instance FromJSON (SwaggerType Param) where
971+instance FromJSON (SwaggerType ParamOtherSchema) where
972972 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray, SwaggerFile]
973973
974−instance FromJSON (SwaggerType Items) where
974+instance {-# OVERLAPPABLE #-} FromJSON (SwaggerType t) where
975975 parseJSON = parseOneOf [SwaggerString, SwaggerInteger, SwaggerNumber, SwaggerBoolean, SwaggerArray]
976976
977977instance FromJSON (CollectionFormat Param) where
@@ -980,5 +980,8 @@ instance FromJSON (CollectionFormat Param) where
980980instance FromJSON (CollectionFormat Items) where
981981 parseJSON = parseOneOf [CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes]
982982
983+-- NOTE: The constraint @FromJSON (SwaggerType t)@ is necessary here!
984+-- Without the constraint the general instance will be used
985+-- that only accepts common types (i.e. NOT object, null or file).
983986instance (FromJSON (SwaggerType t), FromJSON i) => FromJSON (SchemaCommon t i) where
984987 parseJSON = genericParseJSON (jsonPrefix "SchemaCommon")