Dredd is an HTTP API testing framework designed to validate API description documents, such as OpenAPI (formerly Swagger) and API Blueprint, against a running backend API. It ensures that the API implementation adheres to its documented contract by generating requests based on the specification and comparing the actual responses to the described expectations. The current stable version is 14.1.0, with ongoing development and a release cadence that includes major version updates for parser improvements, schema validation, and dependency management. Dredd's key differentiators include its strong focus on documentation-driven testing, support for various API description formats, and its extensible hook system. This hook system allows developers to write custom test logic in multiple languages (including Node.js), enabling advanced scenarios like authentication, data setup, and cleanup, making it a valuable tool for integration into CI/CD pipelines for continuous contract compliance.
npm install dreddVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up Dredd to test a simple Express.js API against an OpenAPI 3.0 specification. It includes the API description, the API server code, Dredd's configuration file, and the command to execute the tests.
Update your API description documents to use JSON Schema Draft V4 or newer (Draft 6 or Draft 7 are also supported).
Migrate your API description documents to JSON Schema Draft V4 or newer to avoid future breaking changes.
Be aware that even if your OpenAPI 2.0 document implies an older JSON Schema draft, Dredd will validate against Draft V4. Adjust your expectations or manually specify a newer draft in your schema if possible.
Use `npm install dredd@stable` or `npm install dredd@<version>` (e.g., `npm install dredd@14`) in your CI configuration to ensure consistent test runs.
To test non-2xx responses, you must explicitly activate them using Dredd hooks. Refer to the 'Multiple Requests and Responses' how-to guide in the Dredd documentation.
Ensure your `blueprint` or `path` in `dredd.yml` points to a valid API description file (OpenAPI/API Blueprint). Verify the API description document contains valid paths and operations. Use `dredd --names` to list detected transactions and debug path matching.
Double-check the `hookfiles` path in your `dredd.yml` configuration or the `--hookfiles` CLI option. Ensure the file exists and the path is correct relative to where you are running Dredd.
Use a linter or validator for your specific API description format (e.g., `swagger-cli validate <file>` for OpenAPI or an API Blueprint linter) to identify and fix syntax errors in your document.