mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Updated code to be more readable as suggested in comment
This commit is contained in:
19
lib/deref.js
19
lib/deref.js
@@ -176,14 +176,17 @@ module.exports = {
|
||||
return { value: 'reference ' + schema.$ref + ' not found in the OpenAPI spec' };
|
||||
}
|
||||
|
||||
/**
|
||||
* use cached schema if it was resolved at level lower or equal then at current stack level or
|
||||
* cached schema is resolved fully (it does not contain ERR_TOO_MANY_LEVELS value in sub schema)
|
||||
*/
|
||||
if (_.get(schemaResolutionCache, [refKey, 'schema']) &&
|
||||
(_.get(schemaResolutionCache, [refKey, 'maxStack'], 0) < stackLimit ||
|
||||
_.get(schemaResolutionCache, [refKey, 'resLevel'], stackLimit) <= stack)) {
|
||||
return schemaResolutionCache[refKey].schema;
|
||||
if (_.get(schemaResolutionCache, [refKey, 'schema'])) {
|
||||
let maxStack = _.get(schemaResolutionCache, [refKey, 'maxStack'], 0),
|
||||
resLevel = _.get(schemaResolutionCache, [refKey, 'resLevel'], stackLimit);
|
||||
|
||||
/**
|
||||
* use cached schema if it was resolved at level lower or equal then at current stack level or
|
||||
* if cached schema is resolved fully (it does not contain ERR_TOO_MANY_LEVELS value in sub schema)
|
||||
*/
|
||||
if (resLevel <= stack || maxStack < stackLimit) {
|
||||
return schemaResolutionCache[refKey].schema;
|
||||
}
|
||||
}
|
||||
// something like #/components/schemas/PaginationEnvelope/properties/page
|
||||
// will be resolved - we don't care about anything after the components part
|
||||
|
||||
Reference in New Issue
Block a user