@@ -4,649 +4,649 @@
5module Data.Swagger.CommonTestTypes where
5module Data.Swagger.CommonTestTypes where
7− import Prelude ()
7+import Prelude ()
8− import Prelude.Compat
8+import Prelude.Compat
10− import Data.Aeson (Value, ToJSON(..), ToJSONKey(..))
10+import Data.Aeson (Value, ToJSON(..), ToJSONKey(..))
11− import Data.Aeson.Types (toJSONKeyText)
11+import Data.Aeson.Types (toJSONKeyText)
12− import Data.Aeson.QQ
12+import Data.Aeson.QQ
13− import Data.Char
13+import Data.Char
14− import Data.Proxy
14+import Data.Proxy
15− import Data.Set (Set)
15+import Data.Set (Set)
16− import Data.Map (Map)
16+import Data.Map (Map)
17− import qualified Data.Text as Text
17+import qualified Data.Text as Text
18− import GHC.Generics
18+import GHC.Generics
20− import Data.Swagger
20+import Data.Swagger
21− import Data.Swagger.Declare
21+import Data.Swagger.Declare
22− import Data.Swagger.Internal (SwaggerKind(..))
22+import Data.Swagger.Internal (SwaggerKind(..))
24− -- ========================================================================
24+-- ========================================================================
25− -- Unit type
25+-- Unit type
26− -- ========================================================================
26+-- ========================================================================
28− data Unit = Unit deriving (Generic)
28+data Unit = Unit deriving (Generic)
29− instance ToParamSchema Unit
29+instance ToParamSchema Unit
30− instance ToSchema Unit
30+instance ToSchema Unit
32− unitSchemaJSON :: Value
32+unitSchemaJSON :: Value
33− unitSchemaJSON = [aesonQQ|
33+unitSchemaJSON = [aesonQQ|
35− "type": "string",
35+ "type": "string",
36− "enum": ["Unit"]
36+ "enum": ["Unit"]
40− -- ========================================================================
40+-- ========================================================================
41− -- Color (enum)
41+-- Color (enum)
42− -- ========================================================================
42+-- ========================================================================
43− data Color
43+data Color
47− deriving (Generic)
47+ deriving (Generic)
48− instance ToParamSchema Color
48+instance ToParamSchema Color
49− instance ToSchema Color
49+instance ToSchema Color
51− colorSchemaJSON :: Value
51+colorSchemaJSON :: Value
52− colorSchemaJSON = [aesonQQ|
52+colorSchemaJSON = [aesonQQ|
54− "type": "string",
54+ "type": "string",
55− "enum": ["Red", "Green", "Blue"]
55+ "enum": ["Red", "Green", "Blue"]
59− -- ========================================================================
59+-- ========================================================================
60− -- Shade (paramSchemaToNamedSchema)
60+-- Shade (paramSchemaToNamedSchema)
61− -- ========================================================================
61+-- ========================================================================
63− data Shade = Dim | Bright deriving (Generic)
63+data Shade = Dim | Bright deriving (Generic)
64− instance ToParamSchema Shade
64+instance ToParamSchema Shade
66− instance ToSchema Shade where declareNamedSchema = pure . paramSchemaToNamedSchema defaultSchemaOptions
66+instance ToSchema Shade where declareNamedSchema = pure . paramSchemaToNamedSchema defaultSchemaOptions
68− shadeSchemaJSON :: Value
68+shadeSchemaJSON :: Value
69− shadeSchemaJSON = [aesonQQ|
69+shadeSchemaJSON = [aesonQQ|
71− "type": "string",
71+ "type": "string",
72− "enum": ["Dim", "Bright"]
72+ "enum": ["Dim", "Bright"]
76− -- ========================================================================
76+-- ========================================================================
77− -- Paint (record with bounded enum property)
77+-- Paint (record with bounded enum property)
78− -- ========================================================================
78+-- ========================================================================
80− newtype Paint = Paint { color :: Color }
80+newtype Paint = Paint { color :: Color }
81− deriving (Generic)
81+ deriving (Generic)
82− instance ToSchema Paint
82+instance ToSchema Paint
84− paintSchemaJSON :: Value
84+paintSchemaJSON :: Value
85− paintSchemaJSON = [aesonQQ|
85+paintSchemaJSON = [aesonQQ|
87− "type": "object",
87+ "type": "object",
88− "properties":
88+ "properties":
92− "$ref": "#/definitions/Color"
92+ "$ref": "#/definitions/Color"
95− "required": ["color"]
95+ "required": ["color"]
99− paintInlinedSchemaJSON :: Value
99+paintInlinedSchemaJSON :: Value
100− paintInlinedSchemaJSON = [aesonQQ|
100+paintInlinedSchemaJSON = [aesonQQ|
102− "type": "object",
102+ "type": "object",
103− "properties":
103+ "properties":
105− "color":
105+ "color":
107− "type": "string",
107+ "type": "string",
108− "enum": ["Red", "Green", "Blue"]
108+ "enum": ["Red", "Green", "Blue"]
111− "required": ["color"]
111+ "required": ["color"]
115− -- ========================================================================
115+-- ========================================================================
116− -- Status (constructorTagModifier)
116+-- Status (constructorTagModifier)
117− -- ========================================================================
117+-- ========================================================================
119− data Status
119+data Status
120− = StatusOk
120+ = StatusOk
121− | StatusError
121+ | StatusError
122− deriving (Generic)
122+ deriving (Generic)
124− instance ToParamSchema Status where
124+instance ToParamSchema Status where
125− toParamSchema = genericToParamSchema defaultSchemaOptions
125+ toParamSchema = genericToParamSchema defaultSchemaOptions
126− { constructorTagModifier = map toLower . drop (length "Status") }
126+ { constructorTagModifier = map toLower . drop (length "Status") }
127− instance ToSchema Status where
127+instance ToSchema Status where
128− declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
128+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
129− { constructorTagModifier = map toLower . drop (length "Status") }
129+ { constructorTagModifier = map toLower . drop (length "Status") }
131− statusSchemaJSON :: Value
131+statusSchemaJSON :: Value
132− statusSchemaJSON = [aesonQQ|
132+statusSchemaJSON = [aesonQQ|
134− "type": "string",
134+ "type": "string",
135− "enum": ["ok", "error"]
135+ "enum": ["ok", "error"]
139− -- ========================================================================
139+-- ========================================================================
140− -- Email (newtype with unwrapUnaryRecords set to True)
140+-- Email (newtype with unwrapUnaryRecords set to True)
141− -- ========================================================================
141+-- ========================================================================
143− newtype Email = Email { getEmail :: String }
143+newtype Email = Email { getEmail :: String }
144− deriving (Generic)
144+ deriving (Generic)
145− instance ToParamSchema Email
145+instance ToParamSchema Email
146− instance ToSchema Email where
146+instance ToSchema Email where
147− declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
147+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
148− { unwrapUnaryRecords = True }
148+ { unwrapUnaryRecords = True }
150− emailSchemaJSON :: Value
150+emailSchemaJSON :: Value
151− emailSchemaJSON = [aesonQQ|
151+emailSchemaJSON = [aesonQQ|
153− "type": "string"
153+ "type": "string"
157− -- ========================================================================
157+-- ========================================================================
158− -- UserId (non-record newtype)
158+-- UserId (non-record newtype)
159− -- ========================================================================
159+-- ========================================================================
161− newtype UserId = UserId Integer
161+newtype UserId = UserId Integer
162− deriving (Eq, Ord, Generic)
162+ deriving (Eq, Ord, Generic)
163− instance ToParamSchema UserId
163+instance ToParamSchema UserId
164− instance ToSchema UserId
164+instance ToSchema UserId
166− userIdSchemaJSON :: Value
166+userIdSchemaJSON :: Value
167− userIdSchemaJSON = [aesonQQ|
167+userIdSchemaJSON = [aesonQQ|
169− "type": "integer"
169+ "type": "integer"
173− -- ========================================================================
173+-- ========================================================================
174− -- UserGroup (set newtype)
174+-- UserGroup (set newtype)
175− -- ========================================================================
175+-- ========================================================================
177− newtype UserGroup = UserGroup (Set UserId)
177+newtype UserGroup = UserGroup (Set UserId)
178− deriving (Generic)
178+ deriving (Generic)
179− instance ToSchema UserGroup
179+instance ToSchema UserGroup
181− userGroupSchemaJSON :: Value
181+userGroupSchemaJSON :: Value
182− userGroupSchemaJSON = [aesonQQ|
182+userGroupSchemaJSON = [aesonQQ|
184− "type": "array",
184+ "type": "array",
185− "items": { "$ref": "#/definitions/UserId" },
185+ "items": { "$ref": "#/definitions/UserId" },
186− "uniqueItems": true
186+ "uniqueItems": true
190− -- ========================================================================
190+-- ========================================================================
191− -- Person (simple record with optional fields)
191+-- Person (simple record with optional fields)
192− -- ========================================================================
192+-- ========================================================================
193− data Person = Person
193+data Person = Person
194− { name :: String
194+ { name :: String
195− , phone :: Integer
195+ , phone :: Integer
196− , email :: Maybe String
196+ , email :: Maybe String
197− } deriving (Generic)
197+ } deriving (Generic)
199− instance ToSchema Person
199+instance ToSchema Person
201− personSchemaJSON :: Value
201+personSchemaJSON :: Value
202− personSchemaJSON = [aesonQQ|
202+personSchemaJSON = [aesonQQ|
204− "type": "object",
204+ "type": "object",
205− "properties":
205+ "properties":
207− "name": { "type": "string" },
207+ "name": { "type": "string" },
208− "phone": { "type": "integer" },
208+ "phone": { "type": "integer" },
209− "email": { "type": "string" }
209+ "email": { "type": "string" }
211− "required": ["name", "phone"]
211+ "required": ["name", "phone"]
215− -- ========================================================================
215+-- ========================================================================
216− -- Player (record newtype)
216+-- Player (record newtype)
217− -- ========================================================================
217+-- ========================================================================
219− newtype Player = Player
219+newtype Player = Player
220− { position :: Point
220+ { position :: Point
221− } deriving (Generic)
221+ } deriving (Generic)
222− instance ToSchema Player
222+instance ToSchema Player
224− playerSchemaJSON :: Value
224+playerSchemaJSON :: Value
225− playerSchemaJSON = [aesonQQ|
225+playerSchemaJSON = [aesonQQ|
227− "type": "object",
227+ "type": "object",
228− "properties":
228+ "properties":
230− "position":
230+ "position":
232− "$ref": "#/definitions/Point"
232+ "$ref": "#/definitions/Point"
235− "required": ["position"]
235+ "required": ["position"]
239− newtype Players = Players [Inlined Player]
239+newtype Players = Players [Inlined Player]
240− deriving (Generic)
240+ deriving (Generic)
241− instance ToSchema Players
241+instance ToSchema Players
243− playersSchemaJSON :: Value
243+playersSchemaJSON :: Value
244− playersSchemaJSON = [aesonQQ|
244+playersSchemaJSON = [aesonQQ|
246− "type": "array",
246+ "type": "array",
247− "items":
247+ "items":
249− "type": "object",
249+ "type": "object",
250− "properties":
250+ "properties":
252− "position":
252+ "position":
254− "$ref": "#/definitions/Point"
254+ "$ref": "#/definitions/Point"
257− "required": ["position"]
257+ "required": ["position"]
262− -- ========================================================================
262+-- ========================================================================
263− -- Character (sum type with ref and record in alternative)
263+-- Character (sum type with ref and record in alternative)
264− -- ========================================================================
264+-- ========================================================================
266− data Character
266+data Character
267− = PC Player
267+ = PC Player
268− | NPC { npcName :: String, npcPosition :: Point }
268+ | NPC { npcName :: String, npcPosition :: Point }
269− deriving (Generic)
269+ deriving (Generic)
270− instance ToSchema Character
270+instance ToSchema Character
272− characterSchemaJSON :: Value
272+characterSchemaJSON :: Value
273− characterSchemaJSON = [aesonQQ|
273+characterSchemaJSON = [aesonQQ|
275− "type": "object",
275+ "type": "object",
276− "properties":
276+ "properties":
278− "PC": { "$ref": "#/definitions/Player" },
278+ "PC": { "$ref": "#/definitions/Player" },
281− "type": "object",
281+ "type": "object",
282− "properties":
282+ "properties":
284− "npcName": { "type": "string" },
284+ "npcName": { "type": "string" },
285− "npcPosition": { "$ref": "#/definitions/Point" }
285+ "npcPosition": { "$ref": "#/definitions/Point" }
287− "required": ["npcName", "npcPosition"]
287+ "required": ["npcName", "npcPosition"]
290− "maxProperties": 1,
290+ "maxProperties": 1,
291− "minProperties": 1
291+ "minProperties": 1
295− characterInlinedSchemaJSON :: Value
295+characterInlinedSchemaJSON :: Value
296− characterInlinedSchemaJSON = [aesonQQ|
296+characterInlinedSchemaJSON = [aesonQQ|
298− "type": "object",
298+ "type": "object",
299− "properties":
299+ "properties":
303− "type": "object",
303+ "type": "object",
304− "properties":
304+ "properties":
306− "position":
306+ "position":
308− "type": "object",
308+ "type": "object",
309− "properties":
309+ "properties":
311− "x": { "type": "number", "format": "double" },
311+ "x": { "type": "number", "format": "double" },
312− "y": { "type": "number", "format": "double" }
312+ "y": { "type": "number", "format": "double" }
314− "required": ["x", "y"]
314+ "required": ["x", "y"]
317− "required": ["position"]
317+ "required": ["position"]
321− "type": "object",
321+ "type": "object",
322− "properties":
322+ "properties":
324− "npcName": { "type": "string" },
324+ "npcName": { "type": "string" },
325− "npcPosition":
325+ "npcPosition":
327− "type": "object",
327+ "type": "object",
328− "properties":
328+ "properties":
330− "x": { "type": "number", "format": "double" },
330+ "x": { "type": "number", "format": "double" },
331− "y": { "type": "number", "format": "double" }
331+ "y": { "type": "number", "format": "double" }
333− "required": ["x", "y"]
333+ "required": ["x", "y"]
336− "required": ["npcName", "npcPosition"]
336+ "required": ["npcName", "npcPosition"]
339− "maxProperties": 1,
339+ "maxProperties": 1,
340− "minProperties": 1
340+ "minProperties": 1
344− characterInlinedPlayerSchemaJSON :: Value
344+characterInlinedPlayerSchemaJSON :: Value
345− characterInlinedPlayerSchemaJSON = [aesonQQ|
345+characterInlinedPlayerSchemaJSON = [aesonQQ|
347− "type": "object",
347+ "type": "object",
348− "properties":
348+ "properties":
352− "type": "object",
352+ "type": "object",
353− "properties":
353+ "properties":
355− "position":
355+ "position":
357− "$ref": "#/definitions/Point"
357+ "$ref": "#/definitions/Point"
360− "required": ["position"]
360+ "required": ["position"]
364− "type": "object",
364+ "type": "object",
365− "properties":
365+ "properties":
367− "npcName": { "type": "string" },
367+ "npcName": { "type": "string" },
368− "npcPosition": { "$ref": "#/definitions/Point" }
368+ "npcPosition": { "$ref": "#/definitions/Point" }
370− "required": ["npcName", "npcPosition"]
370+ "required": ["npcName", "npcPosition"]
373− "maxProperties": 1,
373+ "maxProperties": 1,
374− "minProperties": 1
374+ "minProperties": 1
378− -- ========================================================================
378+-- ========================================================================
379− -- ISPair (non-record product data type)
379+-- ISPair (non-record product data type)
380− -- ========================================================================
380+-- ========================================================================
381− data ISPair = ISPair Integer String
381+data ISPair = ISPair Integer String
382− deriving (Generic)
382+ deriving (Generic)
384− instance ToSchema ISPair
384+instance ToSchema ISPair
386− ispairSchemaJSON :: Value
386+ispairSchemaJSON :: Value
387− ispairSchemaJSON = [aesonQQ|
387+ispairSchemaJSON = [aesonQQ|
389− "type": "array",
389+ "type": "array",
390− "items":
390+ "items":
392− { "type": "integer" },
392+ { "type": "integer" },
393− { "type": "string" }
393+ { "type": "string" }
395− "minItems": 2,
395+ "minItems": 2,
396− "maxItems": 2
396+ "maxItems": 2
400− -- ========================================================================
400+-- ========================================================================
401− -- Point (record data type with custom fieldLabelModifier)
401+-- Point (record data type with custom fieldLabelModifier)
402− -- ========================================================================
402+-- ========================================================================
404− data Point = Point
404+data Point = Point
405− { pointX :: Double
405+ { pointX :: Double
406− , pointY :: Double
406+ , pointY :: Double
407− } deriving (Generic)
407+ } deriving (Generic)
409− instance ToSchema Point where
409+instance ToSchema Point where
410− declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
410+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
411− { fieldLabelModifier = map toLower . drop (length "point") }
411+ { fieldLabelModifier = map toLower . drop (length "point") }
413− pointSchemaJSON :: Value
413+pointSchemaJSON :: Value
414− pointSchemaJSON = [aesonQQ|
414+pointSchemaJSON = [aesonQQ|
416− "type": "object",
416+ "type": "object",
417− "properties":
417+ "properties":
419− "x": { "type": "number", "format": "double" },
419+ "x": { "type": "number", "format": "double" },
420− "y": { "type": "number", "format": "double" }
420+ "y": { "type": "number", "format": "double" }
422− "required": ["x", "y"]
422+ "required": ["x", "y"]
426− -- ========================================================================
426+-- ========================================================================
427− -- Point (record data type with multiple fields)
427+-- Point (record data type with multiple fields)
428− -- ========================================================================
428+-- ========================================================================
430− data Point5 = Point5
430+data Point5 = Point5
431− { point5X :: Double
431+ { point5X :: Double
432− , point5Y :: Double
432+ , point5Y :: Double
433− , point5Z :: Double
433+ , point5Z :: Double
434− , point5U :: Double
434+ , point5U :: Double
435− , point5V :: Double -- 5 dimensional!
435+ , point5V :: Double -- 5 dimensional!
436− } deriving (Generic)
436+ } deriving (Generic)
438− instance ToSchema Point5 where
438+instance ToSchema Point5 where
439− declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
439+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
440− { fieldLabelModifier = map toLower . drop (length "point5") }
440+ { fieldLabelModifier = map toLower . drop (length "point5") }
442− point5SchemaJSON :: Value
442+point5SchemaJSON :: Value
443− point5SchemaJSON = [aesonQQ|
443+point5SchemaJSON = [aesonQQ|
445− "type": "object",
445+ "type": "object",
446− "properties":
446+ "properties":
448− "x": { "type": "number", "format": "double" },
448+ "x": { "type": "number", "format": "double" },
449− "y": { "type": "number", "format": "double" },
449+ "y": { "type": "number", "format": "double" },
450− "z": { "type": "number", "format": "double" },
450+ "z": { "type": "number", "format": "double" },
451− "u": { "type": "number", "format": "double" },
451+ "u": { "type": "number", "format": "double" },
452− "v": { "type": "number", "format": "double" }
452+ "v": { "type": "number", "format": "double" }
454− "required": ["x", "y", "z", "u", "v"]
454+ "required": ["x", "y", "z", "u", "v"]
458− point5Properties :: [String]
458+point5Properties :: [String]
459− point5Properties = ["x", "y", "z", "u", "v"]
459+point5Properties = ["x", "y", "z", "u", "v"]
461− -- ========================================================================
461+-- ========================================================================
462− -- MyRoseTree (custom datatypeNameModifier)
462+-- MyRoseTree (custom datatypeNameModifier)
463− -- ========================================================================
463+-- ========================================================================
465− data MyRoseTree = MyRoseTree
465+data MyRoseTree = MyRoseTree
466− { root :: String
466+ { root :: String
467− , trees :: [MyRoseTree]
467+ , trees :: [MyRoseTree]
468− } deriving (Generic)
468+ } deriving (Generic)
470− instance ToSchema MyRoseTree where
470+instance ToSchema MyRoseTree where
471− declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
471+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
472− { datatypeNameModifier = drop (length "My") }
472+ { datatypeNameModifier = drop (length "My") }
474− myRoseTreeSchemaJSON :: Value
474+myRoseTreeSchemaJSON :: Value
475− myRoseTreeSchemaJSON = [aesonQQ|
475+myRoseTreeSchemaJSON = [aesonQQ|
477− "type": "object",
477+ "type": "object",
478− "properties":
478+ "properties":
480− "root": { "type": "string" },
480+ "root": { "type": "string" },
481− "trees":
481+ "trees":
483− "type": "array",
483+ "type": "array",
484− "items":
484+ "items":
486− "$ref": "#/definitions/RoseTree"
486+ "$ref": "#/definitions/RoseTree"
490− "required": ["root", "trees"]
490+ "required": ["root", "trees"]
494− data MyRoseTree' = MyRoseTree'
494+data MyRoseTree' = MyRoseTree'
495− { root' :: String
495+ { root' :: String
496− , trees' :: [MyRoseTree']
496+ , trees' :: [MyRoseTree']
497− } deriving (Generic)
497+ } deriving (Generic)
499− instance ToSchema MyRoseTree' where
499+instance ToSchema MyRoseTree' where
500− declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
500+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
501− { datatypeNameModifier = map toLower }
501+ { datatypeNameModifier = map toLower }
503− myRoseTreeSchemaJSON' :: Value
503+myRoseTreeSchemaJSON' :: Value
504− myRoseTreeSchemaJSON' = [aesonQQ|
504+myRoseTreeSchemaJSON' = [aesonQQ|
506− "type": "object",
506+ "type": "object",
507− "properties":
507+ "properties":
509− "root'": { "type": "string" },
509+ "root'": { "type": "string" },
510− "trees'":
510+ "trees'":
512− "type": "array",
512+ "type": "array",
513− "items":
513+ "items":
515− "$ref": "#/definitions/myrosetree'"
515+ "$ref": "#/definitions/myrosetree'"
519− "required": ["root'", "trees'"]
519+ "required": ["root'", "trees'"]
523− -- ========================================================================
523+-- ========================================================================
524− -- Inlined (newtype for inlining schemas)
524+-- Inlined (newtype for inlining schemas)
525− -- ========================================================================
525+-- ========================================================================
527− newtype Inlined a = Inlined { getInlined :: a }
527+newtype Inlined a = Inlined { getInlined :: a }
529− instance ToSchema a => ToSchema (Inlined a) where
529+instance ToSchema a => ToSchema (Inlined a) where
530− declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
530+ declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
532− unname (NamedSchema _ s) = NamedSchema Nothing s
532+ unname (NamedSchema _ s) = NamedSchema Nothing s
534− -- ========================================================================
534+-- ========================================================================
535− -- Light (sum type with unwrapUnaryRecords)
535+-- Light (sum type with unwrapUnaryRecords)
536− -- ========================================================================
536+-- ========================================================================
538− data Light
538+data Light
539− = NoLight
539+ = NoLight
540− | LightFreq Double
540+ | LightFreq Double
541− | LightColor Color
541+ | LightColor Color
542− | LightWaveLength { waveLength :: Double }
542+ | LightWaveLength { waveLength :: Double }
543− deriving (Generic)
543+ deriving (Generic)
545− instance ToSchema Light where
545+instance ToSchema Light where
546− declareNamedSchema = genericDeclareNamedSchemaUnrestricted defaultSchemaOptions
546+ declareNamedSchema = genericDeclareNamedSchemaUnrestricted defaultSchemaOptions
547− { unwrapUnaryRecords = True }
547+ { unwrapUnaryRecords = True }
549− lightSchemaJSON :: Value
549+lightSchemaJSON :: Value
550− lightSchemaJSON = [aesonQQ|
550+lightSchemaJSON = [aesonQQ|
552− "type": "object",
552+ "type": "object",
553− "properties":
553+ "properties":
555− "NoLight": { "type": "array", "items": [] },
555+ "NoLight": { "type": "array", "items": [] },
556− "LightFreq": { "type": "number", "format": "double" },
556+ "LightFreq": { "type": "number", "format": "double" },
557− "LightColor": { "$ref": "#/definitions/Color" },
557+ "LightColor": { "$ref": "#/definitions/Color" },
558− "LightWaveLength": { "type": "number", "format": "double" }
558+ "LightWaveLength": { "type": "number", "format": "double" }
560− "maxProperties": 1,
560+ "maxProperties": 1,
561− "minProperties": 1
561+ "minProperties": 1
565− lightInlinedSchemaJSON :: Value
565+lightInlinedSchemaJSON :: Value
566− lightInlinedSchemaJSON = [aesonQQ|
566+lightInlinedSchemaJSON = [aesonQQ|
568− "type": "object",
568+ "type": "object",
569− "properties":
569+ "properties":
571− "NoLight": { "type": "array", "items": [] },
571+ "NoLight": { "type": "array", "items": [] },
572− "LightFreq": { "type": "number", "format": "double" },
572+ "LightFreq": { "type": "number", "format": "double" },
573− "LightColor":
573+ "LightColor":
575− "type": "string",
575+ "type": "string",
576− "enum": ["Red", "Green", "Blue"]
576+ "enum": ["Red", "Green", "Blue"]
578− "LightWaveLength": { "type": "number", "format": "double" }
578+ "LightWaveLength": { "type": "number", "format": "double" }
580− "maxProperties": 1,
580+ "maxProperties": 1,
581− "minProperties": 1
581+ "minProperties": 1
585− -- ========================================================================
585+-- ========================================================================
586− -- ResourceId (series of newtypes)
586+-- ResourceId (series of newtypes)
587− -- ========================================================================
587+-- ========================================================================
589− newtype Id = Id String deriving (Generic)
589+newtype Id = Id String deriving (Generic)
590− instance ToSchema Id
590+instance ToSchema Id
592− newtype ResourceId = ResourceId Id deriving (Generic)
592+newtype ResourceId = ResourceId Id deriving (Generic)
593− instance ToSchema ResourceId
593+instance ToSchema ResourceId
595− -- ========================================================================
595+-- ========================================================================
596− -- ButtonImages (bounded enum key mapping)
596+-- ButtonImages (bounded enum key mapping)
597− -- ========================================================================
597+-- ========================================================================
599− data ButtonState = Neutral | Focus | Active | Hover | Disabled
599+data ButtonState = Neutral | Focus | Active | Hover | Disabled
600− deriving (Show, Bounded, Enum, Generic)
600+ deriving (Show, Bounded, Enum, Generic)
602− instance ToJSON ButtonState
602+instance ToJSON ButtonState
603− instance ToSchema ButtonState
603+instance ToSchema ButtonState
604− instance ToJSONKey ButtonState where toJSONKey = toJSONKeyText (Text.pack . show)
604+instance ToJSONKey ButtonState where toJSONKey = toJSONKeyText (Text.pack . show)
606− type ImageUrl = Text.Text
606+type ImageUrl = Text.Text
608− newtype ButtonImages = ButtonImages { getButtonImages :: Map ButtonState ImageUrl }
608+newtype ButtonImages = ButtonImages { getButtonImages :: Map ButtonState ImageUrl }
609− deriving (Generic)
609+ deriving (Generic)
611− instance ToJSON ButtonImages where
611+instance ToJSON ButtonImages where
612− toJSON = toJSON . getButtonImages
612+ toJSON = toJSON . getButtonImages
614− instance ToSchema ButtonImages where
614+instance ToSchema ButtonImages where
615− declareNamedSchema = genericDeclareNamedSchemaNewtype defaultSchemaOptions
615+ declareNamedSchema = genericDeclareNamedSchemaNewtype defaultSchemaOptions
616− declareSchemaBoundedEnumKeyMapping
616+ declareSchemaBoundedEnumKeyMapping
618− buttonImagesSchemaJSON :: Value
618+buttonImagesSchemaJSON :: Value
619− buttonImagesSchemaJSON = [aesonQQ|
619+buttonImagesSchemaJSON = [aesonQQ|
621− "type": "object",
621+ "type": "object",
622− "properties":
622+ "properties":
624− "Neutral": { "type": "string" },
624+ "Neutral": { "type": "string" },
625− "Focus": { "type": "string" },
625+ "Focus": { "type": "string" },
626− "Active": { "type": "string" },
626+ "Active": { "type": "string" },
627− "Hover": { "type": "string" },
627+ "Hover": { "type": "string" },
628− "Disabled": { "type": "string" }
628+ "Disabled": { "type": "string" }
633− -- ========================================================================
633+-- ========================================================================
634− -- SingleMaybeField (single field data with optional field)
634+-- SingleMaybeField (single field data with optional field)
635− -- ========================================================================
635+-- ========================================================================
637− data SingleMaybeField = SingleMaybeField { singleMaybeField :: Maybe String }
637+data SingleMaybeField = SingleMaybeField { singleMaybeField :: Maybe String }
638− deriving (Show, Generic)
638+ deriving (Show, Generic)
640− instance ToJSON SingleMaybeField
640+instance ToJSON SingleMaybeField
641− instance ToSchema SingleMaybeField
641+instance ToSchema SingleMaybeField
643− singleMaybeFieldSchemaJSON :: Value
643+singleMaybeFieldSchemaJSON :: Value
644− singleMaybeFieldSchemaJSON = [aesonQQ|
644+singleMaybeFieldSchemaJSON = [aesonQQ|
646− "type": "object",
646+ "type": "object",
647− "properties":
647+ "properties":
649− "singleMaybeField": { "type": "string" }
649+ "singleMaybeField": { "type": "string" }