Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test helpers to ensure we don't change types or encodings of types
used in our request and response bodies by accident. crawl
will
traverse our entire Routes
API for request and response body types,
and fail to compile if we don't provide example values for each. We
can then run a golden result test for each, meaning we encode each
example value to JSON and check it matches a known-good encoding we
have comitted to the repo.
Documentation
tests :: forall routes. IsApi (ToServantApi routes) => Proxy routes -> List Test Source #
Creates tests for routes and custom types used in routes.
Example usage: describe Spec.ApiEncoding (TestEncoding.tests (Proxy :: Proxy Routes.Routes))
A helper type class that provides us example values of particular types.
The IsApi
typeclass below will demand we define an instance of this type
class for each type used in a request or response body.
A helper type class that can crawl our servant Routes
type and return us
JSON-encoded examples for each request and response body type in that API.
Example usage:
routes = crawl (Proxy :: Proxy (ToServantApi Routes.Routes))
Instances
IsApi Raw Source # | |
(IsApi a, IsApi b) => IsApi (a :<|> b :: Type) Source # | |
(Typeable body, HasExamples body, IsApi a) => IsApi (ReqBody' x encodings body :> a :: Type) Source # | |
IsApi a => IsApi (QueryFlag flag :> a :: Type) Source # | |
(KnownSymbol key, Typeable val, HasExamples val, IsApi a) => IsApi (Header' mods key val :> a :: Type) Source # | |
IsApi a => IsApi (Summary x :> a :: Type) Source # | |
(KnownSymbol s, IsApi a) => IsApi (Capture' mods s paramType :> a :: Type) Source # | |
IsApi a => IsApi (Auth types user :> a :: Type) Source # | |
(KnownSymbol s, IsApi a) => IsApi (s :> a :: Type) Source # | |
(Typeable method, Typeable body, HasExamples body) => IsApi (Verb method status encodings body :: Type) Source # | |