Skip to content

Commit 935acd7

Browse files
committed
req changes from code review
1 parent ac4094e commit 935acd7

File tree

5 files changed

+48
-14
lines changed

5 files changed

+48
-14
lines changed

OPTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ disableOptionalParameters|boolean|-|false|Whether to set optional parameters as
2323
keepImplicitHeaders|boolean|-|false|Whether to keep implicit headers from the OpenAPI specification, which are removed by default.|CONVERSION
2424
includeWebhooks|boolean|-|false|Select whether to include Webhooks in the generated collection|CONVERSION
2525
includeReferenceMap|boolean|-|false|Whether or not to include reference map or not as part of output|BUNDLE
26-
includeDeprecated|boolean|-|true|Select whether to include deprecated properties or not|CONVERSION, VALIDATION
26+
includeDeprecated|boolean|-|true|Select whether to include deprecated operations, parameters, and properties in generated collection or not|CONVERSION, VALIDATION

lib/options.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ module.exports = {
314314
id: 'includeDeprecated',
315315
type: 'boolean',
316316
default: true,
317-
description: 'Select whether to include deprecated properties or not',
317+
description: 'Select whether to include deprecated operations, parameters,' +
318+
' and properties in generated collection or not',
318319
external: true,
319320
usage: ['CONVERSION', 'VALIDATION'],
320321
supportedIn: [VERSION20, VERSION30, VERSION31]

lib/schemaUtils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ function hash(input) {
126126
}
127127

128128
/**
129-
* Remove or leave the deprecated properties according to the option
129+
* Remove or keep the deprecated properties according to the option
130130
* @param {object} resolvedSchema - the schema to verify properties
131-
* @param {boolean} includeDeprecated - Whether to include the deprecated properties
131+
* @param {boolean} includeDeprecated - Whether to include the deprecated properties
132132
* @returns {undefined} undefined
133133
*/
134134
function verifyDeprecatedProperties(resolvedSchema, includeDeprecated) {
@@ -163,9 +163,9 @@ function safeSchemaFaker(oldSchema, resolveTo, resolveFor, parameterSourceOption
163163
let concreteUtils = components && components.hasOwnProperty('concreteUtils') ?
164164
components.concreteUtils :
165165
DEFAULT_SCHEMA_UTILS;
166-
const indentCharacter = _.get(options, 'indentCharacter', ' '),
167-
stackLimit = _.get(options, 'stackLimit', 10),
168-
includeDeprecated = _.get(options, 'includeDeprecated', true);
166+
const indentCharacter = options.indentCharacter,
167+
stackLimit = options.stackLimit,
168+
includeDeprecated = options.includeDeprecated;
169169

170170
resolvedSchema = deref.resolveRefs(oldSchema, parameterSourceOption, components, schemaResolutionCache,
171171
resolveFor, resolveTo, 0, {}, stackLimit);

test/system/structure.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ const optionIds = [
195195
name: 'Include deprecated properties',
196196
type: 'boolean',
197197
default: true,
198-
description: 'Select whether to include deprecated properties or not',
198+
description: 'Select whether to include deprecated operations, parameters, and properties' +
199+
' in generated collection or not',
199200
external: true,
200201
usage: ['CONVERSION']
201202
}

test/unit/util.test.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
6868
},
6969
parameterSource = 'REQUEST',
7070
resolveTo = 'schema',
71-
resolveFor = 'CONVERSION';
71+
resolveFor = 'CONVERSION',
72+
options = {
73+
indentCharacter: ' ',
74+
stackLimit: 10,
75+
includeDeprecated: true
76+
};
7277

73-
expect(SchemaUtils.safeSchemaFaker(schema, resolveTo, resolveFor, parameterSource, { components, concreteUtils }))
78+
expect(SchemaUtils.safeSchemaFaker(schema, resolveTo, resolveFor, parameterSource, { components, concreteUtils },
79+
'', undefined, options))
7480
.to.equal('<string>');
7581
done();
7682
});
@@ -100,13 +106,21 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
100106
parameterSource = 'REQUEST',
101107
resolveTo = 'schema',
102108
resolveFor = 'CONVERSION',
109+
options = {
110+
indentCharacter: ' ',
111+
stackLimit: 10,
112+
includeDeprecated: true
113+
},
103114

104115
result = SchemaUtils.safeSchemaFaker(
105116
schema,
106117
resolveTo,
107118
resolveFor,
108119
parameterSource,
109-
{ components, concreteUtils }
120+
{ components, concreteUtils },
121+
'',
122+
undefined,
123+
options
110124
),
111125
tooManyLevelsString = result[0].c.value;
112126

@@ -146,12 +160,20 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
146160
parameterSource = 'REQUEST',
147161
resolveTo = 'schema',
148162
resolveFor = 'CONVERSION',
163+
options = {
164+
indentCharacter: ' ',
165+
stackLimit: 10,
166+
includeDeprecated: true
167+
},
149168
fakedSchema = SchemaUtils.safeSchemaFaker(
150169
schema,
151170
resolveTo,
152171
resolveFor,
153172
parameterSource,
154-
{ components, concreteUtils }
173+
{ components, concreteUtils },
174+
'',
175+
undefined,
176+
options
155177
);
156178

157179
expect(fakedSchema.value).to.equal('reference #/components/schem2 not found in the OpenAPI spec');
@@ -188,8 +210,13 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
188210
schemaResolutionCache: {}
189211
},
190212
key = hash('resolveToSchema ' + JSON.stringify(resolvedSchema)),
213+
options = {
214+
indentCharacter: ' ',
215+
stackLimit: 10,
216+
includeDeprecated: true
217+
},
191218
fakedSchema = SchemaUtils.safeSchemaFaker(schema, resolveTo, resolveFor, parameterSource,
192-
{ components, concreteUtils }, 'default', schemaCache);
219+
{ components, concreteUtils }, 'default', schemaCache, options);
193220

194221
expect(schemaCache.schemaFakerCache).to.have.property(key);
195222
expect(schemaCache.schemaFakerCache[key]).to.equal(fakedSchema);
@@ -231,8 +258,13 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
231258
resolveTo
232259
),
233260
key = hash('resolveToExample ' + JSON.stringify(resolvedSchema)),
261+
options = {
262+
indentCharacter: ' ',
263+
stackLimit: 10,
264+
includeDeprecated: true
265+
},
234266
fakedSchema = SchemaUtils.safeSchemaFaker(schema, resolveTo, resolveFor, parameterSource,
235-
{ components, concreteUtils }, 'default', schemaCache);
267+
{ components, concreteUtils }, 'default', schemaCache, options);
236268

237269
expect(schemaCache.schemaFakerCache).to.have.property(key);
238270
expect(schemaCache.schemaFakerCache[key]).to.equal(fakedSchema);

0 commit comments

Comments
 (0)