Skip to content

ehuelsmann/OpenAPIValidators

 
 

Repository files navigation

OpenAPI Validators

build status style codecov MIT License contributions welcome

Note This project is a fork from the openapi-library project because that project is not maintained at the moment. This project contains updates and security fixes, but ideally will be merged back into that project, as soon as it's maintained again.

Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec.

Problem 😕

If your server's behaviour doesn't match your API documentation, then you need to correct your server, your documentation, or both. The sooner you know the better.

Solution 😄

These test plugins let you automatically test whether your server's behaviour and documentation match. They extend Jest and Chai to support the OpenAPI standard for documenting REST APIs. In your JavaScript tests, you can simply assert expect(responseObject).toSatisfyApiSpec()

downloads npm

downloads npm

Installing (scoped packages)

These packages are published to the public npm registry under the scope @ehuelsmann:

  • @ehuelsmann/jest-openapi
  • @ehuelsmann/chai-openapi-response-validator
  • @ehuelsmann/openapi-validator

No authentication or token is required to install.

npm

npm install --save-dev @ehuelsmann/jest-openapi
# or
npm install --save-dev @ehuelsmann/chai-openapi-response-validator

Yarn

yarn add --dev @ehuelsmann/jest-openapi
# or
yarn add --dev @ehuelsmann/chai-openapi-response-validator

Note: These are published as scoped packages, so import using the scoped name — for example:

  • import jestOpenAPI from '@ehuelsmann/jest-openapi'
  • import chaiOpenAPI from '@ehuelsmann/chai-openapi-response-validator'

Both packages ship as ESM-first (preferred) with a CommonJS fallback, supporting:

// ESM / TypeScript
import jestOpenAPI from '@ehuelsmann/jest-openapi';
import chaiOpenAPI from '@ehuelsmann/chai-openapi-response-validator';

// CommonJS
const jestOpenAPI = require('@ehuelsmann/jest-openapi').default;
const chaiOpenAPI = require('@ehuelsmann/chai-openapi-response-validator').default;

Contributors ✨


Richard Waller

🚧 💻 📖 👀

Jonny Spruce

💻 📖 👀

Alex Dobeck

💻 🐛

Ben Guthrie

💻 🐛

Martijn Vegter

💻

Ludek

💻 🐛

Tommy Giardina

💻 🐛

Oleksandr Khotemskyi

📖

Amit Keinan

💻

DetachHead

🐛

Kristoffer Karlsson

📖

About

Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 99.0%
  • JavaScript 1.0%