@@ -45,6 +45,7 @@ spec = do
45 context "Sum types" $ do
45 context "Sum types" $ do
46 context "Status (sum of unary constructors)" $ checkToSchema (Proxy :: Proxy Status) statusSchemaJSON
46 context "Status (sum of unary constructors)" $ checkToSchema (Proxy :: Proxy Status) statusSchemaJSON
47 context "Character (ref and record sum)" $ checkToSchema (Proxy :: Proxy Character) characterSchemaJSON
47 context "Character (ref and record sum)" $ checkToSchema (Proxy :: Proxy Character) characterSchemaJSON
48+ context "Light (sum with unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Light) lightSchemaJSON
48 context "Schema name" $ do
49 context "Schema name" $ do
49 context "String" $ checkSchemaName Nothing (Proxy :: Proxy String)
50 context "String" $ checkSchemaName Nothing (Proxy :: Proxy String)
50 context "(Int, Float)" $ checkSchemaName Nothing (Proxy :: Proxy (Int, Float))
51 context "(Int, Float)" $ checkSchemaName Nothing (Proxy :: Proxy (Int, Float))
@@ -367,3 +368,33 @@ characterSchemaJSON = [aesonQQ|
367 "minProperties": 1
368 "minProperties": 1
372+-- ========================================================================
373+-- Light (sum type with unwrapUnaryRecords)
374+-- ========================================================================
379+ | LightWaveLength { waveLength :: Double }
382+instance ToSchema Light where
383+ toNamedSchema = genericToNamedSchema defaultSchemaOptions
384+ { unwrapUnaryRecords = True }
386+lightSchemaJSON :: Value
387+lightSchemaJSON = [aesonQQ|
392+ "LightFreq": { "type": "number" },
393+ "LightColor": { "$ref": "#/definitions/Color" },
394+ "LightWaveLength": { "type": "number" }