wai-middleware-validation- WAI Middleware to validate the request and response bodies
Safe HaskellNone




toTemplatedPathComponent :: FilePath -> TemplatedPathComponent Source #

Convert FilePath to TemplatedPathComponent.

>>> toTemplatedPathComponent "foo"
Exact "foo"
>>> toTemplatedPathComponent "{foo}"

toTemplatedPath :: FilePath -> TemplatedPath Source #

Convert FilePath to TemplatedPath.

>>> toTemplatedPath "/foo/{fooId}"
[Exact "/",Exact "foo",ParameterValue]
>>> toTemplatedPath "/bar/{barId}/baz/{bazId}"
[Exact "/",Exact "bar",ParameterValue,Exact "baz",ParameterValue]

makePathMap :: [FilePath] -> PathMap Source #

Convert list of FilePath to PathMap.

>>> makePathMap ["/foo", "/foo/{fooId}"]
fromList [([Exact "/",Exact "foo"],"/foo"),([Exact "/",Exact "foo",ParameterValue],"/foo/{fooId}")]

lookupDefinedPath :: FilePath -> PathMap -> Maybe FilePath Source #

Look up a path (including a templated path) from PathMap.

>>> lookupDefinedPath "/foo" (makePathMap ["/foo", "/foo/{fooId}"])
Just "/foo"
>>> lookupDefinedPath "/foo/1" (makePathMap ["/foo", "/foo/{fooId}"])
Just "/foo/{fooId}"
>>> lookupDefinedPath "/bar" (makePathMap ["/foo", "/foo/{fooId}"])

toApiDefinition :: ByteString -> Maybe ApiDefinition Source #

Create ApiDefinition instance from API document.

fixValidationError :: String -> String Source #

Fix validation error message.

>>> fixValidationError "Hello, World!"
"Hello, World!"
>>> fixValidationError "expected JSON value of type OpenApiString"
"expected JSON value of type string"
>>> fixValidationError "expected JSON value of type OpenApiNumber"
"expected JSON value of type number"
>>> fixValidationError "expected JSON value of type OpenApiInteger"
"expected JSON value of type integer"
>>> fixValidationError "expected JSON value of type OpenApiBoolean"
"expected JSON value of type boolean"