@@ -45,6 +45,7 @@ spec = do
4545 context "Sum types" $ do
4646 context "Status (sum of unary constructors)" $ checkToSchema (Proxy :: Proxy Status) statusSchemaJSON
4747 context "Character (ref and record sum)" $ checkToSchema (Proxy :: Proxy Character) characterSchemaJSON
48+ context "Light (sum with unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Light) lightSchemaJSON
4849 context "Schema name" $ do
4950 context "String" $ checkSchemaName Nothing (Proxy :: Proxy String)
5051 context "(Int, Float)" $ checkSchemaName Nothing (Proxy :: Proxy (Int, Float))
@@ -367,3 +368,33 @@ characterSchemaJSON = [aesonQQ|
367368 "minProperties": 1
368369}
369370|]
371+
372+-- ========================================================================
373+-- Light (sum type with unwrapUnaryRecords)
374+-- ========================================================================
375+
376+data Light
377+ = LightFreq Double
378+ | LightColor Color
379+ | LightWaveLength { waveLength :: Double }
380+ deriving (Generic)
381+
382+instance ToSchema Light where
383+ toNamedSchema = genericToNamedSchema defaultSchemaOptions
384+ { unwrapUnaryRecords = True }
385+
386+lightSchemaJSON :: Value
387+lightSchemaJSON = [aesonQQ|
388+{
389+ "type": "object",
390+ "properties":
391+ {
392+ "LightFreq": { "type": "number" },
393+ "LightColor": { "$ref": "#/definitions/Color" },
394+ "LightWaveLength": { "type": "number" }
395+ },
396+ "maxProperties": 1,
397+ "minProperties": 1
398+}
399+|]
400+