git.iko.soy/typeable/openapi3
on master help sign in
Change minimum, maximum and multipleOf to Scientific to match swagger specification
cb6ef7aNickolay Kudasov
src/Data/Swagger/Internal.hs+4−3
@@ -19,6 +19,7 @@ import qualified Data.HashMap.Strict as HashMap
19import Data.Map (Map)
19import Data.Map (Map)
20import qualified Data.Map as Map
20import qualified Data.Map as Map
21import Data.Monoid
21import Data.Monoid
22+import Data.Scientific (Scientific)
22import Data.String (fromString)
23import Data.String (fromString)
23import Data.Text (Text)
24import Data.Text (Text)
24import qualified Data.Text as Text
25import qualified Data.Text as Text
@@ -420,9 +421,9 @@ data SchemaCommon = SchemaCommon
420 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
421 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
421 _schemaCommonDefault :: Maybe Value
422 _schemaCommonDefault :: Maybe Value
422
423
423− , _schemaCommonMaximum :: Maybe Integer
424+ , _schemaCommonMaximum :: Maybe Scientific
424 , _schemaCommonExclusiveMaximum :: Maybe Bool
425 , _schemaCommonExclusiveMaximum :: Maybe Bool
425− , _schemaCommonMinimum :: Maybe Integer
426+ , _schemaCommonMinimum :: Maybe Scientific
426 , _schemaCommonExclusiveMinimum :: Maybe Bool
427 , _schemaCommonExclusiveMinimum :: Maybe Bool
427 , _schemaCommonMaxLength :: Maybe Integer
428 , _schemaCommonMaxLength :: Maybe Integer
428 , _schemaCommonMinLength :: Maybe Integer
429 , _schemaCommonMinLength :: Maybe Integer
@@ -431,7 +432,7 @@ data SchemaCommon = SchemaCommon
431 , _schemaCommonMinItems :: Maybe Integer
432 , _schemaCommonMinItems :: Maybe Integer
432 , _schemaCommonUniqueItems :: Maybe Bool
433 , _schemaCommonUniqueItems :: Maybe Bool
433 , _schemaCommonEnum :: Maybe [Value]
434 , _schemaCommonEnum :: Maybe [Value]
434− , _schemaCommonMultipleOf :: Maybe Integer
435+ , _schemaCommonMultipleOf :: Maybe Scientific
435 } deriving (Eq, Show, Generic)
436 } deriving (Eq, Show, Generic)
436
437
437data Xml = Xml
438data Xml = Xml
src/Data/Swagger/Lens.hs+4−3
@@ -7,6 +7,7 @@ module Data.Swagger.Lens where
7import Control.Lens
7import Control.Lens
8import Control.Lens.TH
8import Control.Lens.TH
9import Data.Aeson (Value)
9import Data.Aeson (Value)
10+import Data.Scientific (Scientific)
10import Data.Swagger.Internal
11import Data.Swagger.Internal
11import Data.Text (Text)
12import Data.Text (Text)
12
13
@@ -69,13 +70,13 @@ instance HasSchemaCommon SchemaCommon where schemaCommon = id
69schemaDefault :: HasSchemaCommon s => Lens' s (Maybe Value)
70schemaDefault :: HasSchemaCommon s => Lens' s (Maybe Value)
70schemaDefault = schemaCommon.schemaCommonDefault
71schemaDefault = schemaCommon.schemaCommonDefault
71
72
72−schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Integer)
73+schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Scientific)
73schemaMaximum = schemaCommon.schemaCommonMaximum
74schemaMaximum = schemaCommon.schemaCommonMaximum
74
75
75schemaExclusiveMaximum :: HasSchemaCommon s => Lens' s (Maybe Bool)
76schemaExclusiveMaximum :: HasSchemaCommon s => Lens' s (Maybe Bool)
76schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
77schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
77
78
78−schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Integer)
79+schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Scientific)
79schemaMinimum = schemaCommon.schemaCommonMinimum
80schemaMinimum = schemaCommon.schemaCommonMinimum
80
81
81schemaExclusiveMinimum :: HasSchemaCommon s => Lens' s (Maybe Bool)
82schemaExclusiveMinimum :: HasSchemaCommon s => Lens' s (Maybe Bool)
@@ -102,6 +103,6 @@ schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
102schemaEnum :: HasSchemaCommon s => Lens' s (Maybe [Value])
103schemaEnum :: HasSchemaCommon s => Lens' s (Maybe [Value])
103schemaEnum = schemaCommon.schemaCommonEnum
104schemaEnum = schemaCommon.schemaCommonEnum
104
105
105−schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Integer)
106+schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Scientific)
106schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
107schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
107
108
src/Data/Swagger/Schema/Internal.hs+2−2
@@ -151,8 +151,8 @@ defaultSchemaOptions = SchemaOptions
151toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
151toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
152toSchemaBoundedIntegral _ = mempty
152toSchemaBoundedIntegral _ = mempty
153 & schemaType .~ SchemaInteger
153 & schemaType .~ SchemaInteger
154− & schemaMinimum ?~ toInteger (minBound :: a)
154+ & schemaMinimum ?~ fromInteger (toInteger (minBound :: a))
155− & schemaMaximum ?~ toInteger (maxBound :: a)
155+ & schemaMaximum ?~ fromInteger (toInteger (maxBound :: a))
156
156
157toSchemaBoundedEnum :: forall a proxy. (ToJSON a, Bounded a, Enum a) => proxy a -> Schema
157toSchemaBoundedEnum :: forall a proxy. (ToJSON a, Bounded a, Enum a) => proxy a -> Schema
158toSchemaBoundedEnum _ = mempty
158toSchemaBoundedEnum _ = mempty
swagger2.cabal+1
@@ -37,6 +37,7 @@ library
37 , text
37 , text
38 , unordered-containers
38 , unordered-containers
39 , lens
39 , lens
40+ , scientific
40 default-language: Haskell2010
41 default-language: Haskell2010
41
42
42test-suite spec
43test-suite spec