Skip to content

Commit a7644bc

Browse files
Merge pull request #672 from postmanlabs/feature/fix-optional-parameters-copy
Fixes options copy and swapped disable optional params with enable
2 parents 8a9e2f2 + 684f55f commit a7644bc

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

OPTIONS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
id|type|available options|default|description|usage
22
|---|---|---|---|---|---|
33
requestNameSource|enum|URL, Fallback|Fallback|Determines how the requests inside the generated collection will be named. If “Fallback” is selected, the request will be named after one of the following schema values: `summary`, `operationId`, `description`, `url`.|CONVERSION, VALIDATION
4-
indentCharacter|enum|Space, Tab|Space|Option for setting indentation character|CONVERSION
4+
indentCharacter|enum|Space, Tab|Space|Option for setting indentation character.|CONVERSION
55
collapseFolders|boolean|-|true|Importing will collapse all folders that have only one child element and lack persistent folder-level data.|CONVERSION
66
optimizeConversion|boolean|-|true|Optimizes conversion for large specification, disabling this option might affect the performance of conversion.|CONVERSION
77
requestParametersResolution|enum|Example, Schema|Schema|Select whether to generate the request parameters based on the [schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject) or the [example](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject) in the schema.|CONVERSION
88
exampleParametersResolution|enum|Example, Schema|Example|Select whether to generate the response parameters based on the [schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject) or the [example](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject) in the schema.|CONVERSION
99
folderStrategy|enum|Paths, Tags|Paths|Select whether to create folders according to the spec’s paths or tags.|CONVERSION
1010
schemaFaker|boolean|-|true|Whether or not schemas should be faked.|CONVERSION
1111
stackLimit|integer|-|10|Number of nesting limit till which schema resolution will happen. Increasing this limit may result in more time to convert collection depending on complexity of specification. (To make sure this option works correctly "optimizeConversion" option needs to be disabled)|CONVERSION
12-
includeAuthInfoInExample|boolean|-|true|Select whether to include authentication parameters in the example request|CONVERSION
12+
includeAuthInfoInExample|boolean|-|true|Select whether to include authentication parameters in the example request.|CONVERSION
1313
shortValidationErrors|boolean|-|false|Whether detailed error messages are required for request <> schema validation operations.|VALIDATION
1414
validationPropertiesToIgnore|array|-|[]|Specific properties (parts of a request/response pair) to ignore during validation. Must be sent as an array of strings. Valid inputs in the array: PATHVARIABLE, QUERYPARAM, HEADER, BODY, RESPONSE_HEADER, RESPONSE_BODY|VALIDATION
1515
showMissingInSchemaErrors|boolean|-|false|MISSING_IN_SCHEMA indicates that an extra parameter was included in the request. For most use cases, this need not be considered an error.|VALIDATION
@@ -19,7 +19,7 @@ validateMetadata|boolean|-|false|Whether to show mismatches for incorrect name a
1919
ignoreUnresolvedVariables|boolean|-|false|Whether to ignore mismatches resulting from unresolved variables in the Postman request|VALIDATION
2020
strictRequestMatching|boolean|-|false|Whether requests should be strictly matched with schema operations. Setting to true will not include any matches where the URL path segments don't match exactly.|VALIDATION
2121
allowUrlPathVarMatching|boolean|-|false|Whether to allow matching path variables that are available as part of URL itself in the collection request|VALIDATION
22-
disableOptionalParameters|boolean|-|false|Whether to set optional parameters as disabled|CONVERSION
22+
enableOptionalParameters|boolean|-|true|Optional parameters aren't selected in the collection. Once enabled they will be selected in the collection and request as well.|CONVERSION
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

lib/options.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
type: 'enum',
7676
default: 'Space',
7777
availableOptions: ['Space', 'Tab'],
78-
description: 'Option for setting indentation character',
78+
description: 'Option for setting indentation character.',
7979
external: true,
8080
usage: ['CONVERSION'],
8181
supportedIn: [VERSION20, VERSION30, VERSION31]
@@ -168,7 +168,7 @@ module.exports = {
168168
id: 'includeAuthInfoInExample',
169169
type: 'boolean',
170170
default: true,
171-
description: 'Select whether to include authentication parameters in the example request',
171+
description: 'Select whether to include authentication parameters in the example request.',
172172
external: true,
173173
usage: ['CONVERSION'],
174174
supportedIn: [VERSION20, VERSION30, VERSION31]
@@ -270,11 +270,12 @@ module.exports = {
270270
usage: ['VALIDATION']
271271
},
272272
{
273-
name: 'Disable optional parameters',
274-
id: 'disableOptionalParameters',
273+
name: 'Enable optional parameters',
274+
id: 'enableOptionalParameters',
275275
type: 'boolean',
276-
default: false,
277-
description: 'Whether to set optional parameters as disabled',
276+
default: true,
277+
description: 'Optional parameters aren\'t selected in the collection. ' +
278+
'Once enabled they will be selected in the collection and request as well.',
278279
external: true,
279280
usage: ['CONVERSION'],
280281
supportedIn: [VERSION20, VERSION30, VERSION31]

lib/schemaUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@ module.exports = {
17491749
let { style, explode, startValue, propSeparator, keyValueSeparator, isExplodable } =
17501750
this.getParamSerialisationInfo(param, parameterSource, components);
17511751

1752-
if (options && options.disableOptionalParameters) {
1752+
if (options && !options.enableOptionalParameters) {
17531753
disabled = !param.required;
17541754
}
17551755

test/system/structure.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const optionIds = [
2222
'ignoreUnresolvedVariables',
2323
'optimizeConversion',
2424
'strictRequestMatching',
25-
'disableOptionalParameters',
25+
'enableOptionalParameters',
2626
'keepImplicitHeaders',
2727
'includeWebhooks',
2828
'allowUrlPathVarMatching',
@@ -77,7 +77,7 @@ const optionIds = [
7777
type: 'enum',
7878
default: 'Space',
7979
availableOptions: ['Space', 'Tab'],
80-
description: 'Option for setting indentation character'
80+
description: 'Option for setting indentation character.'
8181
},
8282
requestNameSource: {
8383
name: 'Naming requests',
@@ -106,7 +106,7 @@ const optionIds = [
106106
name: 'Include auth info in example requests',
107107
type: 'boolean',
108108
default: true,
109-
description: 'Select whether to include authentication parameters in the example request'
109+
description: 'Select whether to include authentication parameters in the example request.'
110110
},
111111
shortValidationErrors: {
112112
name: 'Short error messages during request <> schema validation',
@@ -162,11 +162,12 @@ const optionIds = [
162162
description: 'Whether requests should be strictly matched with schema operations. Setting to true will not ' +
163163
'include any matches where the URL path segments don\'t match exactly.'
164164
},
165-
disableOptionalParameters: {
166-
name: 'Disable optional parameters',
165+
enableOptionalParameters: {
166+
name: 'Enable optional parameters',
167167
type: 'boolean',
168-
default: false,
169-
description: 'Whether to set optional parameters as disabled'
168+
default: true,
169+
description: 'Optional parameters aren\'t selected in the collection. ' +
170+
'Once enabled they will be selected in the collection and request as well.'
170171
},
171172
keepImplicitHeaders: {
172173
name: 'Keep implicit headers',

test/unit/base.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
10801080
});
10811081

10821082
it('[Github #31] & [GitHub #337] - should set optional params as disabled', function(done) {
1083-
let options = { schemaFaker: true, disableOptionalParameters: true };
1083+
let options = { schemaFaker: true, enableOptionalParameters: false };
10841084
Converter.convert({ type: 'file', data: requiredInParams }, options, (err, conversionResult) => {
10851085
expect(err).to.be.null;
10861086
let requests = conversionResult.output[0].data.item[0].item,

0 commit comments

Comments
 (0)