@seriousme/openapi-schema-validator
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -6,2 +6,6 @@ # Changelog | ||
## [v1.1.2] 14-05-2021 | ||
### Changed | ||
- Added Node 10 support | ||
## [v1.1.1] 14-05-2021 | ||
@@ -8,0 +12,0 @@ ### Changed |
14
index.js
const Ajv = require("ajv"); | ||
const Ajv2020 = require("ajv/dist/2020.js"); | ||
const JSYaml = require("js-yaml"); | ||
const { readFile } = require("fs/promises"); | ||
const util = require("util"); | ||
const fs = require("fs"); | ||
const readFile = util.promisify(fs.readFile); | ||
const { resolve } = require("./resolve.js"); | ||
@@ -45,3 +48,3 @@ | ||
module.exports = class Validator { | ||
class Validator { | ||
constructor(ajvOptions = { strict: false, validateFormats: false }) { | ||
@@ -56,4 +59,2 @@ this.ajvOptions = ajvOptions; | ||
static supportedVersions = openApiVersions; | ||
async validate(data) { | ||
@@ -90,2 +91,5 @@ const specification = await getSpecFromData(data); | ||
} | ||
}; | ||
} | ||
Validator.supportedVersions = openApiVersions; | ||
module.exports = Validator; |
{ | ||
"name": "@seriousme/openapi-schema-validator", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Validate OpenApi specifications against their JSON schema", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,6 +19,11 @@ function escapeJsonPointer(str) { | ||
function fromEntries(iterable) { | ||
return [...iterable].reduce((obj, [key, val]) => { | ||
obj[key] = val; | ||
return obj; | ||
}, {}); | ||
} | ||
const filtered = (raw) => | ||
Object.fromEntries( | ||
Object.entries(raw).filter(([key, _]) => !pointerWords.has(key)) | ||
); | ||
fromEntries(Object.entries(raw).filter(([key, _]) => !pointerWords.has(key))); | ||
@@ -25,0 +30,0 @@ function resolveUri(uri, anchors) { |
const { test } = require("tap"); | ||
const Validator = require("../index.js"); | ||
const { readFile } = require("fs/promises"); | ||
const util = require("util"); | ||
const fs = require("fs"); | ||
const readFile = util.promisify(fs.readFile); | ||
const localFile = (fileName) => | ||
@@ -10,3 +13,2 @@ new URL(fileName, `file://${__dirname}/`).pathname; | ||
const invalidSpec = require(`./validation/invalid-spec.json`); | ||
const { resolveSchema } = require("ajv/dist/compile"); | ||
const yamlFileName = localFile(`./validation/petstore-openapi.v3.yaml`); | ||
@@ -13,0 +15,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
183416
6466