mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Added support for stackLimit option to customize schema resolution level
This commit is contained in:
@@ -218,7 +218,7 @@ module.exports = {
|
|||||||
this._currentRefStack.push(refKey);
|
this._currentRefStack.push(refKey);
|
||||||
|
|
||||||
let refResolvedSchema = this.resolveRefs(resolvedSchema, parameterSourceOption,
|
let refResolvedSchema = this.resolveRefs(resolvedSchema, parameterSourceOption,
|
||||||
components, schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef));
|
components, schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef), stackLimit);
|
||||||
|
|
||||||
// remove current ref that's being resolved from stack as soon as resolved
|
// remove current ref that's being resolved from stack as soon as resolved
|
||||||
_.isArray(this._currentRefStack) && (this._currentRefStack.pop());
|
_.isArray(this._currentRefStack) && (this._currentRefStack.pop());
|
||||||
@@ -258,7 +258,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
tempSchema.properties[prop] = this.resolveRefs(property, parameterSourceOption, components,
|
tempSchema.properties[prop] = this.resolveRefs(property, parameterSourceOption, components,
|
||||||
schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef));
|
schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef), stackLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tempSchema;
|
return tempSchema;
|
||||||
@@ -296,7 +296,7 @@ module.exports = {
|
|||||||
// without this, schemas with circular references aren't faked correctly
|
// without this, schemas with circular references aren't faked correctly
|
||||||
let tempSchema = _.omit(schema, 'items');
|
let tempSchema = _.omit(schema, 'items');
|
||||||
tempSchema.items = this.resolveRefs(schema.items, parameterSourceOption,
|
tempSchema.items = this.resolveRefs(schema.items, parameterSourceOption,
|
||||||
components, schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef));
|
components, schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef), stackLimit);
|
||||||
return tempSchema;
|
return tempSchema;
|
||||||
}
|
}
|
||||||
else if (!schema.hasOwnProperty('default')) {
|
else if (!schema.hasOwnProperty('default')) {
|
||||||
|
|||||||
@@ -116,6 +116,15 @@ module.exports = {
|
|||||||
external: false,
|
external: false,
|
||||||
usage: ['CONVERSION']
|
usage: ['CONVERSION']
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Schema resolution nesting limit',
|
||||||
|
id: 'stackLimit',
|
||||||
|
type: 'integer',
|
||||||
|
default: 10,
|
||||||
|
description: 'Number of nesting limit till which schema resolution will happen.',
|
||||||
|
external: false,
|
||||||
|
usage: ['CONVERSION']
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Include auth info in example requests',
|
name: 'Include auth info in example requests',
|
||||||
id: 'includeAuthInfoInExample',
|
id: 'includeAuthInfoInExample',
|
||||||
@@ -246,8 +255,8 @@ module.exports = {
|
|||||||
|
|
||||||
// options to be used as documentation
|
// options to be used as documentation
|
||||||
return _.filter(optsArray, (opt) => {
|
return _.filter(optsArray, (opt) => {
|
||||||
// only return options that are externally controllable
|
// only return options that are not disabled
|
||||||
return opt.external === true;
|
return opt.disabled !== true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,6 +66,15 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case 'integer':
|
||||||
|
if (_.isSafeInteger(userOptions[id])) {
|
||||||
|
retVal[id] = userOptions[id];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retVal[id] = defaultOptions[id].default;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
retVal[id] = defaultOptions[id].default;
|
retVal[id] = defaultOptions[id].default;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user