git.iko.soy/typeable/swagger2
on master help sign in
Change minimum, maximum and multipleOf to Scientific to match swagger specification
commitcb6ef7ae7c11bc06502fba0a54f8a938ed402e3f authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateTue 24 Nov 2015, 15:49 (11 years ago) parent70a35c5
4 files changed+11−8
src/Data/Swagger/Internal.hs+4−3 src/Data/Swagger/Lens.hs+4−3 src/Data/Swagger/Schema/Internal.hs+2−2 swagger2.cabal+1
src/Data/Swagger/Internal.hs+4−3
@@ -19,6 +19,7 @@ import qualified Data.HashMap.Strict as HashMap
1919import Data.Map (Map)
2020import qualified Data.Map as Map
2121import Data.Monoid
22+import Data.Scientific (Scientific)
2223import Data.String (fromString)
2324import Data.Text (Text)
2425import qualified Data.Text as Text
@@ -420,9 +421,9 @@ data SchemaCommon = SchemaCommon
420421 -- Unlike JSON Schema this value MUST conform to the defined type for this parameter.
421422 _schemaCommonDefault :: Maybe Value
422423
423− , _schemaCommonMaximum :: Maybe Integer
424+ , _schemaCommonMaximum :: Maybe Scientific
424425 , _schemaCommonExclusiveMaximum :: Maybe Bool
425− , _schemaCommonMinimum :: Maybe Integer
426+ , _schemaCommonMinimum :: Maybe Scientific
426427 , _schemaCommonExclusiveMinimum :: Maybe Bool
427428 , _schemaCommonMaxLength :: Maybe Integer
428429 , _schemaCommonMinLength :: Maybe Integer
@@ -431,7 +432,7 @@ data SchemaCommon = SchemaCommon
431432 , _schemaCommonMinItems :: Maybe Integer
432433 , _schemaCommonUniqueItems :: Maybe Bool
433434 , _schemaCommonEnum :: Maybe [Value]
434− , _schemaCommonMultipleOf :: Maybe Integer
435+ , _schemaCommonMultipleOf :: Maybe Scientific
435436 } deriving (Eq, Show, Generic)
436437
437438data Xml = Xml
src/Data/Swagger/Lens.hs+4−3
@@ -7,6 +7,7 @@ module Data.Swagger.Lens where
77import Control.Lens
88import Control.Lens.TH
99import Data.Aeson (Value)
10+import Data.Scientific (Scientific)
1011import Data.Swagger.Internal
1112import Data.Text (Text)
1213
@@ -69,13 +70,13 @@ instance HasSchemaCommon SchemaCommon where schemaCommon = id
6970schemaDefault :: HasSchemaCommon s => Lens' s (Maybe Value)
7071schemaDefault = schemaCommon.schemaCommonDefault
7172
72−schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Integer)
73+schemaMaximum :: HasSchemaCommon s => Lens' s (Maybe Scientific)
7374schemaMaximum = schemaCommon.schemaCommonMaximum
7475
7576schemaExclusiveMaximum :: HasSchemaCommon s => Lens' s (Maybe Bool)
7677schemaExclusiveMaximum = schemaCommon.schemaCommonExclusiveMaximum
7778
78−schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Integer)
79+schemaMinimum :: HasSchemaCommon s => Lens' s (Maybe Scientific)
7980schemaMinimum = schemaCommon.schemaCommonMinimum
8081
8182schemaExclusiveMinimum :: HasSchemaCommon s => Lens' s (Maybe Bool)
@@ -102,6 +103,6 @@ schemaUniqueItems = schemaCommon.schemaCommonUniqueItems
102103schemaEnum :: HasSchemaCommon s => Lens' s (Maybe [Value])
103104schemaEnum = schemaCommon.schemaCommonEnum
104105
105−schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Integer)
106+schemaMultipleOf :: HasSchemaCommon s => Lens' s (Maybe Scientific)
106107schemaMultipleOf = schemaCommon.schemaCommonMultipleOf
107108
src/Data/Swagger/Schema/Internal.hs+2−2
@@ -151,8 +151,8 @@ defaultSchemaOptions = SchemaOptions
151151toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
152152toSchemaBoundedIntegral _ = mempty
153153 & schemaType .~ SchemaInteger
154− & schemaMinimum ?~ toInteger (minBound :: a)
155− & schemaMaximum ?~ toInteger (maxBound :: a)
154+ & schemaMinimum ?~ fromInteger (toInteger (minBound :: a))
155+ & schemaMaximum ?~ fromInteger (toInteger (maxBound :: a))
156156
157157toSchemaBoundedEnum :: forall a proxy. (ToJSON a, Bounded a, Enum a) => proxy a -> Schema
158158toSchemaBoundedEnum _ = mempty
swagger2.cabal+1
@@ -37,6 +37,7 @@ library
3737 , text
3838 , unordered-containers
3939 , lens
40+ , scientific
4041 default-language: Haskell2010
4142
4243test-suite spec