mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Fixed issue where certain parameter were not converted to variables in conversion
This commit is contained in:
@@ -306,11 +306,15 @@ module.exports = {
|
|||||||
// All complicated logic removed
|
// All complicated logic removed
|
||||||
// This simply replaces all instances of {text} with {{text}}
|
// This simply replaces all instances of {text} with {{text}}
|
||||||
// text cannot have any of these 3 chars: /{}
|
// text cannot have any of these 3 chars: /{}
|
||||||
// and {text} cannot be followed by a }
|
|
||||||
// {{text}} will not be converted
|
// {{text}} will not be converted
|
||||||
// https://regex101.com/r/9N1520/1
|
|
||||||
return url
|
let replacer = function (match, p1, offset, string) {
|
||||||
.replace(/(\{[^\/\{\}]+\})(?!\})/g, '{$1}');
|
if (string[offset - 1] === '{' && string[offset + match.length + 1] !== '}') {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
return '{' + p1 + '}';
|
||||||
|
};
|
||||||
|
return url.replace(/(\{[^\/\{\}]+\})/g, replacer);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2017,6 +2017,8 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
|
|||||||
|
|
||||||
expect(SchemaUtils.fixPathVariablesInUrl('{{a}}')).to.equal('{{a}}');
|
expect(SchemaUtils.fixPathVariablesInUrl('{{a}}')).to.equal('{{a}}');
|
||||||
|
|
||||||
|
expect(SchemaUtils.fixPathVariablesInUrl('/agents/{agentId}}')).to.equal('/agents/{{agentId}}}');
|
||||||
|
|
||||||
expect(SchemaUtils.fixPathVariablesInUrl('{{a}}://{b}.com/{pathvar}/{morevar}'))
|
expect(SchemaUtils.fixPathVariablesInUrl('{{a}}://{b}.com/{pathvar}/{morevar}'))
|
||||||
.to.equal('{{a}}://{{b}}.com/{{pathvar}}/{{morevar}}');
|
.to.equal('{{a}}://{{b}}.com/{{pathvar}}/{{morevar}}');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user