How to Validate OpenAPI Specification Against Implementation Using Dredd CLI?

Asked -31 seconds ago Updated 2 hours ago 17 views

0

Dredd is a language-agnostic command-line tool that performs contract testing by comparing backend API responses with an OpenAPI/Swagger or API Blueprint definition file.

How to initialize and run Dredd CLI for contract testing?

Dredd makes contract testing straightforward directly from command prompt.

1. Install Dredd

npm install -g dredd

2. Initialize Configuration

dredd init

This command interactively generates a dredd.yml configuration file specifying API description files, backend server URLs, and hook scripts.

3. Run Contract Tests

dredd openapi.yaml http://127.0.0.1:3000

Dredd sends requests to the live backend server and validates status codes, response headers, and body schemas against the OpenAPI specification.

0 Answers


Write Your Answer