Add support for url with fragment and servers

Add support for url with fragment and serversAdd support for url with fragment and serversAdd support for url with fragment and servers
This commit is contained in:
Luis Tejeda
2022-07-13 14:39:23 -05:00
parent f25e0252e3
commit ad78625271
3 changed files with 129 additions and 4 deletions

View File

@@ -2603,6 +2603,7 @@ module.exports = {
matchedPath,
matchedPathJsonPath,
schemaPathItems = schema.paths,
pathToMatchServer,
filteredPathItemsArray = [];
// Return no matches for invalid url (if unable to decode parsed url)
@@ -2650,9 +2651,12 @@ module.exports = {
// check if path and pathToMatch match (non-null)
// check in explicit (local defined) servers
if (pathItemObject[method.toLowerCase()].servers) {
pathToMatch = this.handleExplicitServersPathToMatch(pathToMatch, path);
pathToMatchServer = this.handleExplicitServersPathToMatch(pathToMatch, path);
schemaMatchResult = this.getPostmanUrlSchemaMatchScore(pathToMatchServer, path, options);
}
else {
schemaMatchResult = this.getPostmanUrlSchemaMatchScore(pathToMatch, path, options);
}
schemaMatchResult = this.getPostmanUrlSchemaMatchScore(pathToMatch, path, options);
if (!schemaMatchResult.match) {
// there was no reasonable match b/w the postman path and this schema path
return true;
@@ -4446,6 +4450,7 @@ module.exports = {
*/
handleExplicitServersPathToMatch: function (pathToMatch, schemaPath) {
let pathTMatchSlice,
fragment = '',
schemaPathArr = _.reject(schemaPath.split('/'), (segment) => {
return segment === '';
}),
@@ -4453,12 +4458,16 @@ module.exports = {
pathToMatchArr = _.reject(pathToMatch.split('/'), (segment) => {
return segment === '';
}),
pathToMatchSegments = pathToMatchArr.length;
pathToMatchSegments = pathToMatchArr.length,
fragments = schemaPath.split('#');
if (fragments.length > 1) {
fragment = '#' + fragments[1];
}
if (pathToMatchSegments < schemaPathSegments) {
return pathToMatch;
}
pathTMatchSlice = pathToMatchArr.slice(pathToMatchArr.length - schemaPathSegments, pathToMatchArr.length);
return pathTMatchSlice.join('/');
return pathTMatchSlice.join('/') + fragment;
},
/**