git.iko.soy/typeable/openapi3
on master help sign in
Merge pull request #123 from pngwjpgh/feature/Natural

Add ParamSchema & Schema for Numeric.Natural

commit5ec8bd72ca66d47f62544b2022def2418959d951 authorOleg Grenrus <oleg.grenrus@iki.fi> dateThu 21 Sep 2017, 20:05 (9 years ago) parent482a9abbf9c2e5
3 files changed+11
src/Data/Swagger/Internal/ParamSchema.hs+7 src/Data/Swagger/Internal/Schema.hs+2 swagger2.cabal+2
src/Data/Swagger/Internal/ParamSchema.hs+7
@@ -39,6 +39,7 @@ import qualified Data.Vector as V
3939import qualified Data.Vector.Primitive as VP
4040import qualified Data.Vector.Storable as VS
4141import qualified Data.Vector.Unboxed as VU
42+import Numeric.Natural
4243import Data.Word
4344import Data.UUID.Types (UUID)
4445
@@ -125,6 +126,12 @@ instance ToParamSchema Bool where
125126instance ToParamSchema Integer where
126127 toParamSchema _ = mempty & type_ .~ SwaggerInteger
127128
129+instance ToParamSchema Natural where
130+ toParamSchema _ = mempty
131+ & type_ .~ SwaggerInteger
132+ & minimum_ ?~ 0
133+ & exclusiveMinimum ?~ False
134+
128135instance ToParamSchema Int where toParamSchema = toParamSchemaBoundedIntegral
129136instance ToParamSchema Int8 where toParamSchema = toParamSchemaBoundedIntegral
130137instance ToParamSchema Int16 where toParamSchema = toParamSchemaBoundedIntegral
src/Data/Swagger/Internal/Schema.hs+2
@@ -56,6 +56,7 @@ import qualified Data.Vector as V
5656import qualified Data.Vector.Primitive as VP
5757import qualified Data.Vector.Storable as VS
5858import qualified Data.Vector.Unboxed as VU
59+import Numeric.Natural
5960import Data.Word
6061import GHC.Generics
6162import qualified Data.UUID.Types as UUID
@@ -419,6 +420,7 @@ instance OVERLAPPABLE_ ToSchema a => ToSchema [a] where
419420instance OVERLAPPING_ ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
420421instance ToSchema Bool where declareNamedSchema = plain . paramSchemaToSchema
421422instance ToSchema Integer where declareNamedSchema = plain . paramSchemaToSchema
423+instance ToSchema Natural where declareNamedSchema = plain . paramSchemaToSchema
422424instance ToSchema Int where declareNamedSchema = plain . paramSchemaToSchema
423425instance ToSchema Int8 where declareNamedSchema = plain . paramSchemaToSchema
424426instance ToSchema Int16 where declareNamedSchema = plain . paramSchemaToSchema
swagger2.cabal+2
@@ -69,6 +69,8 @@ library
6969 , unordered-containers
7070 , vector
7171 , uuid-types >=1.0.2 && <1.1
72+ if !impl(ghc >= 7.10)
73+ build-depends: nats >=1.1.1 && <1.2
7274 default-language: Haskell2010
7375
7476test-suite spec