All Projects → earldouglas → Swagger Test

earldouglas / Swagger Test

Licence: mit
Specification-driven REST API testing

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Swagger Test

Swagger Coverage
Tool which generates full picture of coverage of API tests based on OAS 2 (Swagger)
Stars: ✭ 89 (-12.75%)
Mutual labels:  swagger
Swurg
Parse OpenAPI documents into Burp Suite for automating OpenAPI-based APIs security assessments (approved by PortSwigger for inclusion in their official BApp Store).
Stars: ✭ 94 (-7.84%)
Mutual labels:  swagger
Springboot Templates
springboot和dubbo、netty的集成,redis mongodb的nosql模板, kafka rocketmq rabbit的MQ模板, solr solrcloud elasticsearch查询引擎
Stars: ✭ 100 (-1.96%)
Mutual labels:  swagger
Openapi.net.odata
Generates OpenAPI document from OData CSDL
Stars: ✭ 90 (-11.76%)
Mutual labels:  swagger
Swagger Scala Module
Swagger support for scala
Stars: ✭ 93 (-8.82%)
Mutual labels:  swagger
Node Typescript Mongodb
node js typescript mongodb express generator yo
Stars: ✭ 96 (-5.88%)
Mutual labels:  swagger
Django Rest Swagger Docs
Beginners approach to Django Rest Swagger
Stars: ✭ 86 (-15.69%)
Mutual labels:  swagger
Swagger Express Ts
Generate and serve swagger.json
Stars: ✭ 102 (+0%)
Mutual labels:  swagger
Swagger Merger
🔗 Merge multiple swagger files into a swagger file, support JSON/YAML.
Stars: ✭ 94 (-7.84%)
Mutual labels:  swagger
Koa Oai Router
Koa Router, based on OpenAPI, Swagger and Json Schema.
Stars: ✭ 97 (-4.9%)
Mutual labels:  swagger
Go Tgbot
Golang telegram bot API wrapper, session-based router and middleware
Stars: ✭ 90 (-11.76%)
Mutual labels:  swagger
Api Client Generator
Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
Stars: ✭ 92 (-9.8%)
Mutual labels:  swagger
Appy Backend
A user system to bootstrap your app.
Stars: ✭ 96 (-5.88%)
Mutual labels:  swagger
Swagger To Flowtype
Generate Flow types from swagger file
Stars: ✭ 89 (-12.75%)
Mutual labels:  swagger
Apifuzzer
Fuzz test your application using your OpenAPI or Swagger API definition without coding
Stars: ✭ 101 (-0.98%)
Mutual labels:  swagger
Aspnetcore Ddd
Full ASP.NET Core 3.1 LTS application with DDD, CQRS and Event Sourcing
Stars: ✭ 88 (-13.73%)
Mutual labels:  swagger
Swaggman
OpenAPI Spec SDK and Converter for OpenAPI 3.0 and 2.0 Specs to Postman 2.0 Collections. Example RingCentral spec included.
Stars: ✭ 94 (-7.84%)
Mutual labels:  swagger
Swagger Combine
Combines multiple Swagger schemas into one dereferenced schema.
Stars: ✭ 102 (+0%)
Mutual labels:  swagger
Swagger Github Pages
How to host Swagger API documentation with GitHub Pages
Stars: ✭ 102 (+0%)
Mutual labels:  swagger
Kaizen Openapi Editor
Eclipse Editor for the Swagger-OpenAPI Description Language
Stars: ✭ 97 (-4.9%)
Mutual labels:  swagger

Specification-driven REST API testing

Build Status Coverage Status

Quick start

To run swagger-test without writing any JavaScript, install the CLI:

$ npm install -g swagger-test

Then, start your server under test, and pipe your Swagger specification to swagger-test:

$ cat swagger.json | swagger-test
response did not match specification
the specification is:
{
  "status": 200,
  "headers": {
    "content-type": "application/json; charset=utf-8"
  },
  "body": {
    "greeting": "Hello, world!"
  }
}
the response was:
{
  "status": 200,
  "headers": {
    "content-type": "text/html; charset=utf-8"
  },
  "body": "Hello, world!"
}

Usage

Load the npm module:

var swaggerTest = require('swagger-test');

Parse a Swagger specification (e.g. from a Web URL, or the local file system):

var swaggerSpec = // load a Swagger specification as a JavaScript object
var xamples = swaggerTest.parse(swaggerSpec);

The xamples array contains a sequence of request/response pairs. Test them against your service:

var preq = require('preq');

describe('specification-driven tests', function () {
  xamples.forEach(function (xample) {
    it(xample.description, function() {
      return preq[xample.request.method](xample.request)
      .then(function (response) {
        assert.deepEqual(response, xample.responses[response.status]);
      });
    });
  });
});

Test generation

Tests are generated in one of two ways:

  1. Directly from the the x-amples extension to the Swagger specification
  2. Indirectly by inferring examples from the Swagger specification

Direct test specification

The x-amples extension allows explicit specification of request/response pairs:

"/pets/{id}": {
  "get": {
  ...
  "x-amples": [
    {
      "description": "short description of example; it's used as testcase description"
      "request": {
        "params": {
          "id": "fido4"
        }
      },
      "responses": {
        "200": {
          "headers": {
            "content-type": "application/json"
          }
        }
      }
    }
  ]
}

These can be specified for any operation.

Indirect test inference

For cases where an explicit examples don't need to be specified, they are inferred directly from the Swagger operation's specification.

"get": {
  "produces": [ "application/json" ],
  "responses": {
    "200": {
      "description": "Returns all the pets"
    }
  }
}

To enable indirect test inference, set inferXamples to true in the options argument to parse():

var xamples = swaggerTest.parse(spec, { inferXamples: true });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].