The composting worm. Composts your contract specification and tests and confirms that the contract specification is being followed.
RedWiggler has 3 main components:
-
EndpointSpecifications: defines the endpoint contract. Defined from the API documentation
-
EndpointCall: An instance of a request/response to the service to be matched against the EndpointSpecification
-
ReportProcessor: Takes the result of the analysis and generates output (such as an html page)
Currently, the jars are only available on bintray.
repositories {
jCenter()
}
dependencies {
compile groupId: 'com.nike.redwiggler', artifactId: 'redwiggler-core_2.12', verson: redwigglerVersion
compile groupId: 'com.nike.redwiggler', artifactId: 'redwiggler-swagger_2.12', verson: redwigglerVersion
compile groupId: 'com.nike.redwiggler', artifactId: 'redwiggler-reports-html_2.12', verson: redwigglerVersion
compile groupId: 'com.nike.redwiggler', artifactId: 'redwiggler-restassured_2.12', verson: redwigglerVersion
}
Resolvers += Resolver.jcenterRepo
libraryDependencies ++= Seq("core", "swagger", "reports-html", "restassured")
.map(library => "com.nike.redwiggler" %% library % redwigglerVersion)
import com.nike.redwiggler.core._
import com.nike.redwiggler.swagger._
import com.nike.redwiggler.html._
val swagger = SwaggerEndpointSpecificationProvider(
"""
|swagger: "2.0"
|paths:
| /:
| get:
| description: Gets Item
| responses:
| 200:
| schema:
| properties:
| id:
| type: string
""".stripMargin)
import java.io._
val requestDir = File.createTempFile("redwiggler", "requests")
requestDir.delete()
requestDir.mkdir()
val requests = new GlobEndpointCallProvider(requestDir, ".*.json")
val htmlReportFile = File.createTempFile("redwiggler", ".html")
val htmlRender = HtmlReportProcessor(htmlReportFile)
Redwiggler(callProvider = requests, specificationProvider = swagger, reportProcessor = htmlRender)
htmlReportFile.exists() should be(true)
- Supports swagger 2.0
- Compares every call to every schema and sees if there's a match to path, code and request schema
- 5 types of outcome:
- schema validation fails
- call not matched by schema
- schema is not covered
- schema validation passes
- call is matched by multiple schemas
- Outputs a report in html format