git.iko.soy/typeable/swagger2
on master help sign in
Remove DeriveAnyClass from validation tests
commite48bd53d14f33de3766d32b97be70d4595dca9d4 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateMon 1 Feb 2016, 16:28 (11 years ago) parent67221ec
1 file changed+22−6
test/Data/Swagger/Schema/ValidationSpec.hs+22−6
test/Data/Swagger/Schema/ValidationSpec.hs+22−6
@@ -1,5 +1,4 @@
11{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveAnyClass #-}
32{-# LANGUAGE DeriveGeneric #-}
43{-# LANGUAGE PackageImports #-}
54module Data.Swagger.Schema.ValidationSpec where
@@ -91,7 +90,14 @@ main = hspec spec
9190-- ========================================================================
9291-- Person (simple record with optional fields)
9392-- ========================================================================
94−data Person = Person { name :: String , phone :: Integer , email :: Maybe String } deriving (Show, Generic, ToSchema, ToJSON)
93+data Person = Person
94+ { name :: String
95+ , phone :: Integer
96+ , email :: Maybe String
97+ } deriving (Show, Generic)
98+
99+instance ToJSON Person
100+instance ToSchema Person
95101
96102instance Arbitrary Person where
97103 arbitrary = Person <$> arbitrary <*> arbitrary <*> arbitrary
@@ -99,7 +105,10 @@ instance Arbitrary Person where
99105-- ========================================================================
100106-- Color (enum)
101107-- ========================================================================
102−data Color = Red | Green | Blue deriving (Show, Generic, ToSchema, ToJSON, Bounded, Enum)
108+data Color = Red | Green | Blue deriving (Show, Generic, Bounded, Enum)
109+
110+instance ToJSON Color
111+instance ToSchema Color
103112
104113instance Arbitrary Color where
105114 arbitrary = arbitraryBoundedEnum
@@ -109,7 +118,10 @@ instance Arbitrary Color where
109118-- ========================================================================
110119
111120newtype Paint = Paint { color :: Color }
112− deriving (Show, Generic, ToSchema, ToJSON)
121+ deriving (Show, Generic)
122+
123+instance ToJSON Paint
124+instance ToSchema Paint
113125
114126instance Arbitrary Paint where
115127 arbitrary = Paint <$> arbitrary
@@ -121,7 +133,9 @@ instance Arbitrary Paint where
121133data MyRoseTree = MyRoseTree
122134 { root :: String
123135 , trees :: [MyRoseTree]
124− } deriving (Show, Generic, ToJSON)
136+ } deriving (Show, Generic)
137+
138+instance ToJSON MyRoseTree
125139
126140instance ToSchema MyRoseTree where
127141 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
@@ -138,7 +152,9 @@ instance Arbitrary MyRoseTree where
138152-- Light (sum type)
139153-- ========================================================================
140154
141−data Light = NoLight | LightFreq Double | LightColor Color deriving (Show, Generic, ToSchema)
155+data Light = NoLight | LightFreq Double | LightColor Color deriving (Show, Generic)
156+
157+instance ToSchema Light
142158
143159instance ToJSON Light where
144160 toJSON = genericToJSON defaultOptions { sumEncoding = ObjectWithSingleField }