git.iko.soy/typeable/openapi3
on master help sign in
Remove DeriveAnyClass from validation tests
e48bd53Nickolay Kudasov
test/Data/Swagger/Schema/ValidationSpec.hs+22−6
@@ -1,5 +1,4 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveAnyClass #-}
3{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE PackageImports #-}
3{-# LANGUAGE PackageImports #-}
5module Data.Swagger.Schema.ValidationSpec where
4module Data.Swagger.Schema.ValidationSpec where
@@ -91,7 +90,14 @@ main = hspec spec
91-- ========================================================================
90-- ========================================================================
92-- Person (simple record with optional fields)
91-- Person (simple record with optional fields)
93-- ========================================================================
92-- ========================================================================
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
95
101
96instance Arbitrary Person where
102instance Arbitrary Person where
97 arbitrary = Person <$> arbitrary <*> arbitrary <*> arbitrary
103 arbitrary = Person <$> arbitrary <*> arbitrary <*> arbitrary
@@ -99,7 +105,10 @@ instance Arbitrary Person where
99-- ========================================================================
105-- ========================================================================
100-- Color (enum)
106-- Color (enum)
101-- ========================================================================
107-- ========================================================================
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
103
112
104instance Arbitrary Color where
113instance Arbitrary Color where
105 arbitrary = arbitraryBoundedEnum
114 arbitrary = arbitraryBoundedEnum
@@ -109,7 +118,10 @@ instance Arbitrary Color where
109-- ========================================================================
118-- ========================================================================
110
119
111newtype Paint = Paint { color :: Color }
120newtype Paint = Paint { color :: Color }
112− deriving (Show, Generic, ToSchema, ToJSON)
121+ deriving (Show, Generic)
122+
123+instance ToJSON Paint
124+instance ToSchema Paint
113
125
114instance Arbitrary Paint where
126instance Arbitrary Paint where
115 arbitrary = Paint <$> arbitrary
127 arbitrary = Paint <$> arbitrary
@@ -121,7 +133,9 @@ instance Arbitrary Paint where
121data MyRoseTree = MyRoseTree
133data MyRoseTree = MyRoseTree
122 { root :: String
134 { root :: String
123 , trees :: [MyRoseTree]
135 , trees :: [MyRoseTree]
124− } deriving (Show, Generic, ToJSON)
136+ } deriving (Show, Generic)
137+
138+instance ToJSON MyRoseTree
125
139
126instance ToSchema MyRoseTree where
140instance ToSchema MyRoseTree where
127 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
141 declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
@@ -138,7 +152,9 @@ instance Arbitrary MyRoseTree where
138-- Light (sum type)
152-- Light (sum type)
139-- ========================================================================
153-- ========================================================================
140
154
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
142
158
143instance ToJSON Light where
159instance ToJSON Light where
144 toJSON = genericToJSON defaultOptions { sumEncoding = ObjectWithSingleField }
160 toJSON = genericToJSON defaultOptions { sumEncoding = ObjectWithSingleField }