swagger2-2.7: Swagger 2.0 data model
Safe HaskellNone
LanguageHaskell2010

Data.Swagger.Internal.ParamSchema

Synopsis

Documentation

binaryParamSchema :: ParamSchema t Source #

Default schema for binary data (any sequence of octets).

byteParamSchema :: ParamSchema t Source #

Default schema for binary data (base64 encoded).

passwordParamSchema :: ParamSchema t Source #

Default schema for password string. "password" format is used to hint UIs the input needs to be obscured.

class ToParamSchema a where Source #

Convert a type into a plain ParamSchema.

An example type and instance:

{-# LANGUAGE OverloadedStrings #-}   -- allows to write Text literals

import Control.Lens

data Direction = Up | Down

instance ToParamSchema Direction where
  toParamSchema _ = mempty
     & type_ ?~ SwaggerString
     & enum_ ?~ [ "Up", "Down" ]

Instead of manually writing your ToParamSchema instance you can use a default generic implementation of toParamSchema.

To do that, simply add deriving Generic clause to your datatype and declare a ToParamSchema instance for your datatype without giving definition for toParamSchema.

For instance, the previous example can be simplified into this:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics (Generic)

data Direction = Up | Down deriving Generic

instance ToParamSchema Direction

Minimal complete definition

Nothing

Methods

toParamSchema :: Proxy a -> ParamSchema t Source #

Convert a type into a plain parameter schema.

>>> encode $ toParamSchema (Proxy :: Proxy Integer)
"{\"type\":\"integer\"}"

Instances

Instances details
ToParamSchema Bool Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Bool -> ParamSchema t Source #

ToParamSchema Char Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Char -> ParamSchema t Source #

ToParamSchema Double Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Float Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Int Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Int -> ParamSchema t Source #

ToParamSchema Int8 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Int8 -> ParamSchema t Source #

ToParamSchema Int16 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Int32 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Int64 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Integer Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Natural Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Word Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Word -> ParamSchema t Source #

ToParamSchema Word8 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Word16 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Word32 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Word64 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema () Source #
>>> encode $ toParamSchema (Proxy :: Proxy ())
"{\"enum\":[\"_\"],\"type\":\"string\"}"
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy () -> ParamSchema t Source #

ToParamSchema String Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Version Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

(ToParamSchemaByteStringError ByteString :: Constraint) => ToParamSchema ByteString Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

(ToParamSchemaByteStringError ByteString :: Constraint) => ToParamSchema ByteString Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Scientific Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema UTCTime Source #
>>> toParamSchema (Proxy :: Proxy UTCTime) ^. format
Just "yyyy-mm-ddThh:MM:ssZ"
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Text Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Text -> ParamSchema t Source #

ToParamSchema Text Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Text -> ParamSchema t Source #

ToParamSchema All Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy All -> ParamSchema t Source #

ToParamSchema Any Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Any -> ParamSchema t Source #

ToParamSchema SetCookie Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema ZonedTime Source #
>>> toParamSchema (Proxy :: Proxy ZonedTime) ^. format
Just "yyyy-mm-ddThh:MM:ss+hhMM"
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema LocalTime Source #
>>> toParamSchema (Proxy :: Proxy LocalTime) ^. format
Just "yyyy-mm-ddThh:MM:ss"
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema TimeOfDay Source #
>>> toParamSchema (Proxy :: Proxy TimeOfDay) ^. format
Just "hh:MM:ss"
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema NominalDiffTime Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

ToParamSchema Day Source #

Format "date" corresponds to yyyy-mm-dd format.

Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy Day -> ParamSchema t Source #

ToParamSchema UUID Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy UUID -> ParamSchema t Source #

ToParamSchema a => ToParamSchema [a] Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy [a] -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Identity a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Identity a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (First a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (First a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Last a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Last a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Dual a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Dual a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Sum a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Sum a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Product a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Product a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Set a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Set a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (HashSet a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (HashSet a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Vector a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Vector a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Vector a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Vector a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Vector a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Vector a) -> ParamSchema t Source #

ToParamSchema a => ToParamSchema (Vector a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Vector a) -> ParamSchema t Source #

HasResolution a => ToParamSchema (Fixed a) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: forall (t :: SwaggerKind Type). Proxy (Fixed a) -> ParamSchema t Source #

toParamSchemaBoundedIntegral :: forall a t. (Bounded a, Integral a) => Proxy a -> ParamSchema t Source #

Default plain schema for Bounded, Integral types.

>>> encode $ toParamSchemaBoundedIntegral (Proxy :: Proxy Int8)
"{\"maximum\":127,\"minimum\":-128,\"type\":\"integer\"}"

type family ToParamSchemaByteStringError bs where ... Source #

Equations

ToParamSchemaByteStringError bs = TypeError (((('Text "Impossible to have an instance " :<>: ShowType (ToParamSchema bs)) :<>: Text ".") :$$: (('Text "Please, use a newtype wrapper around " :<>: ShowType bs) :<>: Text " instead.")) :$$: 'Text "Consider using byteParamSchema or binaryParamSchema templates.") 

genericToParamSchema :: forall a t. (Generic a, GToParamSchema (Rep a)) => SchemaOptions -> Proxy a -> ParamSchema t Source #

A configurable generic ParamSchema creator.

>>> :set -XDeriveGeneric
>>> data Color = Red | Blue deriving Generic
>>> encode $ genericToParamSchema defaultSchemaOptions (Proxy :: Proxy Color)
"{\"enum\":[\"Red\",\"Blue\"],\"type\":\"string\"}"

class GToParamSchema (f :: * -> *) where Source #

Instances

Instances details
ToParamSchema c => GToParamSchema (K1 i c :: Type -> Type) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

gtoParamSchema :: forall (t :: SwaggerKind Type). SchemaOptions -> Proxy (K1 i c) -> ParamSchema t -> ParamSchema t Source #

(GEnumParamSchema f, GEnumParamSchema g) => GToParamSchema (f :+: g) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

gtoParamSchema :: forall (t :: SwaggerKind Type). SchemaOptions -> Proxy (f :+: g) -> ParamSchema t -> ParamSchema t Source #

GToParamSchema f => GToParamSchema (D1 d f) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

gtoParamSchema :: forall (t :: SwaggerKind Type). SchemaOptions -> Proxy (D1 d f) -> ParamSchema t -> ParamSchema t Source #

GToParamSchema f => GToParamSchema (C1 c (S1 s f)) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

gtoParamSchema :: forall (t :: SwaggerKind Type). SchemaOptions -> Proxy (C1 c (S1 s f)) -> ParamSchema t -> ParamSchema t Source #

Constructor c => GToParamSchema (C1 c (U1 :: Type -> Type)) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

class GEnumParamSchema (f :: * -> *) where Source #

Instances

Instances details
(GEnumParamSchema f, GEnumParamSchema g) => GEnumParamSchema (f :+: g) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Constructor c => GEnumParamSchema (C1 c (U1 :: Type -> Type)) Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

data Proxy3 a b c Source #

Constructors

Proxy3 
>>> import Data.Aeson (encode)