webhooks scenarios

This commit is contained in:
Luis Tejeda
2022-01-27 12:33:42 -06:00
parent 68bb3f7c4f
commit 384c23f01c
7 changed files with 7497 additions and 15 deletions

View File

@@ -212,17 +212,18 @@ function safeSchemaFaker(oldSchema, resolveTo, resolveFor, parameterSourceOption
* @returns {object} the concatenation of paths and webhooks
*/
function concatPathsAndWebhooks(schema) {
let schemaPathItems = {};
_.forOwn(schema.paths, (pathItemObject) => {
let schemaPathItems = {},
deepCopy = _.cloneDeep(schema);
_.forOwn(deepCopy.paths, (pathItemObject) => {
pathItemObject.kind = 'paths';
});
schemaPathItems = schema.paths;
schemaPathItems = deepCopy.paths;
if (schema.webhooks) {
_.forOwn(schema.webhooks, (webhookItemObject) => {
if (deepCopy.webhooks) {
_.forOwn(deepCopy.webhooks, (webhookItemObject) => {
webhookItemObject.kind = 'webhooks';
});
schemaPathItems = Object.assign(schemaPathItems, schema.webhooks);
schemaPathItems = Object.assign(schemaPathItems, deepCopy.webhooks);
}
return schemaPathItems;
}
@@ -4566,9 +4567,10 @@ module.exports = {
*/
getMissingSchemaEndpoints: function (schema, matchedEndpoints, components, options, schemaCache) {
let endpoints = [],
schemaPaths = schema.paths,
// schemaPaths = schema.paths,
rootCollectionVariables,
schemaJsonPath;
schemaJsonPath,
schemaPathItems;
// collection variables generated for resolving for baseUrl and variables
rootCollectionVariables = this.convertToPmCollectionVariables(
@@ -4576,10 +4578,10 @@ module.exports = {
'baseUrl',
schema.baseUrl
);
_.forEach(schemaPaths, (schemaPathObj, schemaPath) => {
schemaPathItems = concatPathsAndWebhooks(schema);
_.forEach(schemaPathItems, (schemaPathObj, schemaPath) => {
_.forEach(_.keys(schemaPathObj), (pathKey) => {
schemaJsonPath = `$.paths[${schemaPath}].${_.toLower(pathKey)}`;
schemaJsonPath = `$.${schemaPathObj.kind}[${schemaPath}].${_.toLower(pathKey)}`;
if (METHODS.includes(pathKey) && !matchedEndpoints.includes(schemaJsonPath)) {
let mismatchObj = {
property: 'ENDPOINT',