webapi-0.2.2.0: WAI based library for web api

LicenseBSD3
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

WebApi.Mock

Contents

Description

Once a contract is defined for a web api, a mock server and client for it can be obtained. Arbitrary instances of the data types used in Request and Response is used to generate the request and response. Note that if a different mocking behaviour is required, it is easy enough to write a different implementation. Please take a look at the reference implementation of MockServer for details.

Synopsis

Mock Server

mockServerSettings :: MockServerSettings Source

Default mock server settings.

mockResponse :: forall route m r. (Arbitrary (ApiOut m r), Arbitrary (HeaderOut m r), Arbitrary (CookieOut m r), Arbitrary (ApiErr m r), Typeable m, Typeable r) => route m r -> MockServerSettings -> IO (Response m r) Source

Create a mock response from endpoint information and MockServerSettings

mockServer :: Router (MockServer p) (Apis p) `(CUSTOM "", `[]`)` => ServerSettings -> MockServer p -> Application Source

Create a mock server.

newtype MockServer p Source

Datatype representing a mock server. The parameterization over p allows it to be a mock server for any p.

data MockServerSettings Source

Settings related to mock server.

data MockServerException Source

Datatype representing a mock exception. This exception will be put inside OtherError.

Constructors

MockServerException 

Fields

exceptionMsg :: String
 

data ResponseData Source

Determine the data constructor of Response to be generated in mockServer.

Mock Client

mockClient :: (Arbitrary (PathParam m r), Arbitrary (QueryParam m r), Arbitrary (FormParam m r), Arbitrary (FileParam m r), Arbitrary (HeaderIn m r), Arbitrary (CookieIn m r), Arbitrary (HListToTuple (StripContents (RequestBody m r))), SingMethod m) => route m r -> IO (Request m r) Source

Create a mock client.