@@ -91,6 +91,8 @@ spec = do
91 prop "Paint" $ shouldValidate (Proxy :: Proxy Paint)
91 prop "Paint" $ shouldValidate (Proxy :: Proxy Paint)
92 prop "MyRoseTree" $ shouldValidate (Proxy :: Proxy MyRoseTree)
92 prop "MyRoseTree" $ shouldValidate (Proxy :: Proxy MyRoseTree)
93 prop "Light" $ shouldValidate (Proxy :: Proxy Light)
93 prop "Light" $ shouldValidate (Proxy :: Proxy Light)
94+ prop "Light TaggedObject" $ shouldValidate (Proxy :: Proxy LightTaggedObject)
95+ prop "Light UntaggedValue" $ shouldValidate (Proxy :: Proxy LightUntaggedValue)
94 prop "ButtonImages" $ shouldValidate (Proxy :: Proxy ButtonImages)
96 prop "ButtonImages" $ shouldValidate (Proxy :: Proxy ButtonImages)
95 prop "Version" $ shouldValidate (Proxy :: Proxy Version)
97 prop "Version" $ shouldValidate (Proxy :: Proxy Version)
96 prop "FreeForm" $ shouldValidate (Proxy :: Proxy FreeForm)
98 prop "FreeForm" $ shouldValidate (Proxy :: Proxy FreeForm)
@@ -203,6 +205,34 @@ instance Arbitrary Light where
203invalidLightToJSON :: Light -> Value
205invalidLightToJSON :: Light -> Value
204invalidLightToJSON = genericToJSON defaultOptions
206invalidLightToJSON = genericToJSON defaultOptions
208+-- Check all SumEncoding flavors.
210+newtype LightTaggedObject = LightTaggedObject Light
213+instance ToJSON LightTaggedObject where
214+ toJSON (LightTaggedObject light) = genericToJSON defaultOptions { Data.Aeson.Types.sumEncoding = defaultTaggedObject } light
216+instance ToSchema LightTaggedObject where
217+ declareNamedSchema _ =
218+ genericDeclareNamedSchema defaultSchemaOptions { Data.Swagger.sumEncoding = defaultTaggedObject } (Proxy :: Proxy Light)
220+instance Arbitrary LightTaggedObject where
221+ arbitrary = LightTaggedObject <$> arbitrary
223+newtype LightUntaggedValue = LightUntaggedValue Light
226+instance ToJSON LightUntaggedValue where
227+ toJSON (LightUntaggedValue light) = genericToJSON defaultOptions { Data.Aeson.Types.sumEncoding = UntaggedValue } light
229+instance ToSchema LightUntaggedValue where
230+ declareNamedSchema _ =
231+ genericDeclareNamedSchema defaultSchemaOptions { Data.Swagger.sumEncoding = UntaggedValue } (Proxy :: Proxy Light)
233+instance Arbitrary LightUntaggedValue where
234+ arbitrary = LightUntaggedValue <$> arbitrary
206-- ========================================================================
236-- ========================================================================
207-- ButtonImages (bounded enum key mapping)
237-- ButtonImages (bounded enum key mapping)
208-- ========================================================================
238-- ========================================================================