Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajv-oai

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-oai - npm Package Compare versions

Comparing version 1.1.2 to 1.1.4

lib/ajv-oai.d.ts

26

lib/ajv-oai.js

@@ -5,13 +5,21 @@ const Ajv = require('ajv');

function AjvOAI(optsIn) {
const opts = Object.assign({
schemaId: 'id',
format: 'full',
coerceTypes: true,
unknownFormats: 'ignore',
useDefaults: true,
}, optsIn);
function AjvOAI({ metaSchema = 'json-schema-draft-04', ...optsIn } = {}) {
const opts = Object.assign(
{
schemaId: 'id',
format: 'full',
coerceTypes: true,
unknownFormats: 'ignore',
useDefaults: true,
},
optsIn,
);
const ajv = new Ajv(opts);
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
try {
// eslint-disable-next-line import/no-dynamic-require
ajv.addMetaSchema(require(`ajv/lib/refs/${metaSchema}.json`), metaSchema);
} catch (e) {
throw new Error(`Meta schema ${metaSchema} not supported. ${e.message}`);
}

@@ -18,0 +26,0 @@ ajv.addFormat('int32', { type: 'number', validate: validator.int32 });

{
"name": "ajv-oai",
"version": "1.1.2",
"version": "1.1.4",
"description": "OpenAPI's JsonSchema validator, Powered by Ajv",
"main": "lib/ajv-oai.js",
"typings": "lib/ajv-oai.d.ts",
"scripts": {

@@ -21,3 +22,3 @@ "ci": "npm run lint && npm run test",

"dependencies": {
"decimal.js": "^9.0.1"
"decimal.js": "^10.2.0"
},

@@ -28,2 +29,3 @@ "peerDependencies": {

"devDependencies": {
"ajv": "6.10.2",
"babel-core": "^6.26.0",

@@ -30,0 +32,0 @@ "babel-jest": "^22.1.0",

[license-img]: http://img.shields.io/badge/license-MIT-green.svg
[license-url]: http://opensource.org/licenses/MIT
[node-image]: https://img.shields.io/badge/node.js-v6.0.0-blue.svg
[node-url]: http://nodejs.org/download/
[npm-img]: https://img.shields.io/npm/v/ajv-oai.svg
[npm-url]: https://npmjs.org/package/ajv-oai
[travis-img]: https://travis-ci.org/BiteBit/ajv-oai.svg
[travis-url]: https://travis-ci.org/BiteBit/ajv-oai
[coveralls-img]: https://coveralls.io/repos/github/BiteBit/ajv-oai/badge.svg
[coveralls-url]: https://coveralls.io/github/BiteBit/ajv-oai
[downloads-image]: https://img.shields.io/npm/dm/ajv-oai.svg
[downloads-url]: https://npmjs.org/package/ajv-oai
[david-img]: https://img.shields.io/david/BiteBit/ajv-oai.svg
[david-url]: https://david-dm.org/BiteBit/ajv-oai
[router]: https://github.com/BiteBit/koa-oai-router

@@ -39,2 +32,3 @@

# Installation
```

@@ -44,3 +38,18 @@ npm install ajv-oai --save

# Usage
With draft 04 by default:
```js
const ajv = new AjvOAI();
```
With a custom meta schema from [AJV lib](https://github.com/epoberezkin/ajv/tree/master/lib/refs)
```js
const ajv = new AjvOAI({ metaSchema: 'json-schema-draft-06' });
```
# Example
```js

@@ -93,2 +102,2 @@ const ajv = new AjvOAI();

> true
```
```

Sorry, the diff of this file is not supported yet

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