Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data TemplatedPathComponent
- toTemplatedPathComponent :: FilePath -> TemplatedPathComponent
- type TemplatedPath = [TemplatedPathComponent]
- toTemplatedPath :: FilePath -> TemplatedPath
- type PathMap = Map TemplatedPath FilePath
- makePathMap :: [FilePath] -> PathMap
- lookupDefinedPath :: FilePath -> PathMap -> Maybe FilePath
- data ApiDefinition = ApiDefinition {}
- toApiDefinition :: ByteString -> Maybe ApiDefinition
- newtype BodySchema = BodySchema {}
- getRequestBodySchema :: ApiDefinition -> StdMethod -> FilePath -> Maybe BodySchema
- getRequestBodyReferencedSchema :: ApiDefinition -> (PathItem -> Maybe Operation) -> FilePath -> Maybe (Referenced Schema)
- getResponseBodySchema :: ApiDefinition -> StdMethod -> FilePath -> Int -> Maybe BodySchema
- getResponseBodyReferencedSchema :: ApiDefinition -> (PathItem -> Maybe Operation) -> FilePath -> Int -> Maybe (Referenced Schema)
- getPathItem :: ApiDefinition -> FilePath -> Maybe PathItem
- validateJsonDocument :: ApiDefinition -> BodySchema -> ByteString -> Either String [String]
- fixValidationError :: String -> String
Documentation
data TemplatedPathComponent Source #
Instances
toTemplatedPathComponent :: FilePath -> TemplatedPathComponent Source #
Convert FilePath to TemplatedPathComponent.
>>>
toTemplatedPathComponent "foo"
Exact "foo">>>
toTemplatedPathComponent "{foo}"
ParameterValue
type TemplatedPath = [TemplatedPathComponent] Source #
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
data ApiDefinition Source #
Instances
Eq ApiDefinition Source # | |
Defined in Network.Wai.Middleware.Validation.Internal (==) :: ApiDefinition -> ApiDefinition -> Bool # (/=) :: ApiDefinition -> ApiDefinition -> Bool # | |
Show ApiDefinition Source # | |
Defined in Network.Wai.Middleware.Validation.Internal showsPrec :: Int -> ApiDefinition -> ShowS # show :: ApiDefinition -> String # showList :: [ApiDefinition] -> ShowS # |
toApiDefinition :: ByteString -> Maybe ApiDefinition Source #
Create ApiDefinition instance from API document.
newtype BodySchema Source #
Instances
Eq BodySchema Source # | |
Defined in Network.Wai.Middleware.Validation.Internal (==) :: BodySchema -> BodySchema -> Bool # (/=) :: BodySchema -> BodySchema -> Bool # | |
Show BodySchema Source # | |
Defined in Network.Wai.Middleware.Validation.Internal showsPrec :: Int -> BodySchema -> ShowS # show :: BodySchema -> String # showList :: [BodySchema] -> ShowS # |
getRequestBodySchema :: ApiDefinition -> StdMethod -> FilePath -> Maybe BodySchema Source #
Get request body schema.
getRequestBodyReferencedSchema :: ApiDefinition -> (PathItem -> Maybe Operation) -> FilePath -> Maybe (Referenced Schema) Source #
getResponseBodySchema :: ApiDefinition -> StdMethod -> FilePath -> Int -> Maybe BodySchema Source #
Get response body schema.
getResponseBodyReferencedSchema :: ApiDefinition -> (PathItem -> Maybe Operation) -> FilePath -> Int -> Maybe (Referenced Schema) Source #
getPathItem :: ApiDefinition -> FilePath -> Maybe PathItem Source #
validateJsonDocument :: ApiDefinition -> BodySchema -> ByteString -> Either String [String] Source #
Validate JSON 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"