mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-17 17:56:27 +00:00
Openapi Schema improvements
- Return proper booleans in api responses - Update jsonschemavalidation to latest draft
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
const Ajv = require('ajv/dist/2020');
|
||||
const error = require('../error');
|
||||
|
||||
const ajv = require('ajv')({
|
||||
verbose: true,
|
||||
validateSchema: true,
|
||||
allErrors: false,
|
||||
format: 'full',
|
||||
coerceTypes: true
|
||||
const ajv = new Ajv({
|
||||
verbose: true,
|
||||
allErrors: true,
|
||||
allowUnionTypes: true,
|
||||
strict: false,
|
||||
coerceTypes: true,
|
||||
});
|
||||
|
||||
/**
|
||||
@ -25,8 +26,8 @@ function apiValidator (schema, payload/*, description*/) {
|
||||
return;
|
||||
}
|
||||
|
||||
let validate = ajv.compile(schema);
|
||||
let valid = validate(payload);
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(payload);
|
||||
|
||||
if (valid && !validate.errors) {
|
||||
resolve(payload);
|
||||
|
@ -1,15 +1,17 @@
|
||||
const _ = require('lodash');
|
||||
const Ajv = require('ajv/dist/2020');
|
||||
const error = require('../error');
|
||||
const commonDefinitions = require('../../schema/common.json');
|
||||
|
||||
RegExp.prototype.toJSON = RegExp.prototype.toString;
|
||||
|
||||
const ajv = require('ajv')({
|
||||
verbose: true,
|
||||
allErrors: true,
|
||||
format: 'full', // strict regexes for format checks
|
||||
coerceTypes: true,
|
||||
schemas: [commonDefinitions]
|
||||
const ajv = new Ajv({
|
||||
verbose: true,
|
||||
allErrors: true,
|
||||
allowUnionTypes: true,
|
||||
coerceTypes: true,
|
||||
strict: false,
|
||||
schemas: [commonDefinitions]
|
||||
});
|
||||
|
||||
/**
|
||||
@ -38,7 +40,6 @@ function validator (schema, payload) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module.exports = validator;
|
||||
|
Reference in New Issue
Block a user