License | BSD3 |
---|---|
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
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.
- mockServerSettings :: MockServerSettings
- 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)
- mockServer :: Router (MockServer p) (Apis p) `(CUSTOM "", `[]`)` => ServerSettings -> MockServer p -> Application
- newtype MockServer p = MockServer {}
- data MockServerSettings = MockServerSettings {}
- data MockServerException = MockServerException {}
- data ResponseData
- 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)
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
.
Eq (MockServer p) Source | |
Show (MockServer p) Source | |
WebApi p => WebApiImplementation (MockServer p) Source | |
(ApiContract p m r, Arbitrary (ApiOut m r), Arbitrary (ApiErr m r), Arbitrary (HeaderOut m r), Arbitrary (CookieOut m r), Typeable * m, Typeable * r) => ApiHandler (MockServer p) m r Source | |
type HandlerM (MockServer p) = IO | |
type ApiInterface (MockServer p) = p Source |
data MockServerSettings Source
Settings related to mock server.
data MockServerException Source
Datatype representing a mock exception. This exception will be put inside OtherError
.
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.