git.iko.soy/typeable/swagger2
on master help sign in
Add genericToNamedSchemaBoundedIntegral helper
commit70a35c56c041519bfec19afdec74b52a0bd6eca3 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateTue 24 Nov 2015, 15:42 (11 years ago) parentce9375c
2 files changed+10−1
src/Data/Swagger/Schema.hs+1 src/Data/Swagger/Schema/Internal.hs+9−1
src/Data/Swagger/Schema.hs+1
@@ -11,6 +11,7 @@ module Data.Swagger.Schema (
1111 genericToSchema,
1212 genericToNamedSchema,
1313 genericToNamedSchemaBoundedEnum,
14+ genericToNamedSchemaBoundedIntegral,
1415
1516 toSchemaBoundedIntegral,
1617 toSchemaBoundedEnum,
src/Data/Swagger/Schema/Internal.hs+9−1
@@ -159,11 +159,19 @@ toSchemaBoundedEnum _ = mempty
159159 & schemaType .~ SchemaString
160160 & schemaEnum ?~ map toJSON [minBound..maxBound :: a]
161161
162+genericToNamedSchemaBoundedIntegral :: forall a d f proxy.
163+ ( Bounded a, Integral a
164+ , Generic a, Rep a ~ D1 d f, Datatype d)
165+ => SchemaOptions -> proxy a -> NamedSchema
166+genericToNamedSchemaBoundedIntegral opts proxy
167+ = (gdatatypeSchemaName opts (Proxy :: Proxy d), toSchemaBoundedIntegral proxy)
168+
162169genericToNamedSchemaBoundedEnum :: forall a d f proxy.
163170 ( ToJSON a, Bounded a, Enum a
164171 , Generic a, Rep a ~ D1 d f, Datatype d)
165172 => SchemaOptions -> proxy a -> NamedSchema
166−genericToNamedSchemaBoundedEnum opts proxy = (gdatatypeSchemaName opts (Proxy :: Proxy d), toSchemaBoundedEnum proxy)
173+genericToNamedSchemaBoundedEnum opts proxy
174+ = (gdatatypeSchemaName opts (Proxy :: Proxy d), toSchemaBoundedEnum proxy)
167175
168176genericToSchema :: (Generic a, GToSchema (Rep a)) => SchemaOptions -> proxy a -> Schema
169177genericToSchema opts = snd . genericToNamedSchema opts