mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Exposing option to hide MISSING_IN_SCHEMA mismatches by default
This commit is contained in:
@@ -106,6 +106,15 @@ module.exports = {
|
||||
' Must be sent as an array of strings. Valid inputs in the array: PATHVARIABLE, QUERYPARAM,' +
|
||||
' HEADER, BODY, RESPONSE_HEADER, RESPONSE_BODY',
|
||||
external: true
|
||||
},
|
||||
{
|
||||
name: 'Whether MISSING_IN_SCHEMA mismatches should be returned',
|
||||
id: 'showMissingInSchemaErrors',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'MISSING_IN_SCHEMA indicates that an extra parameter was included in the request. For most ' +
|
||||
'use cases, this need not be considered an error.',
|
||||
external: true
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -1837,6 +1837,7 @@ module.exports = {
|
||||
|
||||
if (!schemaPathVar) {
|
||||
// extra pathVar present in given request.
|
||||
if (options.showMissingInSchemaErrors) {
|
||||
mismatches.push({
|
||||
property: mismatchProperty,
|
||||
// not adding the pathVar name to the jsonPath because URL is just a string
|
||||
@@ -1845,6 +1846,7 @@ module.exports = {
|
||||
reasonCode: 'MISSING_IN_SCHEMA',
|
||||
reason: `The path variable ${pathVar.key} was not found in the schema`
|
||||
});
|
||||
}
|
||||
return cb(null, mismatches);
|
||||
}
|
||||
|
||||
@@ -1915,6 +1917,7 @@ module.exports = {
|
||||
|
||||
if (!schemaParam) {
|
||||
// no schema param found
|
||||
if (options.showMissingInSchemaErrors) {
|
||||
mismatches.push({
|
||||
property: mismatchProperty,
|
||||
transactionJsonPath: transactionPathPrefix + '[?(@.key==\'' + pQuery.key + '\')]',
|
||||
@@ -1922,7 +1925,8 @@ module.exports = {
|
||||
reasonCode: 'MISSING_IN_SCHEMA',
|
||||
reason: `The query parameter ${pQuery.key} was not found in the schema`
|
||||
});
|
||||
return cb(null, []);
|
||||
}
|
||||
return cb(null, mismatches);
|
||||
}
|
||||
|
||||
// query found in spec. check query's schema
|
||||
@@ -1967,6 +1971,7 @@ module.exports = {
|
||||
|
||||
if (!schemaHeader) {
|
||||
// no schema header found
|
||||
if (options.showMissingInSchemaErrors) {
|
||||
mismatches.push({
|
||||
property: mismatchProperty,
|
||||
transactionJsonPath: transactionPathPrefix + '[?(@.key==\'' + pHeader.key + '\')]',
|
||||
@@ -1974,6 +1979,7 @@ module.exports = {
|
||||
reasonCode: 'MISSING_IN_SCHEMA',
|
||||
reason: `The header ${pHeader.key} was not found in the schema`
|
||||
});
|
||||
}
|
||||
return cb(null, []);
|
||||
}
|
||||
|
||||
@@ -2017,13 +2023,8 @@ module.exports = {
|
||||
|
||||
if (!schemaResponse || !(schemaResponse.headers)) {
|
||||
// no default response found, or no headers specified
|
||||
return callback(null, [{
|
||||
property: 'RESPONSE_HEADER',
|
||||
transactionJsonPath: transactionPathPrefix,
|
||||
schemaJsonPath: null,
|
||||
reasonCode: 'MISSING_IN_SCHEMA',
|
||||
reason: 'No response headers were found in the schema'
|
||||
}]);
|
||||
// if there is no header key, we can't call it a mismatch
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
schemaHeaders = schemaResponse.headers;
|
||||
@@ -2033,6 +2034,7 @@ module.exports = {
|
||||
|
||||
if (!schemaHeader) {
|
||||
// no schema header found
|
||||
if (options.showMissingInSchemaErrors) {
|
||||
mismatches.push({
|
||||
property: mismatchProperty,
|
||||
transactionJsonPath: transactionPathPrefix + '/' + pHeader.key,
|
||||
@@ -2040,6 +2042,7 @@ module.exports = {
|
||||
reasonCode: 'MISSING_IN_SCHEMA',
|
||||
reason: `The header ${pHeader.key} was not found in the schema`
|
||||
});
|
||||
}
|
||||
return cb(null, []);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user