@@ -341,73 +341,41 @@ deriving instance Eq (SwaggerType t)
341341deriving instance Show (SwaggerType t)
342342deriving instance Typeable (SwaggerType t)
343343
344−swaggerStringConstr :: DataType -> Constr
345−swaggerStringConstr dt = mkConstr dt "SwaggerString" [] Prefix
344+swaggerTypeConstr :: Data (SwaggerType t) => SwaggerType t -> Constr
345+swaggerTypeConstr t = mkConstr (dataTypeOf t) (show t) [] Prefix
346346
347−swaggerNumberConstr :: DataType -> Constr
348−swaggerNumberConstr dt = mkConstr dt "SwaggerNumber" [] Prefix
347+swaggerTypeDataType :: Data (SwaggerType t) => [SwaggerType t] -> SwaggerType t -> DataType
348+swaggerTypeDataType cons _ = mkDataType "Data.Swagger.SwaggerType" $ map swaggerTypeConstr cons
349349
350−swaggerIntegerConstr :: DataType -> Constr
351−swaggerIntegerConstr dt = mkConstr dt "SwaggerInteger" [] Prefix
350+swaggerCommonTypes :: [SwaggerType t]
351+swaggerCommonTypes = [SwaggerString, SwaggerNumber, SwaggerInteger, SwaggerBoolean, SwaggerArray]
352352
353−swaggerBooleanConstr :: DataType -> Constr
354−swaggerBooleanConstr dt = mkConstr dt "SwaggerBoolean" [] Prefix
353+swaggerParamTypes :: [SwaggerType ParamOtherSchema]
354+swaggerParamTypes = swaggerCommonTypes ++ [SwaggerFile]
355355
356−swaggerArrayConstr :: DataType -> Constr
357−swaggerArrayConstr dt = mkConstr dt "SwaggerArray" [] Prefix
358−
359−swaggerFileConstr :: DataType -> Constr
360−swaggerFileConstr dt = mkConstr dt "SwaggerFile" [] Prefix
361−
362−swaggerNullConstr :: DataType -> Constr
363−swaggerNullConstr dt = mkConstr dt "SwaggerNull" [] Prefix
364−
365−swaggerObjectConstr :: DataType -> Constr
366−swaggerObjectConstr dt = mkConstr dt "SwaggerObject" [] Prefix
367−
368−swaggerTypeDataType :: [DataType -> Constr] -> DataType
369−swaggerTypeDataType extra = dt
370− where
371− dt = mkDataType "Data.Swagger.SwaggerType" $ map ($ dt) $
372− [ swaggerStringConstr, swaggerNumberConstr, swaggerIntegerConstr, swaggerBooleanConstr , swaggerArrayConstr ]
373− ++ extra
374−
375−swaggerTypeToConstr :: Data (SwaggerType t) => SwaggerType t -> Constr
376−swaggerTypeToConstr t = case t of
377− SwaggerString -> swaggerStringConstr dt
378− SwaggerNumber -> swaggerNumberConstr dt
379− SwaggerInteger -> swaggerIntegerConstr dt
380− SwaggerBoolean -> swaggerBooleanConstr dt
381− SwaggerArray -> swaggerArrayConstr dt
382− SwaggerFile -> swaggerFileConstr dt
383− SwaggerNull -> swaggerNullConstr dt
384− SwaggerObject -> swaggerObjectConstr dt
385− where
386− dt = dataTypeOf t
356+swaggerSchemaTypes :: [SwaggerType Schema]
357+swaggerSchemaTypes = swaggerCommonTypes ++ [SwaggerNull, SwaggerObject]
387358
388359instance Data (SwaggerType Items) where
389− gunfold = gunfoldEnum "SwaggerType Items" $ zip [1..]
390− [SwaggerString, SwaggerNumber, SwaggerInteger, SwaggerBoolean, SwaggerArray]
391− toConstr = swaggerTypeToConstr
392− dataTypeOf _ = swaggerTypeDataType []
360+ gunfold = gunfoldEnum "SwaggerType Items" $ zip [1..] swaggerCommonTypes
361+ toConstr = swaggerTypeConstr
362+ dataTypeOf = swaggerTypeDataType swaggerCommonTypes
393363
394364instance Data (SwaggerType Header) where
395− gunfold = gunfoldEnum "SwaggerType Header" $ zip [1..]
396− [SwaggerString, SwaggerNumber, SwaggerInteger, SwaggerBoolean, SwaggerArray]
397− toConstr = swaggerTypeToConstr
398− dataTypeOf _ = swaggerTypeDataType []
365+ gunfold = gunfoldEnum "SwaggerType Header" $ zip [1..] swaggerCommonTypes
366+ toConstr = swaggerTypeConstr
367+ dataTypeOf = swaggerTypeDataType swaggerCommonTypes
399368
400369instance Data (SwaggerType ParamOtherSchema) where
401− gunfold = gunfoldEnum "SwaggerType ParamOtherSchema" $ zip [1..]
402− [SwaggerString, SwaggerNumber, SwaggerInteger, SwaggerBoolean, SwaggerArray, SwaggerFile]
403− toConstr = swaggerTypeToConstr
404− dataTypeOf _ = swaggerTypeDataType [swaggerFileConstr]
370+ gunfold = gunfoldEnum "SwaggerType ParamOtherSchema" $ zip [1..] swaggerParamTypes
371+ toConstr = swaggerTypeConstr
372+ dataTypeOf = swaggerTypeDataType swaggerParamTypes
405373
406374instance Data (SwaggerType Schema) where
407− gunfold = gunfoldEnum "SwaggerType Schema" $ zip [1, 2, 3, 4, 5, 7, 8]
408− [SwaggerString, SwaggerNumber, SwaggerInteger, SwaggerBoolean, SwaggerArray, SwaggerNull, SwaggerObject]
409− toConstr = swaggerTypeToConstr
410− dataTypeOf _ = swaggerTypeDataType [swaggerNullConstr, swaggerObjectConstr]
375+ gunfold = gunfoldEnum "SwaggerType Schema" $ zip ns swaggerSchemaTypes
376+ where ns = [1, 2, 3, 4, 5, 7, 8] -- skipping constructor #6 here
377+ toConstr = swaggerTypeConstr
378+ dataTypeOf = swaggerTypeDataType swaggerSchemaTypes
411379
412380data ParamLocation
413381 = -- | Parameters that are appended to the URL.
@@ -450,31 +418,19 @@ deriving instance Eq (CollectionFormat t)
450418deriving instance Show (CollectionFormat t)
451419deriving instance Typeable (CollectionFormat t)
452420
453−collectionCsvConstr :: Constr
454−collectionCsvConstr = mkConstr collectionFormatDataType "CollectionCSV" [] Prefix
455−
456−collectionSsvConstr :: Constr
457−collectionSsvConstr = mkConstr collectionFormatDataType "CollectionSSV" [] Prefix
458−
459−collectionTsvConstr :: Constr
460−collectionTsvConstr = mkConstr collectionFormatDataType "CollectionTSV" [] Prefix
461−
462−collectionPipesConstr :: Constr
463−collectionPipesConstr = mkConstr collectionFormatDataType "CollectionPipes" [] Prefix
421+collectionFormatConstr :: CollectionFormat t -> Constr
422+collectionFormatConstr cf = mkConstr collectionFormatDataType (show cf) [] Prefix
464423
465424collectionFormatDataType :: DataType
466−collectionFormatDataType = mkDataType "Data.Swagger.CollectionFormat"
467− [ collectionCsvConstr, collectionSsvConstr, collectionTsvConstr, collectionPipesConstr ]
425+collectionFormatDataType = mkDataType "Data.Swagger.CollectionFormat" $
426+ map collectionFormatConstr collectionCommonFormats
468427
469−instance {-# OVERLAPPABLE #-} Data t => Data (CollectionFormat t) where
470− gunfold = gunfoldEnum "CollectionFormat" $ zip [1..]
471− [ CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes ]
472−
473− toConstr CollectionCSV = collectionCsvConstr
474− toConstr CollectionSSV = collectionSsvConstr
475− toConstr CollectionTSV = collectionTsvConstr
476− toConstr CollectionPipes = collectionPipesConstr
428+collectionCommonFormats :: [CollectionFormat t]
429+collectionCommonFormats = [ CollectionCSV, CollectionSSV, CollectionTSV, CollectionPipes ]
477430
431+instance {-# OVERLAPPABLE #-} Data t => Data (CollectionFormat t) where
432+ gunfold = gunfoldEnum "CollectionFormat" $ zip [1..] collectionCommonFormats
433+ toConstr = collectionFormatConstr
478434 dataTypeOf _ = collectionFormatDataType
479435
480436deriving instance {-# OVERLAPPING #-} Data (CollectionFormat Param)