api-doc-validator
Advanced tools
Comparing version 2.7.6 to 2.8.0
@@ -11,5 +11,2 @@ | ||
const ajv = Api.getAjv(); | ||
const errorHandler = context.errorHandler || Api.errorHandler; | ||
let params = null; | ||
@@ -47,2 +44,5 @@ let query = null; | ||
const ajv = Api.getAjv({type: 'request', endpoint: e, context: this, meta}); | ||
const errorHandler = context.errorHandler || Api.errorHandler; | ||
if (e.params) { | ||
@@ -118,2 +118,4 @@ let {schema, validate} = e.params; | ||
if (e.response) { | ||
const ajv = Api.getAjv({type: 'response', endpoint: e, context: this, meta}); | ||
for (let i = 0, len = e.response.length; i < len; i++) { | ||
@@ -120,0 +122,0 @@ let response = e.response[i]; |
Api.getAjv = function () { | ||
let {ajv} = Api; | ||
Api.getAjv = function ({type}) { | ||
const key = type + 'Ajv'; | ||
let ajv = Api[key]; | ||
if (!ajv) { | ||
const Ajv = require('ajv').default; | ||
if (ajv) return ajv; | ||
ajv = Api.ajv = new Ajv({coerceTypes: true}); | ||
const Ajv = require('ajv').default; | ||
try { | ||
var formatsFound = !!require.resolve('ajv-formats'); | ||
} | ||
catch (err) {} | ||
ajv = Api[key] = new Ajv({coerceTypes: type === 'response'}); | ||
if (formatsFound) { | ||
require('ajv-formats')(ajv); | ||
} | ||
try { | ||
var formatsFound = !!require.resolve('ajv-formats'); | ||
} | ||
catch (err) {} | ||
if (formatsFound) { | ||
require('ajv-formats')(ajv); | ||
} | ||
return ajv; | ||
}; |
{ | ||
"name": "api-doc-validator", | ||
"version": "2.7.6", | ||
"version": "2.8.0", | ||
"description": "api doc and validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59064
1654