Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

### `1.0.5` 21-02-2020
- Bump version of @hapi/joi used in tests
- Update README.md to reflect accurate usage of @hapi/joi
- Fix vulnerabilities
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ npm i oas2joi

```
const oas2joi = require('oas2joi');
const Joi = require('@hapi/joi');

const schemas = oas2joi('./path/to/open-api.yml');
const schemas = oas2joi('./test/oas/open-api.yml');

const someObject = {
foo: 'bar'
demoRes1: 'A',
demoRes2: 'baz'
};

const { error } = Joi.validate(someObject, schemas.someObject);
const { error } = schemas.response.validate(someObject));
```
130 changes: 74 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oas2joi",
"version": "1.0.4",
"version": "1.0.5",
"description": "Create a Joi schema from an Open API Specification",
"main": "index.js",
"scripts": {
Expand All @@ -19,7 +19,7 @@
"js-yaml": "^3.10.0"
},
"devDependencies": {
"@hapi/joi": "^15.0.3",
"@hapi/joi": "^17.1.0",
"jest": "^24.8.0",
"pre-commit": "^1.2.2"
},
Expand Down
10 changes: 5 additions & 5 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ describe('OpenAPI parser', () => {
demoRes2: 'abc123'
};

const { error } = Joi.validate(obj, schemas.response);
const { error } = schemas.response.validate(obj);
expect(error).toEqual(null);
});

it('should allow the non-required properties to be missing', () => {
const obj = {};

const { error } = Joi.validate(obj, schemas.optional);
const { error } = schemas.optional.validate(obj);
expect(error).toEqual(null);
});

Expand All @@ -38,7 +38,7 @@ describe('OpenAPI parser', () => {
demoErr1: 'abc123'
};

const { error } = Joi.validate(obj, schemas.error);
const { error } = schemas.error.validate(obj);
expect(error).toEqual(null);
});
});
Expand All @@ -50,7 +50,7 @@ describe('OpenAPI parser', () => {
demoRes2: 'abc123',
};

const { error } = Joi.validate(obj, schemas.response);
const { error } = schemas.response.validate(obj);
expect(error.details[0].message).toEqual(
'"demoRes1" must be one of [A, B, C]');
});
Expand All @@ -62,7 +62,7 @@ describe('OpenAPI parser', () => {
demoErr1: 'abc123'
};

const { error } = Joi.validate(obj, schemas.response);
const { error } = schemas.response.validate(obj);
expect(error.details[0].message).toEqual(
'"demoErr1" is not allowed');
});
Expand Down