@@ -31,6 +31,8 @@ spec = do
31 context "Person" $ checkToSchema (Proxy :: Proxy Person) personSchemaJSON
31 context "Person" $ checkToSchema (Proxy :: Proxy Person) personSchemaJSON
32 context "ISPair" $ checkToSchema (Proxy :: Proxy ISPair) ispairSchemaJSON
32 context "ISPair" $ checkToSchema (Proxy :: Proxy ISPair) ispairSchemaJSON
33 context "Point (fieldLabelModifier)" $ checkToSchema (Proxy :: Proxy Point) pointSchemaJSON
33 context "Point (fieldLabelModifier)" $ checkToSchema (Proxy :: Proxy Point) pointSchemaJSON
34+ context "Color (bounded enum)" $ checkToSchema (Proxy :: Proxy Color) colorSchemaJSON
35+ context "Paint (record with bounded enum field)" $ checkToSchema (Proxy :: Proxy Paint) paintSchemaJSON
34 context "Unary records" $ do
36 context "Unary records" $ do
35 context "Email (unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Email) emailSchemaJSON
37 context "Email (unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Email) emailSchemaJSON
36 context "UserId (non-record newtype)" $ checkToSchema (Proxy :: Proxy UserId) userIdSchemaJSON
38 context "UserId (non-record newtype)" $ checkToSchema (Proxy :: Proxy UserId) userIdSchemaJSON
@@ -115,7 +117,7 @@ pointSchemaJSON = [aesonQQ|
117-- ========================================================================
119-- ========================================================================
118−-- Point (record data type with custom fieldLabelModifier)
120+-- Color (bounded enum)
119-- ========================================================================
121-- ========================================================================
120data Color
122data Color
@@ -124,7 +126,7 @@ data Color
124 deriving (Generic, Enum, Bounded, ToJSON)
126 deriving (Generic, Enum, Bounded, ToJSON)
126instance ToSchema Color where
128instance ToSchema Color where
127− toNamedSchema = genericToNamedSchemaBoundedEnum
129+ toNamedSchema = genericToNamedSchemaBoundedEnum defaultSchemaOptions
129colorSchemaJSON :: Value
131colorSchemaJSON :: Value
130colorSchemaJSON = [aesonQQ|
132colorSchemaJSON = [aesonQQ|
@@ -134,6 +136,28 @@ colorSchemaJSON = [aesonQQ|
139+-- ========================================================================
140+-- Paint (record with bounded enum property)
141+-- ========================================================================
143+newtype Paint = Paint { color :: Color }
144+ deriving (Generic, ToSchema)
146+paintSchemaJSON :: Value
147+paintSchemaJSON = [aesonQQ|
154+ "$ref": "#/definitions/Color"
157+ "required": ["color"]
137-- ========================================================================
161-- ========================================================================
138-- Email (newtype with unwrapUnaryRecords set to True)
162-- Email (newtype with unwrapUnaryRecords set to True)
139-- ========================================================================
163-- ========================================================================