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

Network.Wai.Middleware.Validation.Internal

Synopsis

Documentation

toTemplatedPathComponent :: FilePath -> TemplatedPathComponent Source #

Convert FilePath to TemplatedPathComponent.

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

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}"])
Nothing

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"