Fix for https://github.com/postmanlabs/openapi-to-postman/issues/5 - headers that have refs to deeper components are correctly generated

This commit is contained in:
abhijitkane
2018-12-16 17:29:45 +05:30
parent 47ab79f082
commit d5992d19e5
3 changed files with 87 additions and 5 deletions

View File

@@ -1062,8 +1062,9 @@ module.exports = {
_.forOwn(response.headers, (value, key) => {
if (key !== 'Content-Type') {
if (value.$ref) {
// the convert to PmHeader function handles the
// schema-faking
header = this.getRefObject(value.$ref);
// header.name = value.$ref.split('/').slice(3)[0];
}
else {
header = value;
@@ -1115,8 +1116,8 @@ module.exports = {
var refObj, savedSchema;
savedSchema = $ref.split('/').slice(2);
// must have 2 segments after "#/components"
if (savedSchema.length !== 2) {
// must have min. 2 segments after "#/components"
if (savedSchema.length < 2) {
console.warn(`ref ${$ref} not found.`);
return null;
}