@@ -24,6 +24,7 @@ spec :: Spec
2424spec = do
2525 describe "Generic ToParamSchema" $ do
2626 context "Color (bounded enum)" $ checkToParamSchema (Proxy :: Proxy Color) colorSchemaJSON
27+ context "Status (constructorTagModifier)" $ checkToParamSchema (Proxy :: Proxy Status) statusSchemaJSON
2728 context "Unary records" $ do
2829 context "Email (unary record)" $ checkToParamSchema (Proxy :: Proxy Email) emailSchemaJSON
2930 context "UserId (non-record newtype)" $ checkToParamSchema (Proxy :: Proxy UserId) userIdSchemaJSON
@@ -48,6 +49,24 @@ colorSchemaJSON = [aesonQQ|
4849}
4950|]
5051
52+-- ========================================================================
53+-- Status (constructorTagModifier)
54+-- ========================================================================
55+
56+data Status = StatusOk | StatusError deriving (Generic)
57+
58+instance ToParamSchema Status where
59+ toParamSchema = genericToParamSchema defaultSchemaOptions
60+ { constructorTagModifier = map toLower . drop (length "Status") }
61+
62+statusSchemaJSON :: Value
63+statusSchemaJSON = [aesonQQ|
64+{
65+ "type": "string",
66+ "enum": ["ok", "error"]
67+}
68+|]
69+
5170-- ========================================================================
5271-- Email (newtype with unwrapUnaryRecords set to True)
5372-- ========================================================================