git.iko.soy/typeable/swagger2
on master help sign in
Move items to SchemaCommon
commit352f68c67d7fa4cc2174b86ce5e9b07d8e7854e3 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateTue 8 Dec 2015, 18:21 (11 years ago) parentbadf3a1
2 files changed+35−44
src/Data/Swagger/Internal.hs+10−22 src/Data/Swagger/Lens.hs+25−22
src/Data/Swagger/Internal.hs+10−22
@@ -289,15 +289,11 @@ data ParamOtherSchema = ParamOtherSchema
289289 -- Default value is @False@.
290290 , _paramOtherSchemaAllowEmptyValue :: Maybe Bool
291291
292− -- | __Required if type is @'ParamArray'@__.
293− -- Describes the type of items in the array.
294− , _paramOtherSchemaItems :: Maybe Items
295−
296292 -- | Determines the format of the array if @'ParamArray'@ is used.
297293 -- Default value is csv.
298294 , _paramOtherSchemaCollectionFormat :: Maybe CollectionFormat
299295
300− , _paramOtherSchemaCommon :: SchemaCommon ParamType
296+ , _paramOtherSchemaCommon :: SchemaCommon ParamType Items
301297 } deriving (Eq, Show, Generic)
302298
303299data ParamType
@@ -375,7 +371,6 @@ data Schema = Schema
375371 , _schemaDescription :: Maybe Text
376372 , _schemaRequired :: [ParamName]
377373
378− , _schemaItems :: Maybe SchemaItems
379374 , _schemaAllOf :: Maybe [Schema]
380375 , _schemaProperties :: HashMap Text (Referenced Schema)
381376 , _schemaAdditionalProperties :: Maybe Schema
@@ -389,7 +384,7 @@ data Schema = Schema
389384 , _schemaMaxProperties :: Maybe Integer
390385 , _schemaMinProperties :: Maybe Integer
391386
392− , _schemaSchemaCommon :: SchemaCommon SchemaType
387+ , _schemaSchemaCommon :: SchemaCommon SchemaType SchemaItems
393388 } deriving (Eq, Show, Generic)
394389
395390data SchemaItems
@@ -397,7 +392,7 @@ data SchemaItems
397392 | SchemaItemsArray [Referenced Schema]
398393 deriving (Eq, Show)
399394
400−data SchemaCommon typeDomain = SchemaCommon
395+data SchemaCommon typeDomain items = SchemaCommon
401396 { -- | Declares the value of the parameter that the server will use if none is provided,
402397 -- for example a @"count"@ to control the number of results per page might default to @100@
403398 -- if not supplied by the client in the request.
@@ -407,6 +402,7 @@ data SchemaCommon typeDomain = SchemaCommon
407402
408403 , _schemaCommonType :: typeDomain
409404 , _schemaCommonFormat :: Maybe Format
405+ , _schemaCommonItems :: Maybe items
410406 , _schemaCommonMaximum :: Maybe Scientific
411407 , _schemaCommonExclusiveMaximum :: Maybe Bool
412408 , _schemaCommonMinimum :: Maybe Scientific
@@ -450,15 +446,11 @@ data Xml = Xml
450446 } deriving (Eq, Show, Generic)
451447
452448data 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.
458450 -- Default value is @'ItemsCollectionCSV'@.
459− , _itemsCollectionFormat :: Maybe ItemsCollectionFormat
451+ _itemsCollectionFormat :: Maybe ItemsCollectionFormat
460452
461− , _itemsCommon :: SchemaCommon ItemsType
453+ , _itemsCommon :: SchemaCommon ItemsType Items
462454 } deriving (Eq, Show, Generic)
463455
464456-- | A container for the expected responses of an operation.
@@ -504,15 +496,11 @@ data Header = Header
504496 { -- | A short description of the header.
505497 _headerDescription :: Maybe Text
506498
507− -- | __Required if type is @'ItemsArray'@__.
508− -- Describes the type of items in the array.
509− , _headerItems :: Maybe Items
510−
511499 -- | Determines the format of the array if type array is used.
512500 -- Default value is @'ItemsCollectionCSV'@.
513501 , _headerCollectionFormat :: Maybe ItemsCollectionFormat
514502
515− , _headerCommon :: SchemaCommon ItemsType
503+ , _headerCommon :: SchemaCommon ItemsType Items
516504 } deriving (Eq, Show, Generic)
517505
518506data Example = Example { getExample :: Map MediaType Value }
@@ -634,7 +622,7 @@ instance Monoid Schema where
634622 mempty = genericMempty
635623 mappend = genericMappend
636624
637−instance SwaggerMonoid t => Monoid (SchemaCommon t) where
625+instance SwaggerMonoid t => Monoid (SchemaCommon t i) where
638626 mempty = genericMempty
639627 mappend = genericMappend
640628
@@ -670,7 +658,7 @@ instance SwaggerMonoid Info
670658instance SwaggerMonoid Paths
671659instance SwaggerMonoid PathItem
672660instance SwaggerMonoid Schema
673−instance SwaggerMonoid t => SwaggerMonoid (SchemaCommon t)
661+instance SwaggerMonoid t => SwaggerMonoid (SchemaCommon t i)
674662instance SwaggerMonoid Param
675663instance SwaggerMonoid ParamOtherSchema
676664instance SwaggerMonoid Responses
src/Data/Swagger/Lens.hs+25−22
@@ -57,57 +57,60 @@ instance HasDescription Schema (Maybe Text) where description = schemaDe
5757instance HasDescription SecurityScheme (Maybe Text) where description = securitySchemeDescription
5858instance HasDescription ExternalDocs (Maybe Text) where description = externalDocsDescription
5959
60−class HasSchemaCommon s t | s -> t where
61− schemaCommon :: Lens' s (SchemaCommon t)
60+class HasSchemaCommon s t i | s -> t i where
61+ schemaCommon :: Lens' s (SchemaCommon t i)
6262
63−instance HasSchemaCommon Schema SchemaType where schemaCommon = schemaSchemaCommon
64−instance HasSchemaCommon ParamOtherSchema ParamType where schemaCommon = paramOtherSchemaCommon
65−instance HasSchemaCommon Items ItemsType where schemaCommon = itemsCommon
66−instance HasSchemaCommon Header ItemsType where schemaCommon = headerCommon
67−instance HasSchemaCommon (SchemaCommon t) t where schemaCommon = id
63+instance HasSchemaCommon Schema SchemaType SchemaItems where schemaCommon = schemaSchemaCommon
64+instance HasSchemaCommon ParamOtherSchema ParamType Items where schemaCommon = paramOtherSchemaCommon
65+instance HasSchemaCommon Items ItemsType Items where schemaCommon = itemsCommon
66+instance HasSchemaCommon Header ItemsType Items where schemaCommon = headerCommon
67+instance HasSchemaCommon (SchemaCommon t i) t i where schemaCommon = id
6868
69−schemaType :: HasSchemaCommon s t => Lens' s t
69+schemaType :: HasSchemaCommon s t i => Lens' s t
7070schemaType = schemaCommon.schemaCommonType
7171
72−schemaFormat :: HasSchemaCommon s t => Lens' s (Maybe Format)
72+schemaFormat :: HasSchemaCommon s t i => Lens' s (Maybe Format)
7373schemaFormat = schemaCommon.schemaCommonFormat
7474
75−schemaDefault :: HasSchemaCommon s t => Lens' s (Maybe Value)
75+schemaItems :: HasSchemaCommon s t i => Lens' s (Maybe i)
76+schemaItems = schemaCommon.schemaCommonItems
77+
78+schemaDefault :: HasSchemaCommon s t i => Lens' s (Maybe Value)
7679schemaDefault = schemaCommon.schemaCommonDefault
7780
78−schemaMaximum :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
81+schemaMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
7982schemaMaximum = schemaCommon.schemaCommonMaximum
8083
81−schemaExclusiveMaximum :: HasSchemaCommon s t => Lens' s (Maybe Bool)
84+schemaExclusiveMaximum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
8285schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
8386
84−schemaMinimum :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
87+schemaMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
8588schemaMinimum = schemaCommon.schemaCommonMinimum
8689
87−schemaExclusiveMinimum :: HasSchemaCommon s t => Lens' s (Maybe Bool)
90+schemaExclusiveMinimum :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
8891schemaExclusiveMinimum = schemaCommon.schemaCommonExclusiveMinimum
8992
90−schemaMaxLength :: HasSchemaCommon s t => Lens' s (Maybe Integer)
93+schemaMaxLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
9194schemaMaxLength = schemaCommon.schemaCommonMaxLength
9295
93−schemaMinLength :: HasSchemaCommon s t => Lens' s (Maybe Integer)
96+schemaMinLength :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
9497schemaMinLength = schemaCommon.schemaCommonMinLength
9598
96−schemaPattern :: HasSchemaCommon s t => Lens' s (Maybe Text)
99+schemaPattern :: HasSchemaCommon s t i => Lens' s (Maybe Text)
97100schemaPattern = schemaCommon.schemaCommonPattern
98101
99−schemaMaxItems :: HasSchemaCommon s t => Lens' s (Maybe Integer)
102+schemaMaxItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
100103schemaMaxItems = schemaCommon.schemaCommonMaxItems
101104
102−schemaMinItems :: HasSchemaCommon s t => Lens' s (Maybe Integer)
105+schemaMinItems :: HasSchemaCommon s t i => Lens' s (Maybe Integer)
103106schemaMinItems = schemaCommon.schemaCommonMinItems
104107
105−schemaUniqueItems :: HasSchemaCommon s t => Lens' s (Maybe Bool)
108+schemaUniqueItems :: HasSchemaCommon s t i => Lens' s (Maybe Bool)
106109schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
107110
108−schemaEnum :: HasSchemaCommon s t => Lens' s (Maybe [Value])
111+schemaEnum :: HasSchemaCommon s t i => Lens' s (Maybe [Value])
109112schemaEnum = schemaCommon.schemaCommonEnum
110113
111−schemaMultipleOf :: HasSchemaCommon s t => Lens' s (Maybe Scientific)
114+schemaMultipleOf :: HasSchemaCommon s t i => Lens' s (Maybe Scientific)
112115schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
113116