@@ -91,6 +91,8 @@ spec = do
9191 prop "Paint" $ shouldValidate (Proxy :: Proxy Paint)
9292 prop "MyRoseTree" $ shouldValidate (Proxy :: Proxy MyRoseTree)
9393 prop "Light" $ shouldValidate (Proxy :: Proxy Light)
94+ prop "Light TaggedObject" $ shouldValidate (Proxy :: Proxy LightTaggedObject)
95+ prop "Light UntaggedValue" $ shouldValidate (Proxy :: Proxy LightUntaggedValue)
9496 prop "ButtonImages" $ shouldValidate (Proxy :: Proxy ButtonImages)
9597 prop "Version" $ shouldValidate (Proxy :: Proxy Version)
9698 prop "FreeForm" $ shouldValidate (Proxy :: Proxy FreeForm)
@@ -203,6 +205,34 @@ instance Arbitrary Light where
203205invalidLightToJSON :: Light -> Value
204206invalidLightToJSON = genericToJSON defaultOptions
205207
208+-- Check all SumEncoding flavors.
209+
210+newtype LightTaggedObject = LightTaggedObject Light
211+ deriving (Show)
212+
213+instance ToJSON LightTaggedObject where
214+ toJSON (LightTaggedObject light) = genericToJSON defaultOptions { Data.Aeson.Types.sumEncoding = defaultTaggedObject } light
215+
216+instance ToSchema LightTaggedObject where
217+ declareNamedSchema _ =
218+ genericDeclareNamedSchema defaultSchemaOptions { Data.Swagger.sumEncoding = defaultTaggedObject } (Proxy :: Proxy Light)
219+
220+instance Arbitrary LightTaggedObject where
221+ arbitrary = LightTaggedObject <$> arbitrary
222+
223+newtype LightUntaggedValue = LightUntaggedValue Light
224+ deriving (Show)
225+
226+instance ToJSON LightUntaggedValue where
227+ toJSON (LightUntaggedValue light) = genericToJSON defaultOptions { Data.Aeson.Types.sumEncoding = UntaggedValue } light
228+
229+instance ToSchema LightUntaggedValue where
230+ declareNamedSchema _ =
231+ genericDeclareNamedSchema defaultSchemaOptions { Data.Swagger.sumEncoding = UntaggedValue } (Proxy :: Proxy Light)
232+
233+instance Arbitrary LightUntaggedValue where
234+ arbitrary = LightUntaggedValue <$> arbitrary
235+
206236-- ========================================================================
207237-- ButtonImages (bounded enum key mapping)
208238-- ========================================================================