New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openapi-enforcer

Package Overview
Dependencies
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-enforcer - npm Package Compare versions

Comparing version 1.16.1 to 1.17.0

8

CHANGELOG.md

@@ -7,2 +7,10 @@ # Change Log

## 1.17.0
### Added
- **Examples Warn of Additional Properties**
For a schema, the default behavior of an object is to allow additional properties. This can be problematic when examples have additional properties that the schema does not define. Now there is a global config option `Enforcer.config.examplesWarnAdditionalProperty` that defaults to `true` and will warn of examples with additional properties. To disable this behavior set the global config property to `false`.
## 1.16.1

@@ -9,0 +17,0 @@

1

index.js

@@ -90,2 +90,3 @@ /**

Enforcer.config = {
examplesWarnAdditionalProperty: true,
useNewRefParser: false

@@ -92,0 +93,0 @@ };

2

package.json
{
"name": "openapi-enforcer",
"version": "1.16.1",
"version": "1.17.0",
"description": "Library for validating, parsing, and formatting data against open api schemas.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -291,3 +291,7 @@ /**

const value = this.enum.map((value, index) => {
return deserializeAndValidate(this, child.at(index), value, { enum: false });
return deserializeAndValidate(this, child.at(index), value, {
enum: false,
escalateCodes,
skipCodes
});
});

@@ -303,3 +307,5 @@ Object.freeze(value);

// TODO: should this produce an error or a warning? It's currently set to warn.
const value = deserializeAndValidate(this, warn.at('example'), this.example, {});
const value = deserializeAndValidate(this, warn.at('example'), this.example, {
isExample: true
});
setProperty(this, 'example', freeze(value));

@@ -864,2 +870,14 @@ }

/**
*
* @param schema
* @param exception
* @param value
* @param {object} options
* @param {boolean} [options.enum] Set to false to skip enum validation.
* @param {boolean} [options.isExample] If the passed in value is an example then set this to true.
* @param {boolean} [options.maxMin] Set to false to skip max min validation.
* @param {'read', 'write} [options.readWriteMode] Set to 'read' if in read only mode or to 'write' if write only mode.
* @returns {*}
*/
function deserializeAndValidate(schema, exception, value, options) {

@@ -866,0 +884,0 @@ let error;

@@ -25,2 +25,16 @@ /**

/**
*
* @param exception
* @param map
* @param schema
* @param originalValue
* @param options
* @param {object} options
* @param {boolean} [options.enum] Set to false to skip enum validation.
* @param {boolean} [options.isExample] If the passed in value is an example then set this to true.
* @param {boolean} [options.maxMin] Set to false to skip max min validation.
* @param {'read', 'write} [options.readWriteMode] Set to 'read' if in read only mode or to 'write' if write only mode.
* @returns {*}
*/
function runValidate(exception, map, schema, originalValue, options) {

@@ -188,2 +202,7 @@ let { validate, value } = Value.getAttributes(originalValue);

runValidate(exception.at(key), map, schema.additionalProperties, value[key], options);
} else if (options.isExample) {
const enforcerConfig = require('../../').config
if (enforcerConfig.examplesWarnAdditionalProperty === true) {
exception.at(key).message('Property is an additional property');
}
}

@@ -190,0 +209,0 @@ }

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc