-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Testing of Swagger APIs
--
-- This package provides a library and executable tool that supports
-- testing APIs specified with Swagger. It allows one to generate
-- arbitrary Swagger requests for any given specification.
@package swagger-test
@version 0.2.6
-- | Re-exports
module Test.Swagger
-- | Given a swagger.json schema, produce a Request that complies with the
-- schema. The return type is a random Request (in the IO monad because
-- it's random).
generateRequest :: Seed -> Size -> NormalizedSwagger -> Maybe OperationId -> (Operation, HttpRequest)
-- | Possible output formats that applies to HttpRequest and
-- HttpResponse values
data Format
FormatHttp :: Format
FormatCurl :: Format
FormatNone :: Format
FormatJSON :: Format
-- | Valid output formats for HttpRequest values
requestFormats :: [Format]
-- | Valid output formats for HttpResponse values
responseFormats :: [Format]
-- | Print a request according to format
printRequest :: Format -> HttpRequest -> Builder
-- | Print a response according to format
printResponse :: Format -> HttpResponse -> Builder
-- | Executes the HTTP request and returns the HTTP response
doHttpRequest :: HttpRequest -> IO HttpResponse
-- | The FullyQualifiedHost contains the scheme (i.e. http://),
-- hostname and port.
type FullyQualifiedHost = String
type Seed = Int
type Size = Int
data NormalizedSwagger
getSwagger :: NormalizedSwagger -> Swagger
type OperationId = Text
type HttpHeader = (CI Text, Text)
type Headers = [HttpHeader]
data HttpRequest
HttpRequest :: Maybe FullyQualifiedHost -> Method -> Text -> QueryText -> Headers -> Maybe ByteString -> HttpRequest
[requestHost] :: HttpRequest -> Maybe FullyQualifiedHost
[requestMethod] :: HttpRequest -> Method
[requestPath] :: HttpRequest -> Text
[requestQuery] :: HttpRequest -> QueryText
[requestHeaders] :: HttpRequest -> Headers
[requestBody] :: HttpRequest -> Maybe ByteString
data HttpResponse
HttpResponse :: HttpVersion -> Status -> Headers -> Maybe ByteString -> HttpResponse
[responseHttpVersion] :: HttpResponse -> HttpVersion
[responseStatus] :: HttpResponse -> Status
[responseHeaders] :: HttpResponse -> Headers
[responseBody] :: HttpResponse -> Maybe ByteString
-- | Transform a reference into a Just value if is inline, Nothing,
-- otherwise
refToMaybe :: Referenced a -> Maybe a
-- | A description of a particular test run.
data TestReport
TestReport :: Seed -> Operation -> HttpRequest -> Maybe HttpResponse -> ValidationResult -> TestReport
[reportSeed] :: TestReport -> Seed
[reportOperation] :: TestReport -> Operation
[reportRequest] :: TestReport -> HttpRequest
[reportResponse] :: TestReport -> Maybe HttpResponse
[reportResult] :: TestReport -> ValidationResult
-- | Predicate that tells whether or not a report is of a successful
-- validation
isSuccessful :: TestReport -> Bool
isFailure :: TestReport -> Bool
-- | Write a report file containing a header description about the
-- Swagger schema, then a section about each Operation, how
-- many tests were performed, general stats (# failuressuccesses) and
-- requestresponse details for failures.
writeReportFile :: FilePath -> NormalizedSwagger -> [TestReport] -> IO ()
-- | Write a report file containing just a single error message. This is to
-- be used if we find an error before being able to run any test (parsing
-- schema, etc.)
writeErrorReportFile :: FilePath -> String -> IO ()
-- | Run n tests for a Swagger schema
runTests :: NormalizedSwagger -> Int -> Size -> IO [TestReport]
-- | Parse a HttpResponse from ByteString
parseResponse :: ByteString -> Either String HttpResponse
type ValidationResult = Either String ()
-- | Validate a response, from a particular operation id, (encoded in a
-- byte-string) against a Swagger schema
validateResponseBytes :: ByteString -> NormalizedSwagger -> OperationId -> ValidationResult
-- | Validate a response, from a particular operation against a Swagger
-- schema
validateResponseWithOperation :: HttpResponse -> NormalizedSwagger -> Operation -> ValidationResult
-- | Validate a response, from a particular operation id against a Swagger
-- schema
validateResponse :: HttpResponse -> NormalizedSwagger -> OperationId -> ValidationResult