@@ -63,6 +63,9 @@ import Data.Swagger.SchemaOptions
6363-- @
6464class ToParamSchema a where
6565 -- | Convert a type into a plain parameter schema.
66+ --
67+ -- >>> encode $ toParamSchema (Proxy :: Proxy Integer)
68+ -- "{\"type\":\"integer\"}"
6669 toParamSchema :: proxy a -> ParamSchema t
6770 default toParamSchema :: (Generic a, GToParamSchema (Rep a)) => proxy a -> ParamSchema t
6871 toParamSchema = genericToParamSchema defaultSchemaOptions
@@ -89,6 +92,9 @@ instance ToParamSchema Word32 where toParamSchema = toParamSchemaBoundedIntegral
8992instance ToParamSchema Word64 where toParamSchema = toParamSchemaBoundedIntegral
9093
9194-- | Default plain schema for @'Bounded'@, @'Integral'@ types.
95+--
96+-- >>> encode $ toParamSchemaBoundedIntegral (Proxy :: Proxy Int8)
97+-- "{\"maximum\":127,\"minimum\":-128,\"type\":\"integer\"}"
9298toParamSchemaBoundedIntegral :: forall proxy a t. (Bounded a, Integral a) => proxy a -> ParamSchema t
9399toParamSchemaBoundedIntegral _ = mempty
94100 & schemaType .~ SwaggerInteger
@@ -166,6 +172,10 @@ instance ToParamSchema () where
166172 & schemaEnum ?~ ["_"]
167173
168174-- | A configurable generic @'ParamSchema'@ creator.
175+--
176+-- >>> data Color = Red | Blue deriving Generic
177+-- >>> encode $ genericToParamSchema defaultSchemaOptions (Proxy :: Proxy Color)
178+-- "{\"type\":\"string\",\"enum\":[\"Red\",\"Blue\"]}"
169179genericToParamSchema :: forall proxy a t. (Generic a, GToParamSchema (Rep a)) => SchemaOptions -> proxy a -> ParamSchema t
170180genericToParamSchema opts _ = gtoParamSchema opts (Proxy :: Proxy (Rep a)) mempty
171181