mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Merge pull request #481 from postmanlabs/fix479/valueTypes
values like <integer> in validation
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* utils.js contains other util functions
|
||||
*/
|
||||
|
||||
const { formatDataPath } = require('./common/schemaUtilsCommon.js'),
|
||||
const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/schemaUtilsCommon.js'),
|
||||
{ getConcreteSchemaUtils } = require('./common/versionUtils.js'),
|
||||
async = require('async'),
|
||||
sdk = require('postman-collection'),
|
||||
@@ -85,15 +85,6 @@ const { formatDataPath } = require('./common/schemaUtilsCommon.js'),
|
||||
'authorization'
|
||||
],
|
||||
|
||||
/* eslint-disable arrow-body-style */
|
||||
schemaTypeToJsValidator = {
|
||||
'string': (d) => typeof d === 'string',
|
||||
'number': (d) => !isNaN(d),
|
||||
'integer': (d) => !isNaN(d) && Number.isInteger(Number(d)),
|
||||
'boolean': (d) => _.isBoolean(d) || d === 'true' || d === 'false',
|
||||
'array': (d) => Array.isArray(d),
|
||||
'object': (d) => typeof d === 'object' && !Array.isArray(d)
|
||||
},
|
||||
crypto = require('crypto'),
|
||||
DEFAULT_SCHEMA_UTILS = require('./30XUtils/schemaUtils30X');
|
||||
/* eslint-enable */
|
||||
@@ -3105,7 +3096,7 @@ module.exports = {
|
||||
}
|
||||
// When processing a reference, schema.type could also be undefined
|
||||
else if (schema && schema.type) {
|
||||
if (typeof schemaTypeToJsValidator[schema.type] === 'function') {
|
||||
if (isKnownType(schema)) {
|
||||
let isCorrectType;
|
||||
|
||||
// Treat unresolved postman collection/environment variable as correct type
|
||||
@@ -3113,7 +3104,7 @@ module.exports = {
|
||||
isCorrectType = true;
|
||||
}
|
||||
else {
|
||||
isCorrectType = schemaTypeToJsValidator[schema.type](valueToUse);
|
||||
isCorrectType = checkIsCorrectType(valueToUse, schema);
|
||||
}
|
||||
|
||||
if (!isCorrectType) {
|
||||
|
||||
Reference in New Issue
Block a user