-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Implementation of swagger data model -- @package swagger @version 0.2 -- | The Authorisation Object part of the swagger specification. For -- construction please consider using -- Data.Swagger.Build.Authorisation. module Data.Swagger.Model.Authorisation -- | Cf. Authorization Object data Authorisation BasicAuth :: Authorisation ApiKey :: PassMethod -> Text -> Authorisation passAs :: Authorisation -> PassMethod keyname :: Authorisation -> Text OAuth2 :: Maybe [Scope] -> GrantTypes -> Authorisation scopes :: Authorisation -> Maybe [Scope] grantTypes :: Authorisation -> GrantTypes data PassMethod PassAsHeader :: PassMethod PassAsQuery :: PassMethod -- | Cf. Scope Object data Scope Scope :: Text -> Maybe Text -> Scope scope :: Scope -> Text description :: Scope -> Maybe Text -- | Cf. Grant Types Object data GrantTypes GrantTypes :: Maybe ImplicitGrant -> Maybe AuthCode -> GrantTypes implicit :: GrantTypes -> Maybe ImplicitGrant authCode :: GrantTypes -> Maybe AuthCode -- | Cf. Implicit Object data ImplicitGrant ImplicitGrant :: LoginEndpoint -> Maybe Text -> ImplicitGrant loginEndpoint :: ImplicitGrant -> LoginEndpoint tokenName :: ImplicitGrant -> Maybe Text newtype LoginEndpoint LoginEndpoint :: Text -> LoginEndpoint loginUrl :: LoginEndpoint -> Text -- | Cf. Authorization Code Object data AuthCode AuthCode :: TokenRequestEndpoint -> TokenEndpoint -> AuthCode tokenRequestEndpoint :: AuthCode -> TokenRequestEndpoint tokenEndpoint :: AuthCode -> TokenEndpoint -- | Cf. Token Request Endpoint Object data TokenRequestEndpoint TokenRequestEndpoint :: Text -> Maybe Text -> Maybe Text -> TokenRequestEndpoint tokenRequestUrl :: TokenRequestEndpoint -> Text clientIdName :: TokenRequestEndpoint -> Maybe Text clientSecretName :: TokenRequestEndpoint -> Maybe Text -- | Cf. Token Endpoint Object data TokenEndpoint TokenEndpoint :: Text -> Maybe Text -> TokenEndpoint tokenEndpointUrl :: TokenEndpoint -> Text tokenEndpointTokenName :: TokenEndpoint -> Maybe Text instance Eq PassMethod instance Show PassMethod instance Show Scope instance Show LoginEndpoint instance Show ImplicitGrant instance Show TokenRequestEndpoint instance Show TokenEndpoint instance Show AuthCode instance Show GrantTypes instance Show Authorisation instance ToJSON TokenEndpoint instance ToJSON TokenRequestEndpoint instance ToJSON LoginEndpoint instance ToJSON AuthCode instance ToJSON ImplicitGrant instance ToJSON GrantTypes instance ToJSON Scope instance ToJSON PassMethod instance ToJSON Authorisation -- | The Resource Listing part of the swagger specification. For -- construction please consider using Data.Swagger.Build.Resource. module Data.Swagger.Model.Resource -- | Cf. Resource Listing Object data Resources Resources :: Text -> [Resource] -> Maybe Text -> Maybe Info -> Maybe [(Text, Authorisation)] -> Resources swaggerVersion :: Resources -> Text apis :: Resources -> [Resource] apiVersion :: Resources -> Maybe Text info :: Resources -> Maybe Info authorisations :: Resources -> Maybe [(Text, Authorisation)] -- | Cf. Resource Object data Resource Resource :: Text -> Maybe Text -> Resource path :: Resource -> Text description :: Resource -> Maybe Text -- | Cf. Info Object data Info Info :: Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Info title :: Info -> Text infoDescription :: Info -> Maybe Text termsOfServiceUrl :: Info -> Maybe Text contact :: Info -> Maybe Text license :: Info -> Maybe Text licenseUrl :: Info -> Maybe Text instance Show Resource instance Show Info instance Show Resources instance ToJSON Info instance ToJSON Resource instance ToJSON Resources -- | The API Declaration part of the swagger specification. For -- construction please consider using Data.Swagger.Build.Api. module Data.Swagger.Model.Api -- | Cf. API Declaration data ApiDecl ApiDecl :: Text -> Text -> [API] -> Maybe Text -> Maybe Text -> Maybe [(Text, Model)] -> Maybe [Text] -> Maybe [Text] -> Maybe [(Text, [Scope])] -> ApiDecl swaggerVersion :: ApiDecl -> Text basePath :: ApiDecl -> Text apis :: ApiDecl -> [API] apiVersion :: ApiDecl -> Maybe Text resourcePath :: ApiDecl -> Maybe Text models :: ApiDecl -> Maybe [(Text, Model)] apiProduces :: ApiDecl -> Maybe [Text] apiConsumes :: ApiDecl -> Maybe [Text] apiAuthorisations :: ApiDecl -> Maybe [(Text, [Scope])] -- | Cf. API Object data API API :: Text -> [Operation] -> Maybe Text -> API path :: API -> Text operations :: API -> [Operation] apiDescription :: API -> Maybe Text -- | Cf. Operation Object data Operation Operation :: Text -> Text -> Either () DataType -> [Parameter] -> Maybe Text -> Maybe Text -> Maybe [(Text, [Scope])] -> Maybe [Response] -> Maybe [Text] -> Maybe [Text] -> Maybe Bool -> Operation method :: Operation -> Text nickname :: Operation -> Text returnType :: Operation -> Either () DataType parameters :: Operation -> [Parameter] summary :: Operation -> Maybe Text notes :: Operation -> Maybe Text authorisations :: Operation -> Maybe [(Text, [Scope])] responses :: Operation -> Maybe [Response] produces :: Operation -> Maybe [Text] consumes :: Operation -> Maybe [Text] deprecated :: Operation -> Maybe Bool -- | Cf. Parameter Object data Parameter Parameter :: ParamType -> Either File DataType -> Text -> Maybe Text -> Maybe Bool -> Maybe Bool -> Parameter paramType :: Parameter -> ParamType inputType :: Parameter -> Either File DataType paramName :: Parameter -> Text description :: Parameter -> Maybe Text required :: Parameter -> Maybe Bool allowMultiple :: Parameter -> Maybe Bool data ParamType Path :: ParamType Query :: ParamType Body :: ParamType Header :: ParamType Form :: ParamType -- | Cf. Response Message Object data Response Response :: Int -> Text -> Maybe ModelId -> Response code :: Response -> Int message :: Response -> Text responseModel :: Response -> Maybe ModelId -- | Cf. Model Object data Model Model :: ModelId -> [(PropertyName, Property)] -> Maybe Text -> Maybe [PropertyName] -> Maybe [Model] -> Maybe PropertyName -> Model modelId :: Model -> ModelId properties :: Model -> [(PropertyName, Property)] modelDescription :: Model -> Maybe Text requiredProps :: Model -> Maybe [PropertyName] subTypes :: Model -> Maybe [Model] discriminator :: Model -> Maybe PropertyName -- | Cf. Property Object data Property Property :: DataType -> Maybe Text -> Property propertyType :: Property -> DataType propDescription :: Property -> Maybe Text data DataType Prim :: Primitive a -> DataType Array :: Items a -> Maybe Bool -> DataType Ref :: ModelId -> DataType -- | Cf. Primitive Types data Primitive a Primitive :: PrimType -> Maybe a -> Maybe [a] -> Maybe a -> Maybe a -> Primitive a primType :: Primitive a -> PrimType defaultValue :: Primitive a -> Maybe a enum :: Primitive a -> Maybe [a] minVal :: Primitive a -> Maybe a maxVal :: Primitive a -> Maybe a data Items a PrimItems :: (Primitive a) -> Items a ModelItems :: ModelId -> Items a data PrimType PrimInt32 :: PrimType PrimInt64 :: PrimType PrimFloat :: PrimType PrimDouble :: PrimType PrimString :: PrimType PrimByte :: PrimType PrimBool :: PrimType PrimDate :: PrimType PrimDateTime :: PrimType data File File :: File type ModelId = Text type PropertyName = Text instance Show DataType instance Eq ParamType instance Show ParamType instance Show Response instance Show PrimType instance Show a => Show (Primitive a) instance Show a => Show (Items a) instance Show Property instance Show Model instance Show File instance Show Parameter instance Show Operation instance Show API instance Show ApiDecl instance ToJSON Property instance ToJSON Model instance ToJSON Response instance ToJSON ParamType instance ToJSON Parameter instance ToJSON Operation instance ToJSON API instance ToJSON ApiDecl module Data.Swagger.Build.Authorisation basic :: Authorisation apiKey :: PassMethod -> Text -> Authorisation data PassMethod PassAsHeader :: PassMethod PassAsQuery :: PassMethod oauth2 :: GrantTypes -> OAuth2Builder -> Authorisation -- | Add one scope with the given name to an OAuth2 object. scope :: Text -> ScopeBuilder -> OAuth2Builder -- | Construct an implicit grant type with the given login endpoint and -- some optional token name. implicit :: Text -> ImplicitBuilder -> GrantTypes -- | Construct an authentorisation code based grant type object. authCode :: TokenRequestEndpoint -> TokenEndpoint -> GrantTypes tokenEndpoint :: Text -> TokenEndpointBuilder -> TokenEndpoint tokenRequestEndpoint :: Text -> TokenReqEndpointBuilder -> TokenRequestEndpoint clientIdName :: Text -> TokenReqEndpointBuilder clientSecretName :: Text -> TokenReqEndpointBuilder token :: Text -> State (TokenName a) () -- | If cases where no build steps are provided but a builder is required -- end can be used, e.g. defineModel "Foo" end end :: Monad m => m () type OAuth2Builder = State [Scope] () type ScopeSt = Common '["description"] Scope type ScopeBuilder = State ScopeSt () type ImplicitBuilder = State (TokenName ImplicitGrant) () type TokenEndpointBuilder = State (TokenName TokenEndpoint) () type TokenReqEndpointBuilder = State TokenRequestEndpoint () module Data.Swagger.Build.Resource -- | Construct a resource listing object given a swagger version and some -- resource objects. resources :: Text -> ResourcesBuilder -> Resources -- | Add one resource object to a resource listing given a path and some -- resource specific values. api :: Text -> ResourceBuilder -> ResourcesBuilder apiVersion :: Text -> ResourcesBuilder -- | Set the info object of a resource listing object given a title and -- other infor object specific values. info :: Text -> InfoBuilder -> ResourcesBuilder termsOfServiceUrl :: Text -> InfoBuilder contact :: Text -> InfoBuilder license :: Text -> InfoBuilder licenseUrl :: Text -> InfoBuilder -- | Add a authorisation object to a resource listing with the given name. authorisation :: Text -> Authorisation -> ResourcesBuilder -- | If cases where no build steps are provided but a builder is required -- end can be used, e.g. defineModel "Foo" end end :: Monad m => m () type ResourcesBuilder = State Resources () type InfoBuilder = State InfoSt () -- | Construction of Data.Swagger.Model.Api values. For example: -- --
-- declare "http://petstore.swagger.wordnik.com/api" "1.2" $ do
-- apiVersion "1.0.0"
-- resourcePath "/store"
-- model foo
-- model bar
-- produces "application/json"
-- produces "text/html"
-- produces "text/plain"
-- api "/store/order/{orderId}" $ do
-- operation "GET" "foo" $ do
-- summary "give me some foo"
-- notes "but only the good one"
-- returns (ref foo)
-- parameter Header "type" (string $ enum ["bar", "baz"]) $ do
-- description "specifies the type of foo"
-- optional
-- parameter Query "format" (string $ enum ["plain", "html"]) $
-- description "output format"
-- parameter Query "size" (int32 $ min 1 . max 100 . def 10) $
-- description "amount of foo"
-- produces "application/json"
-- produces "text/html"
-- response 200 "OK" (model foo)
-- response 400 "Bad Request" end
-- operation "POST" "foo" $ do
-- summary "something else"
-- deprecated
--
module Data.Swagger.Build.Api
-- | Cf. API Declaration
data ApiDecl
-- | Cf. API Object
data API
-- | Cf. Operation Object
data Operation
-- | Cf. Parameter Object
data Parameter
data ParamType
Path :: ParamType
Query :: ParamType
Body :: ParamType
Header :: ParamType
Form :: ParamType
-- | Cf. Response Message Object
data Response
-- | Cf. Model Object
data Model
-- | Cf. Property Object
data Property
data DataType
-- | Cf. Primitive Types
data Primitive a
data Items a
int32 :: (Primitive Int32 -> Primitive Int32) -> DataType
int32' :: DataType
int64 :: (Primitive Int64 -> Primitive Int64) -> DataType
int64' :: DataType
float :: (Primitive Float -> Primitive Float) -> DataType
float' :: DataType
bool :: (Primitive Bool -> Primitive Bool) -> DataType
bool' :: DataType
double :: (Primitive Double -> Primitive Double) -> DataType
double' :: DataType
string :: (Primitive String -> Primitive String) -> DataType
string' :: DataType
bytes :: (Primitive String -> Primitive String) -> DataType
bytes' :: DataType
date :: (Primitive UTCTime -> Primitive UTCTime) -> DataType
date' :: DataType
dateTime :: (Primitive UTCTime -> Primitive UTCTime) -> DataType
dateTime' :: DataType
-- | Default value of some primitive type.
def :: a -> Primitive a -> Primitive a
-- | Enumerate valid values of some primitive type.
enum :: [a] -> Primitive a -> Primitive a
-- | Minimum value of some primitive type.
min :: a -> Primitive a -> Primitive a
-- | Maximum value of some primitive type.
max :: a -> Primitive a -> Primitive a
ref :: Model -> DataType
array :: DataType -> DataType
-- | Specify that array elements are unique.
unique :: DataType -> DataType
type ApiDeclSt = Common '["produces", "consumes", "models", "authorisations"] ApiDecl
type ApiDeclBuilder = State ApiDeclSt ()
type ApiSt = Common '["description"] API
type ApiBuilder = State ApiSt ()
type OperationSt = Common '["produces", "consumes", "authorisations"] Operation
type OperationBuilder = State OperationSt ()
type ParameterSt = Common '["description", "required"] Parameter
type ParameterBuilder = State ParameterSt ()
type ResponseSt = Common '["models"] Response
type ResponseBuilder = State ResponseSt ()
type ModelSt = Common '["description"] Model
type ModelBuilder = State ModelSt ()
type PropertySt = Common '["description", "required"] Property
type PropertyBuilder = State PropertySt ()
-- | Create an API declaration given a base URL, a swagger version, and
-- other API declaration values.
declare :: Text -> Text -> ApiDeclBuilder -> ApiDecl
apiVersion :: Text -> ApiDeclBuilder
resourcePath :: Text -> ApiDeclBuilder
-- | Add one API object to an API declaration given some path and other API
-- object values.
api :: Text -> ApiBuilder -> ApiDeclBuilder
model :: Elem "models" f => Model -> State (Common f a) ()
-- | Add one operation object to an API object given an HTTP method, a
-- nickname and other operation specific values.
operation :: Text -> Text -> OperationBuilder -> ApiBuilder
returns :: DataType -> OperationBuilder
-- | Add one parameter object to an operation object given the
-- ParamType, the parameter name and the actual data-type plus
-- some other parameter values.
parameter :: ParamType -> Text -> DataType -> ParameterBuilder -> OperationBuilder
-- | Like parameter but specific for file uploads.
file :: Text -> ParameterBuilder -> OperationBuilder
-- | Like parameter but specific for request body parameters. Sets
-- ParamType to Body and uses as name "body" which is the
-- only valid name for request bodies.
body :: DataType -> ParameterBuilder -> OperationBuilder
summary :: Text -> OperationBuilder
notes :: Text -> OperationBuilder
-- | Add one response message object to an operation given a status code
-- and some message plus response message specific values.
response :: Int -> Text -> ResponseBuilder -> OperationBuilder
produces :: Elem "produces" f => Text -> State (Common f a) ()
authorisation :: Elem "authorisations" f => Auth -> State (Common f a) ()
data Auth
Basic :: Auth
ApiKey :: Auth
OAuth2 :: Scope -> Auth
None :: Auth
multiple :: ParameterBuilder
-- | Construct a complex data-type (aka "Model") given some identifier and
-- model-specific values.
defineModel :: ModelId -> ModelBuilder -> Model
-- | Add a property to a model given a name, type and other propertu
-- values.
property :: PropertyName -> DataType -> PropertyBuilder -> ModelBuilder
-- | Specify a sub-typing relationship for a model by given a
-- "discriminator" property name and all sub-types.
children :: PropertyName -> [Model] -> ModelBuilder
description :: Elem "description" f => Text -> State (Common f a) ()
optional :: Elem "required" f => State (Common f a) ()
consumes :: Elem "consumes" f => Text -> State (Common f a) ()
deprecated :: OperationBuilder
-- | If cases where no build steps are provided but a builder is required
-- end can be used, e.g. defineModel "Foo" end
end :: Monad m => m ()