-- 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.1 -- | This module exposes some types that ure used across other modules of -- swagger-test. module Test.Swagger.Types -- | 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 instance GHC.Show.Show Test.Swagger.Types.HttpResponse instance GHC.Classes.Eq Test.Swagger.Types.HttpResponse instance GHC.Show.Show Test.Swagger.Types.HttpRequest instance GHC.Classes.Eq Test.Swagger.Types.HttpRequest instance Data.Aeson.Types.ToJSON.ToJSON Test.Swagger.Types.HttpRequest instance Data.Aeson.Types.ToJSON.ToJSON Test.Swagger.Types.HttpResponse instance Data.Aeson.Types.FromJSON.FromJSON Test.Swagger.Types.NormalizedSwagger -- | Exposes some functions to validate responses against a Swagger schema. -- There are four functions that can be used depending whether the -- response is parsed, if the operation is available (or just the id) module Test.Swagger.Validate -- | 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 -- | Exposes doHttpRequest, which executes the HTTP request and -- return the response. module Test.Swagger.Request -- | Executes the HTTP request and returns the HTTP response doHttpRequest :: HttpRequest -> IO HttpResponse module Test.Swagger.Print -- | 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 instance GHC.Enum.Enum Test.Swagger.Print.Format instance GHC.Enum.Bounded Test.Swagger.Print.Format instance GHC.Show.Show Test.Swagger.Print.Format -- | Exposes generateRequest, which creates a random request from a -- Swagger schema. module Test.Swagger.Gen -- | 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) module Test.Swagger.Report -- | A description of a particular test run. data TestReport TestReport :: Seed -> Operation -> HttpRequest -> HttpResponse -> ValidationResult -> TestReport [reportSeed] :: TestReport -> Seed [reportOperation] :: TestReport -> Operation [reportRequest] :: TestReport -> HttpRequest [reportResponse] :: TestReport -> HttpResponse [reportResult] :: TestReport -> ValidationResult -- | Predicate that tells whether or not a report is of a successful -- validation isSuccessful :: 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] instance GHC.Classes.Eq Test.Swagger.Report.TestReport instance GHC.Classes.Ord Test.Swagger.Report.TestReport instance Data.Aeson.Types.ToJSON.ToJSON Test.Swagger.Report.TestReport -- | Re-exports module Test.Swagger