1- # OpenAPI Validators
1+ # OASprey
22
33Use Jest to assert that HTTP responses satisfy an OpenAPI spec.
44
@@ -9,7 +9,7 @@ to correct your server, your documentation, or both. The sooner you know the bet
99
1010## Solution 😄
1111
12- This plugin lets you automatically test whether your server's behaviour and
12+ This plugin lets you automatically test whether your server's behavior and
1313documentation match. It adds Jest matchers that support the
1414[ OpenAPI standard] ( https://swagger.io/docs/specification/about/ ) for
1515documenting REST APIs. In your JavaScript tests, you can simply assert
@@ -32,27 +32,31 @@ Features:
3232[ npm] ( http://npmjs.org )
3333
3434``` bash
35- npm install --save-dev jest-openapi
35+ npm install --save-dev oasprey
3636```
3737
3838[ yarn] ( https://yarnpkg.com/ )
3939
4040``` bash
41- yarn add --dev jest-openapi
41+ yarn add --dev oasprey
4242```
4343
4444## Importing
4545
4646ES6 / TypeScript
4747
4848``` typescript
49- import jestOpenAPI from ' jest-openapi' ;
49+ import { loadSpec } from ' oasprey' ;
50+ // or
51+ import loadSpec from ' oasprey' ;
5052```
5153
5254CommonJS / JavaScript
5355
5456``` javascript
55- const jestOpenAPI = require (' jest-openapi' ).default ;
57+ const { loadSpec } = require (' oasprey' );
58+ // or
59+ const loadSpec = require (' oasprey' ).default ;
5660```
5761
5862## Usage
@@ -63,10 +67,10 @@ const jestOpenAPI = require('jest-openapi').default;
6367
6468``` javascript
6569// Import this plugin
66- import jestOpenAPI from ' jest-openapi ' ;
70+ import { loadSpec } from ' oasprey ' ;
6771
6872// Load an OpenAPI file (YAML or JSON) into this plugin
69- jestOpenAPI (' path/to/openapi.yml' );
73+ loadSpec (' path/to/openapi.yml' );
7074
7175// Write your test
7276describe (' GET /example/endpoint' , () => {
@@ -173,11 +177,11 @@ The '200' response defined for endpoint 'GET /example/endpoint' in API spec: {
173177
174178` ` ` javascript
175179// Import this plugin and the function you want to test
176- import jestOpenAPI from 'jest-openapi ';
180+ import { loadSpec } from 'oasprey ';
177181import { functionToTest } from 'path/to/your/code';
178182
179183// Load an OpenAPI file (YAML or JSON) into this plugin
180- jestOpenAPI ('path/to/openapi.yml');
184+ loadSpec ('path/to/openapi.yml');
181185
182186// Write your test
183187describe('functionToTest()', () => {
@@ -281,7 +285,7 @@ The 'ExampleSchemaObject' schema in API spec: {
281285
282286` ` ` javascript
283287// Import this plugin
284- import jestOpenAPI from 'jest-openapi ';
288+ import { loadSpec } from 'oasprey ';
285289
286290// Get an object representing your OpenAPI spec
287291const openApiSpec = {
@@ -311,7 +315,7 @@ const openApiSpec = {
311315};
312316
313317// Load that OpenAPI object into this plugin
314- jestOpenAPI (openApiSpec);
318+ loadSpec (openApiSpec);
315319
316320// Write your test
317321describe('GET /example/endpoint', () => {
@@ -331,7 +335,7 @@ describe('GET /example/endpoint', () => {
331335
332336` ` ` javascript
333337// Import this plugin and an HTTP client (e.g. axios)
334- import jestOpenAPI from 'jest-openapi ';
338+ import { loadSpec } from 'oasprey ';
335339import axios from 'axios';
336340
337341// Write your test
@@ -340,7 +344,7 @@ describe('GET /example/endpoint', () => {
340344 beforeAll(async () => {
341345 const response = await axios.get('url/to/openapi/spec');
342346 const openApiSpec = response.data; // e.g. { openapi: '3.0.0', ... };
343- jestOpenAPI (openApiSpec);
347+ loadSpec (openApiSpec);
344348 });
345349
346350 it('should satisfy OpenAPI spec', async () => {
@@ -357,11 +361,13 @@ describe('GET /example/endpoint', () => {
357361
358362# # Origin and Changes
359363
360- This package is forked from [OpenAPIValidators](https://github.com/openapi-library/OpenAPIValidators).
364+ This package is a hard fork from [OpenAPIValidators](https://github.com/openapi-library/OpenAPIValidators).
361365We have :
362366
363367- Updated and removed dependencies to modern, supported tooling
364368- Removed support for Chai and SuperAgent
369+ - Renamed the package to OASprey for ongoing maintenance
370+ - Renamed the `jestOpenAPI()` function to `loadSpec()`
365371
366372Otherwise, we have preserved the original functionality as-is. All credit to
367373the folks who contributed to that package!
0 commit comments