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);
|
||||
|
||||
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
|
||||
_.isArray(this._currentRefStack) && (this._currentRefStack.pop());
|
||||
@@ -258,7 +258,7 @@ module.exports = {
|
||||
}
|
||||
/* eslint-enable */
|
||||
tempSchema.properties[prop] = this.resolveRefs(property, parameterSourceOption, components,
|
||||
schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef));
|
||||
schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef), stackLimit);
|
||||
}
|
||||
}
|
||||
return tempSchema;
|
||||
@@ -296,7 +296,7 @@ module.exports = {
|
||||
// without this, schemas with circular references aren't faked correctly
|
||||
let tempSchema = _.omit(schema, 'items');
|
||||
tempSchema.items = this.resolveRefs(schema.items, parameterSourceOption,
|
||||
components, schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef));
|
||||
components, schemaResolutionCache, resolveFor, resolveTo, stack, _.cloneDeep(seenRef), stackLimit);
|
||||
return tempSchema;
|
||||
}
|
||||
else if (!schema.hasOwnProperty('default')) {
|
||||
|
||||
@@ -116,6 +116,15 @@ module.exports = {
|
||||
external: false,
|
||||
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',
|
||||
id: 'includeAuthInfoInExample',
|
||||
@@ -246,8 +255,8 @@ module.exports = {
|
||||
|
||||
// options to be used as documentation
|
||||
return _.filter(optsArray, (opt) => {
|
||||
// only return options that are externally controllable
|
||||
return opt.external === true;
|
||||
// only return options that are not disabled
|
||||
return opt.disabled !== true;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,6 +66,15 @@ module.exports = {
|
||||
}
|
||||
|
||||
break;
|
||||
case 'integer':
|
||||
if (_.isSafeInteger(userOptions[id])) {
|
||||
retVal[id] = userOptions[id];
|
||||
}
|
||||
else {
|
||||
retVal[id] = defaultOptions[id].default;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
retVal[id] = defaultOptions[id].default;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user