You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple Chai support for asserting that HTTP responses satisfy an OpenAPI spec.
17
19
18
-
## Problem
20
+
## Problem 😕
19
21
20
22
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.
21
23
22
-
## Solution
24
+
## Solution 😄
23
25
24
26
This plugin lets you automatically test whether your server's behaviour and documentation match. It extends the [Chai Assertion Library](https://www.chaijs.com/) to support the [OpenAPI standard](https://swagger.io/docs/specification/about/) for documenting REST APIs. In your JavaScript tests, you can simply assert [`expect(responseObject).to.satisfyApiSpec`](#in-api-tests-validate-the-status-and-body-of-http-responses-against-your-openapi-spec)
25
27
26
28
Features:
29
+
27
30
- Validates the status and body of HTTP responses against your OpenAPI spec [(see example)](#in-api-tests-validate-the-status-and-body-of-http-responses-against-your-openapi-spec)
28
31
- Validates objects against schemas defined in your OpenAPI spec [(see example)](#in-unit-tests-validate-objects-against-schemas-defined-in-your-OpenAPI-spec)
29
32
- Load your OpenAPI spec just once in your tests (load from a filepath or object)
@@ -35,21 +38,24 @@ Features:
35
38
- Bundled with a TypeScript Declaration File for [use in TypeScript projects](#using-this-plugin-in-a-typescript-project)
36
39
- Use in [Mocha](#usage), [Jest](https://github.com/RuntimeTools/OpenAPIValidators/tree/master/packages/jest-openapi#readme) and other test runners
37
40
38
-
## Contributing
41
+
## Contributing ✨
39
42
40
43
If you've come here to help contribute - thanks! Take a look at the [contributing](https://github.com/RuntimeTools/OpenAPIValidators/blob/master/CONTRIBUTING.md) docs to get started.
41
44
42
45
## Installation
46
+
43
47
This is an addon plugin for the [Chai Assertion Library](http://chaijs.com). Install via [npm](http://npmjs.org).
You don't need to `npm install --save-dev @types/chai-openapi-response-validator` because we bundle our TypeScript Definition file into this package (see `index.d.ts`).
373
+
374
+
You don't need to `npm install --save-dev @types/chai-openapi-response-validator` because we [bundle our TypeScript Definition file into this package](https://github.com/RuntimeTools/OpenAPIValidators/blob/master/packages/chai-openapi-response-validator/index.d.ts).
366
375
367
376
#### Importing
377
+
368
378
1. Make sure your `tsconfig.json` includes:
379
+
369
380
```javascript
370
381
{
371
382
"compilerOptions": {
372
383
esModuleInterop: true,
373
384
}
374
385
}
375
386
```
387
+
376
388
2. Import like this:
389
+
377
390
```javascript
378
391
import chai from 'chai';
379
392
import chaiResponseValidator from 'chai-openapi-response-validator';
0 commit comments