@@ -41,6 +41,8 @@ spec = do
4141 context "Player (unary record)" $ checkToSchema (Proxy :: Proxy Player) playerSchemaJSON
4242 context "Players (inlining schema)" $ checkToSchema (Proxy :: Proxy Players) playersSchemaJSON
4343 context "MyRoseTree (datatypeNameModifier)" $ checkToSchema (Proxy :: Proxy MyRoseTree) myRoseTreeSchemaJSON
44+ context "Sum types" $ do
45+ context "Status (sum of unary constructors)" $ checkToSchema (Proxy :: Proxy Status) statusSchemaJSON
4446 context "Schema name" $ do
4547 context "String" $ checkSchemaName Nothing (Proxy :: Proxy String)
4648 context "(Int, Float)" $ checkSchemaName Nothing (Proxy :: Proxy (Int, Float))
@@ -295,3 +297,26 @@ playersSchemaJSON = [aesonQQ|
295297}
296298|]
297299
300+-- ========================================================================
301+-- Status (sum type with unary constructors)
302+-- ========================================================================
303+
304+data Status
305+ = StatusOk String
306+ | StatusError String
307+ deriving (Generic, ToSchema)
308+
309+statusSchemaJSON :: Value
310+statusSchemaJSON = [aesonQQ|
311+{
312+ "type": "object",
313+ "properties":
314+ {
315+ "StatusOk": { "type": "string" },
316+ "StatusError": { "type": "string" }
317+ },
318+ "maxProperties": 1,
319+ "minProperties": 1
320+}
321+|]
322+