Skip to content

Commit 77b5c9f

Browse files
committed
Use global const for defaults of the options in resolveRefs and resolveAll
1 parent 4f8cc53 commit 77b5c9f

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lib/deref.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ const _ = require('lodash'),
2727
'float',
2828
'double'
2929
],
30+
RESOLVE_REF_DEFAULTS = {
31+
resolveFor: 'CONVERSION',
32+
resolveTo: 'schema',
33+
stack: 0,
34+
stackLimit: 10,
35+
isAllOf: false
36+
},
3037
DEFAULT_SCHEMA_UTILS = require('./30XUtils/schemaUtils30X'),
3138
traverseUtility = require('traverse'),
3239
PROPERTIES_TO_ASSIGN_ON_CASCADE = ['type', 'nullable'];
@@ -96,8 +103,14 @@ module.exports = {
96103
* @param {*} options.stackLimit Depth to which the schema should be resolved.
97104
* @returns {*} schema - schema that adheres to all individual schemas in schemaArr
98105
*/
99-
resolveAllOf: function (schemaArr, parameterSourceOption, components,
100-
{ resolveFor = 'CONVERSION', resolveTo = 'schema', stack = 0, seenRef = {}, stackLimit = 10, analytics = {} }) {
106+
resolveAllOf: function (schemaArr, parameterSourceOption, components, {
107+
resolveFor = RESOLVE_REF_DEFAULTS.resolveFor,
108+
resolveTo = RESOLVE_REF_DEFAULTS.resolveTo,
109+
stack = RESOLVE_REF_DEFAULTS.stack,
110+
seenRef = {},
111+
stackLimit = RESOLVE_REF_DEFAULTS.stackLimit,
112+
analytics = {}
113+
}) {
101114

102115
if (!(schemaArr instanceof Array)) {
103116
return null;
@@ -146,8 +159,13 @@ module.exports = {
146159
*/
147160

148161
resolveRefs: function (schema, parameterSourceOption, components, {
149-
resolveFor = 'CONVERSION', resolveTo = 'schema', stack = 0, seenRef = {}, stackLimit = 10,
150-
isAllOf = false, analytics = {}
162+
resolveFor = RESOLVE_REF_DEFAULTS.resolveFor,
163+
resolveTo = RESOLVE_REF_DEFAULTS.resolveTo,
164+
stack = RESOLVE_REF_DEFAULTS.stack,
165+
seenRef = {},
166+
stackLimit = RESOLVE_REF_DEFAULTS.stackLimit,
167+
isAllOf = RESOLVE_REF_DEFAULTS.isAllOf,
168+
analytics = {}
151169
}) {
152170
var resolvedSchema, prop, splitRef,
153171
ERR_TOO_MANY_LEVELS = '<Error: Too many levels of nesting to fake this schema>';

0 commit comments

Comments
 (0)