Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Gi60s/openapi-enforcer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 11e77301c5a4bf64369ce36d7a35c1496a9db095
Choose a base ref
...
head repository: Gi60s/openapi-enforcer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 72e13f2b91eef7fc8a6346bb12a485b675236472
Choose a head ref
  • 4 commits
  • 5 files changed
  • 2 contributors

Commits on Dec 5, 2022

  1. Copy the full SHA
    877eabd View commit details

Commits on Dec 6, 2022

  1. Merge pull request #149 from gaetano-guerriero/fix-schema-not-validation

    Fix validation of a not subschema
    Gi60s authored Dec 6, 2022
    Copy the full SHA
    922c7b1 View commit details
  2. 1.22.2

    Gi60s committed Dec 6, 2022
    Copy the full SHA
    9d3a050 View commit details
  3. update changelog

    Gi60s committed Dec 6, 2022
    Copy the full SHA
    72e13f2 View commit details
Showing with 28 additions and 4 deletions.
  1. +10 −0 CHANGELOG.md
  2. +2 −2 package-lock.json
  3. +1 −1 package.json
  4. +1 −1 src/schema/validate.js
  5. +14 −0 test/definition.schema.test.js
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.22.2

### Fixed

- **Fix Validation of `not` Sub Schema**

Any time a schema had the property `not`, it was not validating correctly.
This code for this fix, including tests, is thanks to
[gaetano-guerriero](https://github.com/gaetano-guerriero).

## 1.22.1

### Fixed
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openapi-enforcer",
"version": "1.22.1",
"version": "1.22.2",
"description": "Library for validating, parsing, and formatting data against open api schemas.",
"main": "index.js",
"directories": {
2 changes: 1 addition & 1 deletion src/schema/validate.js
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ function runValidate(exception, map, schema, originalValue, options) {

} else if (schema.not) {
const child = Exception('');
runValidate(child, map, schema, value, options);
runValidate(child, map, schema.not, value, options);
if (!child.hasException) {
exception.message('Value should not validate against schema');
}
14 changes: 14 additions & 0 deletions test/definition.schema.test.js
Original file line number Diff line number Diff line change
@@ -4786,6 +4786,20 @@ describe('definition/schema', () => {

});

describe('not', () => {
it('not valid', () => {
const [ schema ] = Enforcer.v3_0.Schema({not: {type: 'string' }});
const errors = schema.validate('abc');
expect(errors).to.match(/Value should not validate against schema/i);
});

it('valid', () => {
const [ schema ] = Enforcer.v3_0.Schema({not: {type: 'string' }});
const errors = schema.validate(true);
expect(errors).to.be.undefined;
});
});

});

describe('hooks', function () {