git.iko.soy/typeable/swagger2
on master help sign in
Move items to SchemaCommon
352f68cNickolay Kudasov
src/Data/Swagger/Internal.hs+10−22
@@ -289,15 +289,11 @@ data ParamOtherSchema = ParamOtherSchema
289 -- Default value is @False@.
289 -- Default value is @False@.
290 , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
290 , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
291
291
292− -- | __Required if type is @'ParamArray'@__.
293− -- Describes the type of items in the array.
294− , _paramOtherSchemaItems :: Maybe Items
295−
296 -- | Determines the format of the array if @'ParamArray'@ is used.
292 -- | Determines the format of the array if @'ParamArray'@ is used.
297 -- Default value is csv.
293 -- Default value is csv.
298 , _paramOtherSchemaCollectionFormat :: Maybe CollectionFormat
294 , _paramOtherSchemaCollectionFormat :: Maybe CollectionFormat
299
295
300− , _paramOtherSchemaCommon :: SchemaCommon ParamType
296+ , _paramOtherSchemaCommon :: SchemaCommon ParamType Items
301 } deriving (Eq, Show, Generic)
297 } deriving (Eq, Show, Generic)
302
298
303data ParamType
299data ParamType
@@ -375,7 +371,6 @@ data Schema = Schema
375 , _schemaDescription :: Maybe Text
371 , _schemaDescription :: Maybe Text
376 , _schemaRequired :: [ParamName]
372 , _schemaRequired :: [ParamName]
377
373
378− , _schemaItems :: Maybe SchemaItems
379 , _schemaAllOf :: Maybe [Schema]
374 , _schemaAllOf :: Maybe [Schema]
380 , _schemaProperties :: HashMap Text (Referenced Schema)
375 , _schemaProperties :: HashMap Text (Referenced Schema)
381 , _schemaAdditionalProperties :: Maybe Schema
376 , _schemaAdditionalProperties :: Maybe Schema
@@ -389,7 +384,7 @@ data Schema = Schema
389 , _schemaMaxProperties :: Maybe Integer
384 , _schemaMaxProperties :: Maybe Integer
390 , _schemaMinProperties :: Maybe Integer
385 , _schemaMinProperties :: Maybe Integer
391
386
392− , _schemaSchemaCommon :: SchemaCommon SchemaType
387+ , _schemaSchemaCommon :: SchemaCommon SchemaType SchemaItems
393 } deriving (Eq, Show, Generic)
388 } deriving (Eq, Show, Generic)
394
389
395data SchemaItems
390data SchemaItems
@@ -397,7 +392,7 @@ data SchemaItems
397 | SchemaItemsArray [Referenced Schema]
392 | SchemaItemsArray [Referenced Schema]
398 deriving (Eq, Show)
393 deriving (Eq, Show)
399
394
400−data SchemaCommon typeDomain = SchemaCommon
395+data SchemaCommon typeDomain items = SchemaCommon
401 { -- | Declares the value of the parameter that the server will use if none is provided,
396 { -- | Declares the value of the parameter that the server will use if none is provided,
402 -- for example a @"count"@ to control the number of results per page might default to @100@
397 -- for example a @"count"@ to control the number of results per page might default to @100@
403 -- if not supplied by the client in the request.
398 -- if not supplied by the client in the request.
@@ -407,6 +402,7 @@ data SchemaCommon typeDomain = SchemaCommon
407
402
408 , _schemaCommonType :: typeDomain
403 , _schemaCommonType :: typeDomain
409 , _schemaCommonFormat :: Maybe Format
404 , _schemaCommonFormat :: Maybe Format
405+ , _schemaCommonItems :: Maybe items
410 , _schemaCommonMaximum :: Maybe Scientific
406 , _schemaCommonMaximum :: Maybe Scientific
411 , _schemaCommonExclusiveMaximum :: Maybe Bool
407 , _schemaCommonExclusiveMaximum :: Maybe Bool
412 , _schemaCommonMinimum :: Maybe Scientific
408 , _schemaCommonMinimum :: Maybe Scientific
@@ -450,15 +446,11 @@ data Xml = Xml
450 } deriving (Eq, Show, Generic)
446 } deriving (Eq, Show, Generic)
451
447
452data Items = Items
448data Items = Items
453− { -- | __Required if type is @'ItemsArray'@.__
454− -- Describes the type of items in the array.
455− _itemsItems :: Maybe Items
456−
457− -- | Determines the format of the array if type array is used.
449+ { -- | Determines the format of the array if type array is used.
458 -- Default value is @'ItemsCollectionCSV'@.
450 -- Default value is @'ItemsCollectionCSV'@.
459− , _itemsCollectionFormat :: Maybe ItemsCollectionFormat
451+ _itemsCollectionFormat :: Maybe ItemsCollectionFormat
460
452
461− , _itemsCommon :: SchemaCommon ItemsType
453+ , _itemsCommon :: SchemaCommon ItemsType Items
462 } deriving (Eq, Show, Generic)
454 } deriving (Eq, Show, Generic)
463
455
464-- | A container for the expected responses of an operation.
456-- | A container for the expected responses of an operation.
@@ -504,15 +496,11 @@ data Header = Header
504 { -- | A short description of the header.
496 { -- | A short description of the header.
505 _headerDescription :: Maybe Text
497 _headerDescription :: Maybe Text
506
498
507− -- | __Required if type is @'ItemsArray'@__.
508− -- Describes the type of items in the array.
509− , _headerItems :: Maybe Items
510−
511 -- | Determines the format of the array if type array is used.
499 -- | Determines the format of the array if type array is used.
512 -- Default value is @'ItemsCollectionCSV'@.
500 -- Default value is @'ItemsCollectionCSV'@.
513 , _headerCollectionFormat :: Maybe ItemsCollectionFormat
501 , _headerCollectionFormat :: Maybe ItemsCollectionFormat
514
502
515− , _headerCommon :: SchemaCommon ItemsType
503+ , _headerCommon :: SchemaCommon ItemsType Items
516 } deriving (Eq, Show, Generic)
504 } deriving (Eq, Show, Generic)
517
505
518data Example = Example { getExample :: Map MediaType Value }
506data Example = Example { getExample :: Map MediaType Value }
@@ -634,7 +622,7 @@ instance Monoid Schema where
634 mempty = genericMempty
622 mempty = genericMempty
635 mappend = genericMappend
623 mappend = genericMappend
636
624
637−instance SwaggerMonoid t => Monoid (SchemaCommon t) where
625+instance SwaggerMonoid t => Monoid (SchemaCommon t i) where
638 mempty = genericMempty
626 mempty = genericMempty
639 mappend = genericMappend
627 mappend = genericMappend
640
628
@@ -670,7 +658,7 @@ instance SwaggerMonoid Info
670instance SwaggerMonoid Paths
658instance SwaggerMonoid Paths
671instance SwaggerMonoid PathItem
659instance SwaggerMonoid PathItem
672instance SwaggerMonoid Schema
660instance SwaggerMonoid Schema
673−instance SwaggerMonoid t => SwaggerMonoid (SchemaCommon t)
661+instance SwaggerMonoid t => SwaggerMonoid (SchemaCommon t i)
674instance SwaggerMonoid Param
662instance SwaggerMonoid Param
675instance SwaggerMonoid ParamOtherSchema
663instance SwaggerMonoid ParamOtherSchema
676instance SwaggerMonoid Responses
664instance SwaggerMonoid Responses
src/Data/Swagger/Lens.hs+25−22
@@ -57,57 +57,60 @@ instance HasDescription Schema (Maybe Text) where description = schemaDe
57instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
57instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
58instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
58instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
59
59
60−class HasSchemaCommon s t | s -> t where
60+class HasSchemaCommon s t i | s -> t i where
61− schemaCommon :: Lens' s (SchemaCommon t)
61+ schemaCommon :: Lens' s (SchemaCommon t i)
62
62
63−instance HasSchemaCommon Schema SchemaType where schemaCommon = schemaSchemaCommon
63+instance HasSchemaCommon Schema SchemaType SchemaItems where schemaCommon = schemaSchemaCommon
64−instance HasSchemaCommon ParamOtherSchema ParamType where schemaCommon = paramOtherSchemaCommon
64+instance HasSchemaCommon ParamOtherSchema ParamType Items where schemaCommon = paramOtherSchemaCommon
65−instance HasSchemaCommon Items ItemsType where schemaCommon = itemsCommon
65+instance HasSchemaCommon Items ItemsType Items where schemaCommon = itemsCommon
66−instance HasSchemaCommon Header ItemsType where schemaCommon = headerCommon
66+instance HasSchemaCommon Header ItemsType Items where schemaCommon = headerCommon
67−instance HasSchemaCommon (SchemaCommon t) t where schemaCommon = id
67+instance HasSchemaCommon (SchemaCommon t i) t i where schemaCommon = id
68
68
69−schemaType :: HasSchemaCommon s t => Lens' s t
69+schemaType :: HasSchemaCommon s t i => Lens' s t
70schemaType = schemaCommon.schemaCommonType
70schemaType = schemaCommon.schemaCommonType
71
71
72−schemaFormat :: HasSchemaCommon s t => Lens' s (Maybe Format)
72+schemaFormat :: HasSchemaCommon s t i => Lens' s (Maybe Format)
73schemaFormat = schemaCommon.schemaCommonFormat
73schemaFormat = schemaCommon.schemaCommonFormat
74
74
75+schemaItems :: HasSchemaCommon s t i => Lens' s (Maybe i)
76+schemaItems = schemaCommon.schemaCommonItems
77+
75−schemaDefault :: HasSchemaCommon s t => Lens' s (Maybe Value)
78+schemaDefault :: HasSchemaCommon s t i => Lens' s (Maybe Value)
76schemaDefault = schemaCommon.schemaCommonDefault
79schemaDefault = schemaCommon.schemaCommonDefault
77
80
78−schemaMaximum :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
81+schemaMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
79schemaMaximum = schemaCommon.schemaCommonMaximum
82schemaMaximum = schemaCommon.schemaCommonMaximum
80
83
81−schemaExclusiveMaximum :: HasSchemaCommon s t => Lens' s (Maybe Bool)
84+schemaExclusiveMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
82schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
85schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
83
86
84−schemaMinimum :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
87+schemaMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
85schemaMinimum = schemaCommon.schemaCommonMinimum
88schemaMinimum = schemaCommon.schemaCommonMinimum
86
89
87−schemaExclusiveMinimum :: HasSchemaCommon s t => Lens' s (Maybe Bool)
90+schemaExclusiveMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
88schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
91schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
89
92
90−schemaMaxLength :: HasSchemaCommon s t => Lens' s (Maybe Integer)
93+schemaMaxLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
91schemaMaxLength = schemaCommon.schemaCommonMaxLength
94schemaMaxLength = schemaCommon.schemaCommonMaxLength
92
95
93−schemaMinLength :: HasSchemaCommon s t => Lens' s (Maybe Integer)
96+schemaMinLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
94schemaMinLength = schemaCommon.schemaCommonMinLength
97schemaMinLength = schemaCommon.schemaCommonMinLength
95
98
96−schemaPattern :: HasSchemaCommon s t => Lens' s (Maybe Text)
99+schemaPattern :: HasSchemaCommon s t i => Lens' s (Maybe Text)
97schemaPattern = schemaCommon.schemaCommonPattern
100schemaPattern = schemaCommon.schemaCommonPattern
98
101
99−schemaMaxItems :: HasSchemaCommon s t => Lens' s (Maybe Integer)
102+schemaMaxItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
100schemaMaxItems = schemaCommon.schemaCommonMaxItems
103schemaMaxItems = schemaCommon.schemaCommonMaxItems
101
104
102−schemaMinItems :: HasSchemaCommon s t => Lens' s (Maybe Integer)
105+schemaMinItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
103schemaMinItems = schemaCommon.schemaCommonMinItems
106schemaMinItems = schemaCommon.schemaCommonMinItems
104
107
105−schemaUniqueItems :: HasSchemaCommon s t => Lens' s (Maybe Bool)
108+schemaUniqueItems :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
106schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
109schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
107
110
108−schemaEnum :: HasSchemaCommon s t => Lens' s (Maybe [Value])
111+schemaEnum :: HasSchemaCommon s t i => Lens' s (Maybe [Value])
109schemaEnum = schemaCommon.schemaCommonEnum
112schemaEnum = schemaCommon.schemaCommonEnum
110
113
111−schemaMultipleOf :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
114+schemaMultipleOf :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
112schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
115schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
113
116