Skip to content

Commit d4efdd8

Browse files
committed
Merge branch 'release/4.8.0'
2 parents 0ce4b5e + ae05418 commit d4efdd8

File tree

9 files changed

+133
-22
lines changed

9 files changed

+133
-22
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# OpenAPI-Postman Changelog
22

3+
#### v4.8.0 (January 24, 2023)
4+
* Added specifictionVersion field to validate result.
5+
36
#### v4.7.0 (January 16, 2023)
47
* Fixed an issue where same schema was being validated against examples multiple times during a conversion - using local cache here.
58
* Added a way to return analytics along with the result for better observability into the kind of schemas we get for conversion.

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

lib/schemapack.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ class SchemaPack {
142142
this.openapi = specParseResult.openapi;
143143
this.validated = true;
144144
this.validationResult = {
145-
result: true
145+
result: true,
146+
specificationVersion: concreteUtils.version
146147
};
147148
return this.validationResult;
148149
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-to-postmanv2",
3-
"version": "4.7.1",
3+
"version": "4.8.0",
44
"description": "Convert a given OpenAPI specification to Postman Collection v2.0",
55
"homepage": "https://github.com/postmanlabs/openapi-to-postman",
66
"bugs": "https://github.com/postmanlabs/openapi-to-postman/issues",

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: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ var expect = require('chai').expect,
77
VALID_OPENAPI_PATH = '../data/valid_openapi',
88
INVALID_OPENAPI_PATH = '../data/invalid_openapi',
99
SWAGGER_20_FOLDER_YAML = '../data/valid_swagger/yaml/',
10-
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/';
10+
SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/',
11+
VALID_OPENAPI_3_1_FOLDER_JSON = '../data/valid_openapi31X/json',
12+
VALID_OPENAPI_3_1_FOLDER_YAML = '../data/valid_openapi31X/yaml';
1113

1214
describe('CONVERT FUNCTION TESTS ', function() {
1315
// these two covers remaining part of util.js
@@ -1080,7 +1082,7 @@ describe('CONVERT FUNCTION TESTS ', function() {
10801082
});
10811083

10821084
it('[Github #31] & [GitHub #337] - should set optional params as disabled', function(done) {
1083-
let options = { schemaFaker: true, disableOptionalParameters: true };
1085+
let options = { schemaFaker: true, enableOptionalParameters: false };
10841086
Converter.convert({ type: 'file', data: requiredInParams }, options, (err, conversionResult) => {
10851087
expect(err).to.be.null;
10861088
let requests = conversionResult.output[0].data.item[0].item,
@@ -2011,6 +2013,109 @@ describe('INTERFACE FUNCTION TESTS ', function () {
20112013
});
20122014
});
20132015
});
2016+
2017+
describe('The converter must identify valid OA3 specification', function () {
2018+
var pathPrefix = VALID_OPENAPI_PATH,
2019+
sampleSpecs = fs.readdirSync(path.join(__dirname, pathPrefix)),
2020+
oa31Files = ['issue#479_2.yaml', 'issue#10229.json', 'query_param_with_enum_resolve_as_example.json'];
2021+
2022+
sampleSpecs.map((sample) => {
2023+
if (!oa31Files.includes(sample)) {
2024+
var specPath = path.join(__dirname, pathPrefix, sample);
2025+
2026+
it(specPath + ' is valid ', function(done) {
2027+
var openapi = fs.readFileSync(specPath, 'utf8'),
2028+
validationResult = Converter.validate({ type: 'string', data: openapi });
2029+
2030+
expect(validationResult.result).to.equal(true);
2031+
expect(validationResult.specificationVersion).to.equal('3.0.x');
2032+
done();
2033+
});
2034+
}
2035+
});
2036+
});
2037+
2038+
describe('The converter must identify valid OA2 specifications - JSON', function () {
2039+
var pathPrefix = SWAGGER_20_FOLDER_JSON,
2040+
sampleSpecs = fs.readdirSync(path.join(__dirname, pathPrefix));
2041+
2042+
sampleSpecs.map((sample) => {
2043+
var specPath = path.join(__dirname, pathPrefix, sample);
2044+
2045+
it(specPath + ' is valid ', function(done) {
2046+
var openapi = fs.readFileSync(specPath, 'utf8'),
2047+
validationResult = Converter.validate({ type: 'string', data: openapi });
2048+
2049+
expect(validationResult.result).to.equal(true);
2050+
expect(validationResult.specificationVersion).to.equal('2.0');
2051+
done();
2052+
});
2053+
});
2054+
});
2055+
2056+
describe('The converter must identify valid OA3.1 specifications - JSON', function () {
2057+
var pathPrefix = VALID_OPENAPI_3_1_FOLDER_JSON,
2058+
sampleSpecs = fs.readdirSync(path.join(__dirname, pathPrefix)),
2059+
oa30Files = ['deprecated_property.json'],
2060+
incorrectOA31Files = ['webhooks.json'],
2061+
filesToIgnore = oa30Files + incorrectOA31Files;
2062+
2063+
2064+
sampleSpecs.map((sample) => {
2065+
if (!filesToIgnore.includes(sample)) {
2066+
var specPath = path.join(__dirname, pathPrefix, sample);
2067+
2068+
it(specPath + ' is valid ', function(done) {
2069+
var openapi = fs.readFileSync(specPath, 'utf8'),
2070+
validationResult = Converter.validate({ type: 'string', data: openapi });
2071+
2072+
expect(validationResult.result).to.equal(true);
2073+
expect(validationResult.specificationVersion).to.equal('3.1.x');
2074+
done();
2075+
});
2076+
}
2077+
});
2078+
});
2079+
2080+
describe('The converter must identify valid OA3.1 specifications - YAML', function () {
2081+
var pathPrefix = VALID_OPENAPI_3_1_FOLDER_YAML,
2082+
sampleSpecs = fs.readdirSync(path.join(__dirname, pathPrefix)),
2083+
invalidOA31Files = ['marketPayNotificationService4.yaml'];
2084+
2085+
sampleSpecs.map((sample) => {
2086+
if (!invalidOA31Files.includes(sample)) {
2087+
var specPath = path.join(__dirname, pathPrefix, sample);
2088+
2089+
it(specPath + ' is valid ', function(done) {
2090+
var openapi = fs.readFileSync(specPath, 'utf8'),
2091+
validationResult = Converter.validate({ type: 'string', data: openapi });
2092+
2093+
expect(validationResult.result).to.equal(true);
2094+
expect(validationResult.specificationVersion).to.equal('3.1.x');
2095+
done();
2096+
});
2097+
}
2098+
});
2099+
});
2100+
2101+
describe('The converter must identify valid OA2 specifications - YAML', function () {
2102+
var pathPrefix = SWAGGER_20_FOLDER_YAML,
2103+
sampleSpecs = fs.readdirSync(path.join(__dirname, pathPrefix));
2104+
2105+
sampleSpecs.map((sample) => {
2106+
var specPath = path.join(__dirname, pathPrefix, sample);
2107+
2108+
it(specPath + ' is valid ', function(done) {
2109+
var openapi = fs.readFileSync(specPath, 'utf8'),
2110+
validationResult = Converter.validate({ type: 'string', data: openapi });
2111+
2112+
expect(validationResult.result).to.equal(true);
2113+
expect(validationResult.specificationVersion).to.equal('2.0');
2114+
done();
2115+
});
2116+
});
2117+
});
2118+
20142119
describe('The converter must identify invalid specifications', function () {
20152120
var pathPrefix = INVALID_OPENAPI_PATH,
20162121
sampleSpecs = fs.readdirSync(path.join(__dirname, pathPrefix));

0 commit comments

Comments
 (0)