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.13.1 to 1.13.2

8

CHANGELOG.md

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

## 1.13.2
### Fixed
- **Read / Write Required Property May Not Exist**
Fixed an error when checking for required schema properties that should not be included due to being read-only or write only.
## 1.13.1

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

2

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

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

@@ -150,4 +150,4 @@ /**

schema.required.filter(name => {
if (!options.readWriteMode) return true
const prop = properties[name]
if (!options.readWriteMode || !prop) return true
if (options.readWriteMode === 'write' && !prop.readOnly) return true

@@ -154,0 +154,0 @@ if (options.readWriteMode === 'read' && !prop.writeOnly) return true

@@ -111,2 +111,68 @@ const expect = require('chai').expect;

describe('issue-108 - attempting to validate an object without discriminator field results in exception', () => {
const def = {
openapi: '3.0.0',
info: { title: '', version: '' },
paths: {},
components: {
schemas: {
'content.text': {
type: 'object',
properties: {
type: {
type: 'string'
},
content: {
type: 'string'
}
}
},
'content.file': {
type: 'object',
properties: {
type: {
type: 'string'
},
content: {
type: 'string',
format: 'byte'
}
}
},
content: {
oneOf: [
{ $ref: '#/components/schemas/content.text' },
{ $ref: '#/components/schemas/content.file' }
],
discriminator: {
propertyName: 'type',
mapping: {
text: '#/components/schemas/content.text',
file: '#/components/schemas/content.file'
}
}
}
}
}
}
it('should validate correctly with valid discriminator property name', async () => {
const openapi = await Enforcer(def, { hideWarnings: true })
const err = openapi.components.schemas.content.validate({
type: 'text',
content: 'hello'
})
expect(err).to.equal(undefined)
})
it('should produce a valid exception with invalid discriminator property name', async () => {
const openapi = await Enforcer(def, { hideWarnings: true })
const err = openapi.components.schemas.content.validate({
type: 'audio',
content: 'hello'
})
expect(err).to.match(/Discriminator property "type" as "audio" did not map to a schema/)
})
})
});
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