
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
@seriousme/openapi-schema-validator
Advanced tools
Validate OpenApi specifications against their JSON schema
A JSON schema validator for OpenAPI specifications, it currently supports:
npm i @seriousme/openapi-schema-validator --save
import Validator from "@seriousme/openapi-schema-validator";
console.log(Validator.supportedVersions.has("3.1"));
// prints true
const validator = new Validator();
const res = await validator.validate("./petstore.json");
if (res.valid) {
console.log("Specification matches schema for version", validator.version);
const schema = validator.resolveRefs();
// schema now contains a Javascript object containing the dereferenced schema
} else {
console.log("Specification does not match Schema");
console.log(res.errors);
}
new Validator(ajvOptions)
<instance>.validate(specification)
<instance>.version
<instance>.resolveRefs(options)
Validator.supportedVersions
new Validator(ajvOptions)
The constructor returns an instance of Validator
.
By passing an ajv options object it is possible to influence the behavior of the AJV schema validator.
<instance>.validate(specification)
This function tries to validata a specification against the OpenApi schemas. specification
can be one of:
External references are not automatically resolved so you need to inline them yourself if required. The result is an object:
{
valid: <boolean>,
errors: <any> // only present if valid is false
}
<instance>.version
If validation is succesfull this will return the openApi version found e.g. ("2.0","3.0","3.1). The openApi specification only specifies major/minor versions as separate schemas. So "3.0.3" results in "3.0".
<instance>.resolveRefs(options)
This function tries to resolve all internal references. External references are not automatically resolved so you need to inline them yourself if required. By default it will use the last specification passed to <instance>.validate()
but you can explicity pass a specification by passing {specification:<object>}
as options.
The result is an object
where all references have been resolved.
Resolution of references is shallow
This should normally not be a problem for this use case.
Validator.supportedVersions
This static property returns the OpenApi versions supported by this package as a Set
. If present, the result of <instance>.version
is a member of this Set
.
Licensed under the MIT license
[v1.0.3] 10-05-2021
FAQs
Validate OpenApi specifications against their JSON schema
The npm package @seriousme/openapi-schema-validator receives a total of 39,109 weekly downloads. As such, @seriousme/openapi-schema-validator popularity was classified as popular.
We found that @seriousme/openapi-schema-validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.