@@ -9,6 +9,7 @@ import Data.Aeson
9import Data.Aeson.QQ
9import Data.Aeson.QQ
10import Data.Char
10import Data.Char
11import Data.Proxy
11import Data.Proxy
12import GHC.Generics
13import GHC.Generics
14import Data.Swagger
15import Data.Swagger
@@ -33,6 +34,7 @@ spec = do
33 context "Point (fieldLabelModifier)" $ checkToSchema (Proxy :: Proxy Point) pointSchemaJSON
34 context "Point (fieldLabelModifier)" $ checkToSchema (Proxy :: Proxy Point) pointSchemaJSON
34 context "Color (bounded enum)" $ checkToSchema (Proxy :: Proxy Color) colorSchemaJSON
35 context "Color (bounded enum)" $ checkToSchema (Proxy :: Proxy Color) colorSchemaJSON
35 context "Paint (record with bounded enum field)" $ checkToSchema (Proxy :: Proxy Paint) paintSchemaJSON
36 context "Paint (record with bounded enum field)" $ checkToSchema (Proxy :: Proxy Paint) paintSchemaJSON
37+ context "UserGroup (set newtype)" $ checkToSchema (Proxy :: Proxy UserGroup) userGroupSchemaJSON
36 context "Unary records" $ do
38 context "Unary records" $ do
37 context "Email (unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Email) emailSchemaJSON
39 context "Email (unwrapUnaryRecords)" $ checkToSchema (Proxy :: Proxy Email) emailSchemaJSON
38 context "UserId (non-record newtype)" $ checkToSchema (Proxy :: Proxy UserId) userIdSchemaJSON
40 context "UserId (non-record newtype)" $ checkToSchema (Proxy :: Proxy UserId) userIdSchemaJSON
@@ -181,7 +183,7 @@ emailSchemaJSON = [aesonQQ|
181-- ========================================================================
183-- ========================================================================
183newtype UserId = UserId Integer
185newtype UserId = UserId Integer
184− deriving (Generic, ToSchema)
186+ deriving (Eq, Ord, Generic, ToSchema)
186userIdSchemaJSON :: Value
188userIdSchemaJSON :: Value
187userIdSchemaJSON = [aesonQQ|
189userIdSchemaJSON = [aesonQQ|
@@ -190,6 +192,22 @@ userIdSchemaJSON = [aesonQQ|
195+-- ========================================================================
196+-- UserGroup (set newtype)
197+-- ========================================================================
199+newtype UserGroup = UserGroup (Set UserId)
200+ deriving (Generic, ToSchema)
202+userGroupSchemaJSON :: Value
203+userGroupSchemaJSON = [aesonQQ|
206+ "items": { "$ref": "#/definitions/UserId" },
193-- ========================================================================
211-- ========================================================================
194-- Player (record newtype)
212-- Player (record newtype)
195-- ========================================================================
213-- ========================================================================