Copyright | (c) Justin Le 2021 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
A package with "test suites" to help verify that your servant APIs are valid at compile-time. Currently the only property tested is that there are no duplicated paths. See README for more information on usage.
Synopsis
- class HasApiTree (api :: Type) where
- class MethodString k where
- type ToMethodString (x :: k) :: Symbol
- validApiTree :: forall api. (HasApiTree api, Typeable (ToApiTree api)) => Proxy api -> ValidApiTree api
- type ValidApiTree api = TypeRep (ToApiTree api)
- reflectApiTree :: forall api. (HasApiTree api, Typeable (ToApiTree api)) => ApiTreeMap
- reflectApiTree_ :: TypeRep (apiTree :: ApiTree) -> ApiTreeMap
- data SApiTree :: ApiTree -> Type where
- reflectSApiTree :: SApiTree api -> ApiTreeMap
Documentation
class HasApiTree (api :: Type) where Source #
Has a valid well-formed API Tree
sApiTree :: SApiTree (ToApiTree api) Source #
Useful runtime witness of the API tree; use to inspect it with
reflectApiTree
. This is not used in any part of the actual
validation; is just an extra treat.
Instances
class MethodString k Source #
A type-level version of ReflectMethod
.
type ToMethodString (x :: k) :: Symbol Source #
Instances
MethodString Symbol Source # | |
Defined in Servant.Validate type ToMethodString x :: Symbol Source # | |
MethodString StdMethod Source # | |
Defined in Servant.Validate type ToMethodString x :: Symbol Source # |
validApiTree :: forall api. (HasApiTree api, Typeable (ToApiTree api)) => Proxy api -> ValidApiTree api Source #
The full validator. To use:
serverApi :: Proxy ServerApi serverApi = Proxy validServerApi :: ValidApiTree ServerApi validServerApi = validApiTree serverApi
type ValidApiTree api = TypeRep (ToApiTree api) Source #
To be used with validApiTree
.
reflectApiTree :: forall api. (HasApiTree api, Typeable (ToApiTree api)) => ApiTreeMap Source #
Useful utility to view the routing structure of a tree; similar to
layout
.
reflectApiTree_ :: TypeRep (apiTree :: ApiTree) -> ApiTreeMap Source #
Version of reflectApiTree
taking an explicit TypeRep
.
reflectSApiTree :: SApiTree api -> ApiTreeMap Source #