mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Revert webhooks related changes for validation
This commit is contained in:
@@ -205,29 +205,6 @@ function safeSchemaFaker(oldSchema, resolveTo, resolveFor, parameterSourceOption
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* concatenates webhooks and paths into a single object and marks the property kind
|
||||
* to identify the tyype
|
||||
* @param {object} schema openapi query params object
|
||||
* @returns {object} the concatenation of paths and webhooks
|
||||
*/
|
||||
function concatPathsAndWebhooks(schema) {
|
||||
let schemaPathItems = {},
|
||||
deepCopy = _.cloneDeep(schema);
|
||||
_.forOwn(deepCopy.paths, (pathItemObject) => {
|
||||
pathItemObject.kind = 'paths';
|
||||
});
|
||||
schemaPathItems = deepCopy.paths;
|
||||
|
||||
if (deepCopy.webhooks) {
|
||||
_.forOwn(deepCopy.webhooks, (webhookItemObject) => {
|
||||
webhookItemObject.kind = 'webhooks';
|
||||
});
|
||||
schemaPathItems = Object.assign(schemaPathItems, deepCopy.webhooks);
|
||||
}
|
||||
return schemaPathItems;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
safeSchemaFaker: safeSchemaFaker,
|
||||
@@ -2614,11 +2591,9 @@ module.exports = {
|
||||
pathToMatch,
|
||||
matchedPath,
|
||||
matchedPathJsonPath,
|
||||
schemaPathItems,
|
||||
schemaPathItems = schema.paths,
|
||||
filteredPathItemsArray = [];
|
||||
|
||||
schemaPathItems = concatPathsAndWebhooks(schema);
|
||||
|
||||
// Return no matches for invalid url (if unable to decode parsed url)
|
||||
try {
|
||||
pathToMatch = decodeURI(parsedUrl.pathname);
|
||||
@@ -2689,7 +2664,6 @@ module.exports = {
|
||||
_.each(filteredPathItemsArray, (fp) => {
|
||||
let path = fp.path,
|
||||
pathItemObject = fp.pathItem,
|
||||
kind = pathItemObject.kind,
|
||||
score = fp.matchScore,
|
||||
pathVars = fp.pathVars;
|
||||
|
||||
@@ -2699,7 +2673,7 @@ module.exports = {
|
||||
return true;
|
||||
}
|
||||
|
||||
matchedPathJsonPath = `$.${kind}[${path}]`;
|
||||
matchedPathJsonPath = `$.paths[${path}]`;
|
||||
|
||||
// filter empty parameters
|
||||
matchedPath.parameters = _.reduce(matchedPath.parameters, (accumulator, param) => {
|
||||
@@ -4687,28 +4661,20 @@ module.exports = {
|
||||
*/
|
||||
getMissingSchemaEndpoints: function (schema, matchedEndpoints, components, options, schemaCache) {
|
||||
let endpoints = [],
|
||||
schemaPaths = schema.paths,
|
||||
rootCollectionVariables,
|
||||
schemaJsonPath,
|
||||
schemaPathItems;
|
||||
schemaPathItems = concatPathsAndWebhooks(schema);
|
||||
_.forEach(schemaPathItems, (schemaPathObj, schemaPath) => {
|
||||
schemaJsonPath;
|
||||
|
||||
// collection variables generated for resolving for baseUrl and variables
|
||||
rootCollectionVariables = this.convertToPmCollectionVariables(
|
||||
schema.baseUrlVariables,
|
||||
'baseUrl',
|
||||
schema.baseUrl
|
||||
);
|
||||
|
||||
_.forEach(schemaPaths, (schemaPathObj, schemaPath) => {
|
||||
_.forEach(_.keys(schemaPathObj), (pathKey) => {
|
||||
schemaJsonPath = `$.${schemaPathObj.kind}[${schemaPath}].${_.toLower(pathKey)}`;
|
||||
if (schemaPathObj.kind === 'webhooks') {
|
||||
rootCollectionVariables = this.convertToPmCollectionVariables(
|
||||
schema.baseUrlVariables,
|
||||
schemaPath.startsWith('/') ? this.cleanWebhookName(schemaPath.slice(1)) : this.cleanWebhookName(schemaPath),
|
||||
schema.baseUrl
|
||||
);
|
||||
}
|
||||
else {
|
||||
// collection variables generated for resolving for baseUrl and variables
|
||||
rootCollectionVariables = this.convertToPmCollectionVariables(
|
||||
schema.baseUrlVariables,
|
||||
'baseUrl',
|
||||
schema.baseUrl
|
||||
);
|
||||
}
|
||||
schemaJsonPath = `$.paths[${schemaPath}].${_.toLower(pathKey)}`;
|
||||
if (METHODS.includes(pathKey) && !matchedEndpoints.includes(schemaJsonPath)) {
|
||||
let mismatchObj = {
|
||||
property: 'ENDPOINT',
|
||||
|
||||
Reference in New Issue
Block a user