Convert Figma logo to code with AI

apiaryio logodredd

Language-agnostic HTTP API Testing Tool

4,179
278
4,179
259

Top Related Projects

Swagger tools for documenting API's built on ASP.NET Core

4,272

Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

OpenAPI 3.0 (and Swagger v2) implementation for Go (parsing, converting, validation, and more)

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.

6,862

Newman is a command-line collection runner for Postman

Quick Overview

Dredd is an HTTP API testing framework that validates API documentation written in API Blueprint or OpenAPI (formerly Swagger) against the actual implementation. It ensures that your API documentation stays up-to-date and accurate by running automated tests based on the documentation.

Pros

  • Supports multiple API description formats (API Blueprint and OpenAPI)
  • Integrates with various CI/CD tools for automated testing
  • Provides detailed test reports and output
  • Allows for custom test hooks and extensions

Cons

  • Learning curve for setting up and configuring tests
  • Can be slow for large API documentations
  • Limited support for complex authentication scenarios
  • May require additional setup for certain edge cases

Code Examples

  1. Basic Dredd configuration in JavaScript:
module.exports = {
  server: 'npm start',
  endpoint: 'http://localhost:3000',
  path: './api-description.apib',
};
  1. Running Dredd with custom hooks:
const hooks = require('hooks');

hooks.before('User > Create', (transaction) => {
  transaction.request.headers['Content-Type'] = 'application/json';
});

hooks.after('User > List', (transaction) => {
  console.log('User list retrieved successfully');
});
  1. Using Dredd with OpenAPI 3.0:
openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      responses:
        '200':
          description: Successful response
          content:
            application/json:    
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'

Getting Started

  1. Install Dredd:
npm install -g dredd
  1. Create an API description file (e.g., api.apib or openapi.yaml)

  2. Run Dredd:

dredd api.apib http://api.example.com
  1. View the test results in the console output

For more advanced usage, create a dredd.yml configuration file and customize your tests using hooks.

Competitor Comparisons

Swagger tools for documenting API's built on ASP.NET Core

Pros of Swashbuckle.AspNetCore

  • Seamless integration with ASP.NET Core, making it easier to generate Swagger documentation for .NET applications
  • Provides a UI for exploring and testing API endpoints directly within the application
  • Supports attribute-based configuration, allowing developers to customize documentation through code annotations

Cons of Swashbuckle.AspNetCore

  • Limited to ASP.NET Core applications, whereas Dredd supports multiple languages and frameworks
  • Focuses primarily on documentation generation, while Dredd offers more comprehensive API testing capabilities
  • May require additional setup for complex scenarios or custom documentation needs

Code Comparison

Swashbuckle.AspNetCore:

services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
});

Dredd:

hooks:
  - ./hooks.js
language: nodejs

Both tools serve different primary purposes. Swashbuckle.AspNetCore excels at generating Swagger documentation for ASP.NET Core applications, while Dredd focuses on API testing and validation across multiple platforms. The choice between them depends on the specific needs of the project, such as the development framework, desired documentation format, and testing requirements.

4,272

Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

Pros of Prism

  • Supports multiple API specification formats (OpenAPI, Postman Collections)
  • Offers dynamic mocking capabilities with customizable responses
  • Provides a user-friendly CLI and HTTP server for easy integration

Cons of Prism

  • Less mature and may have fewer community contributions compared to Dredd
  • Limited support for certain advanced testing scenarios
  • May require additional setup for complex validation cases

Code Comparison

Dredd (JavaScript):

const Dredd = require('dredd');
const dredd = new Dredd(configuration);

dredd.run((err, stats) => {
  console.log(stats);
});

Prism (CLI):

prism mock api.yaml
prism proxy api.yaml http://api.example.com
prism validate api.yaml

Key Differences

  • Dredd focuses on API contract testing, while Prism emphasizes mocking and validation
  • Prism offers a more versatile toolset for API development workflows
  • Dredd provides more extensive reporting and integration with CI/CD pipelines
  • Prism's dynamic mocking capabilities make it suitable for frontend development and testing

Use Cases

  • Choose Dredd for comprehensive API contract testing and CI/CD integration
  • Opt for Prism when you need flexible mocking, validation, and proxy capabilities during API development

OpenAPI 3.0 (and Swagger v2) implementation for Go (parsing, converting, validation, and more)

Pros of kin-openapi

  • Focuses on parsing and validating OpenAPI specifications, offering a more specialized toolset
  • Written in Go, providing better performance and easier integration with Go-based projects
  • Actively maintained with regular updates and contributions

Cons of kin-openapi

  • Limited to OpenAPI specification parsing and validation, lacking the API testing capabilities of Dredd
  • Requires more manual setup and integration for comprehensive API testing workflows
  • Less extensive documentation and community support compared to Dredd

Code Comparison

kin-openapi (Go):

swagger, err := openapi3.NewSwaggerLoader().LoadSwaggerFromFile("openapi.yaml")
if err != nil {
    log.Fatal(err)
}

Dredd (JavaScript):

const Dredd = require('dredd');
const dredd = new Dredd(configuration);
dredd.run((err, stats) => {
    // Handle test results
});

Summary

kin-openapi is a Go-based library focused on OpenAPI specification parsing and validation, offering better performance and integration with Go projects. However, it lacks the comprehensive API testing features of Dredd and requires more manual setup. Dredd, on the other hand, provides a more complete API testing solution but may have lower performance and is less suitable for Go-based projects.

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

Pros of openapi-generator

  • Supports a wide range of programming languages and frameworks for code generation
  • Generates client SDKs, server stubs, and documentation from OpenAPI specifications
  • Active community with frequent updates and improvements

Cons of openapi-generator

  • Primarily focused on code generation, not API testing
  • May require additional setup and configuration for specific use cases
  • Learning curve can be steeper due to its extensive features and options

Code comparison

dredd:

const Dredd = require('dredd');
const dredd = new Dredd(options);
dredd.run((err, stats) => {
  // Handle test results
});

openapi-generator:

openapi-generator generate -i spec.yaml -g java -o ./generated

Key differences

  • dredd is primarily an API testing tool, while openapi-generator focuses on code generation
  • dredd provides a more straightforward approach to API contract testing
  • openapi-generator offers more flexibility in terms of output formats and languages
  • dredd is better suited for continuous integration and automated testing workflows
  • openapi-generator is more useful for jumpstarting API development across multiple platforms

Both tools serve different purposes in the API development lifecycle. dredd excels at validating API implementations against their specifications, while openapi-generator streamlines the process of creating client SDKs and server stubs across various programming languages.

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.

Pros of Swagger Codegen

  • Generates client libraries, server stubs, and documentation for multiple languages and frameworks
  • Supports a wider range of API specification formats (OpenAPI/Swagger, RAML, etc.)
  • More extensive customization options for generated code

Cons of Swagger Codegen

  • Steeper learning curve due to its complexity and numerous configuration options
  • May generate unnecessary or bloated code for simpler API projects
  • Requires more setup and configuration compared to Dredd's simpler approach

Code Comparison

Dredd (JavaScript):

const Dredd = require('dredd');
const dredd = new Dredd(configuration);

dredd.run((err, stats) => {
  // Handle test results
});

Swagger Codegen (Java):

CodegenConfig config = new JavaClientCodegen();
ClientOptInput input = new ClientOptInput().config(config);
DefaultGenerator generator = new DefaultGenerator();
generator.opts(input).generate();

Summary

Swagger Codegen is a powerful tool for generating API clients, servers, and documentation across multiple languages, while Dredd focuses on API testing and validation. Swagger Codegen offers more flexibility and customization but comes with increased complexity, whereas Dredd provides a simpler approach to API testing with less setup required.

6,862

Newman is a command-line collection runner for Postman

Pros of Newman

  • Seamless integration with Postman, allowing easy use of existing Postman collections
  • Supports a wide range of authentication methods out-of-the-box
  • Extensive reporting options, including JUnit and HTML formats

Cons of Newman

  • Limited support for API specification formats compared to Dredd
  • Less flexibility in test script customization
  • Primarily focused on request-response testing, with less emphasis on contract testing

Code Comparison

Newman:

newman.run({
    collection: require('./collection.json'),
    environment: require('./environment.json'),
    reporters: ['cli', 'htmlextra']
}, function (err) {
    if (err) { throw err; }
    console.log('collection run complete!');
});

Dredd:

const Dredd = require('dredd');
const dredd = new Dredd(options);

dredd.run((err, stats) => {
    if (err) { throw err; }
    console.log('API Blueprint validation complete!');
});

Both Newman and Dredd are popular API testing tools, but they cater to different needs. Newman excels in leveraging existing Postman collections and provides rich reporting options, while Dredd focuses more on API specification validation and contract testing. The choice between them depends on your specific testing requirements and workflow preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Dredd — HTTP API Testing Framework

npm version Build Status Build Status Documentation Status Known Vulnerabilities

Dredd - HTTP API Testing Framework

Dredd is a language-agnostic command-line tool for validating API description document against backend implementation of the API.

Dredd reads your API description and step by step validates whether your API implementation replies with responses as they are described in the documentation.

Supported API Description Formats

Supported Hooks Languages

Dredd supports writing hooks — a glue code for each test setup and teardown. Following languages are supported:

Supported Systems

Installation

$ npm install -g dredd

Quick Start

  1. Create an API Blueprint file called api-description.apib. Follow tutorial at API Blueprint website or just take one of the ready-made examples.

  2. Run interactive configuration:

    $ dredd init
    
  3. Run Dredd:

    $ dredd
    
  4. To see how to use all Dredd's features, browse the full documentation.

Howtos, Tutorials, Blogposts (3rd party)

NPM DownloadsLast 30 Days