swagger2-2.3.1.1: Swagger 2.0 data model

MaintainerNickolay Kudasov <nickolay@getshoptv.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Swagger.ParamSchema

Contents

Description

Types and functions for working with Swagger parameter schema.

Synopsis

Encoding

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 FPFormat 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\"}"

toParamSchema :: (Generic a, GToParamSchema (Rep a)) => proxy a -> ParamSchema t Source #

Convert a type into a plain parameter schema.

>>> encode $ toParamSchema (Proxy :: Proxy Integer)
"{\"type\":\"integer\"}"
Instances
ToParamSchema Bool Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Bool -> ParamSchema t Source #

ToParamSchema Char Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Char -> ParamSchema t Source #

ToParamSchema Double Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Double -> ParamSchema t Source #

ToParamSchema Float Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Float -> ParamSchema t Source #

ToParamSchema Int Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Int -> ParamSchema t Source #

ToParamSchema Int8 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Int8 -> ParamSchema t Source #

ToParamSchema Int16 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Int16 -> ParamSchema t Source #

ToParamSchema Int32 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Int32 -> ParamSchema t Source #

ToParamSchema Int64 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Int64 -> ParamSchema t Source #

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 :: proxy Word -> ParamSchema t Source #

ToParamSchema Word8 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Word8 -> ParamSchema t Source #

ToParamSchema Word16 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Word16 -> ParamSchema t Source #

ToParamSchema Word32 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Word32 -> ParamSchema t Source #

ToParamSchema Word64 Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Word64 -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy () -> ParamSchema t Source #

ToParamSchema String Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy String -> ParamSchema t Source #

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 Text Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy Text -> ParamSchema t Source #

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 :: proxy Text -> ParamSchema t Source #

ToParamSchema All Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy All -> ParamSchema t Source #

ToParamSchema Any Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: 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 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 :: proxy Day -> ParamSchema t Source #

ToParamSchema UUID Source # 
Instance details

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy UUID -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy [a] -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Fixed a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Identity a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (First a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Last a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Dual a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Sum a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Product a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Set a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Vector a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Vector a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Vector a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (HashSet a) -> ParamSchema t Source #

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

Defined in Data.Swagger.Internal.ParamSchema

Methods

toParamSchema :: proxy (Vector a) -> ParamSchema t Source #

Generic schema encoding

genericToParamSchema :: forall proxy 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)
"{\"type\":\"string\",\"enum\":[\"Red\",\"Blue\"]}"

toParamSchemaBoundedIntegral :: forall proxy 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\"}"

Schema templates

passwordParamSchema :: ParamSchema t Source #

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

binaryParamSchema :: ParamSchema t Source #

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

byteParamSchema :: ParamSchema t Source #

Default schema for binary data (base64 encoded).

Generic encoding configuration

data SchemaOptions Source #

Options that specify how to encode your type to Swagger schema.

Constructors

SchemaOptions 

Fields