Skip to content

Commit e35074c

Browse files
author
Vishal Shingala
committed
Merge branch 'release/v4.0.0' of github.com:postmanlabs/openapi-to-postman
2 parents 215a5da + db90b43 commit e35074c

File tree

424 files changed

+30548
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+30548
-240
lines changed

CHANGELOG.md

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

3+
#### v4.0.0 (July 12, 2022)
4+
* Added support for new multi-file API detectRootFiles() for OpenAPI 3 and Swagger 2 formats to support detection of root files among multiple files.
5+
* Added support for new multi-file API detectRelatedFiles() for OpenAPI 3 and Swagger 2 formats to support detection of related files for a provided root file amongst multiple files.
6+
* Added support for new multi-file API bundle() for OpenAPI 3 and Swagger 2 formats to support bundling of root files from provided multiple files.
7+
38
#### v3.2.0 (May 02, 2022)
49
* Fixed some of critical and high level severity vulnerabilities.
510
* Fixed issue [#10752](https://github.com/postmanlabs/postman-app-support/issues/10752) where deepObject style parameters were not generated correctly.

OPTIONS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ allowUrlPathVarMatching|boolean|-|false|Whether to allow matching path variables
2222
disableOptionalParameters|boolean|-|false|Whether to set optional parameters as disabled|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
25+
includeReferenceMap|boolean|-|false|Whether or not to include reference map or not as part of output|BUNDLE

index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
const SchemaPack = require('./lib/schemapack.js').SchemaPack;
3+
const _ = require('lodash'),
4+
SchemaPack = require('./lib/schemapack.js').SchemaPack;
45

56
module.exports = {
67
// Old API wrapping the new API
@@ -32,6 +33,21 @@ module.exports = {
3233
return SchemaPack.getOptions(mode, criteria);
3334
},
3435

36+
detectRootFiles: async function(input) {
37+
var schema = new SchemaPack(input);
38+
return schema.detectRootFiles();
39+
},
40+
41+
detectRelatedFiles: async function(input) {
42+
var schema = new SchemaPack(input);
43+
return schema.detectRelatedFiles();
44+
},
45+
46+
bundle: async function(input) {
47+
var schema = new SchemaPack(input, _.has(input, 'options') ? input.options : {});
48+
return schema.bundle();
49+
},
50+
3551
// new API
3652
SchemaPack
3753
};

lib/30XUtils/inputValidation.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const _ = require('lodash');
12
module.exports = {
23

34
/**
@@ -7,37 +8,43 @@ module.exports = {
78
* @return {Object} Validation result
89
*/
910
validateSpec: function (spec) {
10-
11+
if (_.isNil(spec)) {
12+
return {
13+
result: false,
14+
reason: 'The Specification is null or undefined'
15+
};
16+
}
1117
// Checking for the all the required properties in the specification
12-
if (!spec.hasOwnProperty('openapi')) {
18+
if (_.isNil(spec.openapi)) {
1319
return {
1420
result: false,
1521
reason: 'Specification must contain a semantic version number of the OAS specification'
1622
};
1723
}
1824

19-
if (!spec.hasOwnProperty('paths')) {
25+
if (_.isNil(spec.paths)) {
2026
return {
2127
result: false,
2228
reason: 'Specification must contain Paths Object for the available operational paths'
2329
};
2430
}
2531

26-
if (!spec.hasOwnProperty('info')) {
32+
if (_.isNil(spec.info)) {
2733
return {
2834
result: false,
2935
reason: 'Specification must contain an Info Object for the meta-data of the API'
3036
};
3137
}
38+
3239
if (!spec.info.hasOwnProperty('$ref')) {
33-
if (!spec.info.hasOwnProperty('title')) {
40+
if (_.isNil(_.get(spec, 'info.title'))) {
3441
return {
3542
result: false,
3643
reason: 'Specification must contain a title in order to generate a collection'
3744
};
3845
}
3946

40-
if (!spec.info.hasOwnProperty('version')) {
47+
if (_.isNil(_.get(spec, 'info.version'))) {
4148
return {
4249
result: false,
4350
reason: 'Specification must contain a semantic version number of the API in the Info Object'

lib/30XUtils/schemaUtils30X.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ module.exports = {
99
/**
1010
* Parses an OAS string/object as a YAML or JSON
1111
* @param {YAML/JSON} openApiSpec - The OAS 3.x specification specified in either YAML or JSON
12+
* @param {object} options - The parsing options
1213
* @returns {Object} - Contains the parsed JSON-version of the OAS spec, or an error
1314
* @no-unit-test
1415
*/
15-
parseSpec: function (openApiSpec) {
16-
return schemaUtilsCommon.parseSpec(openApiSpec, inputValidation30X);
16+
parseSpec: function (openApiSpec, options) {
17+
return schemaUtilsCommon.parseSpec(openApiSpec, inputValidation30X, options);
1718
},
1819

1920
/**

lib/31XUtils/inputValidation31X.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
const _ = require('lodash');
22
module.exports = {
33

44
/**
@@ -11,29 +11,51 @@ module.exports = {
1111
*/
1212
validateSpec: function (spec, options) {
1313
const includeWebhooksOption = options.includeWebhooks;
14-
if (!spec.hasOwnProperty('openapi')) {
14+
if (_.isNil(spec)) {
15+
return {
16+
result: false,
17+
reason: 'The Specification is null or undefined'
18+
};
19+
}
20+
if (_.isNil(spec.openapi)) {
1521
return {
1622
result: false,
1723
reason: 'Specification must contain a semantic version number of the OAS specification'
1824
};
1925
}
2026

21-
if (!spec.hasOwnProperty('info')) {
27+
if (_.isNil(spec.info)) {
2228
return {
2329
result: false,
2430
reason: 'Specification must contain an Info Object for the meta-data of the API'
2531
};
2632
}
2733

28-
if (!spec.hasOwnProperty('paths') && !includeWebhooksOption) {
34+
if (!spec.info.hasOwnProperty('$ref')) {
35+
if (_.isNil(_.get(spec, 'info.title'))) {
36+
return {
37+
result: false,
38+
reason: 'Specification must contain a title in order to generate a collection'
39+
};
40+
}
41+
42+
if (_.isNil(_.get(spec, 'info.version'))) {
43+
return {
44+
result: false,
45+
reason: 'Specification must contain a semantic version number of the API in the Info Object'
46+
};
47+
}
48+
}
49+
50+
if (_.isNil(spec.paths) && !includeWebhooksOption) {
2951
return {
3052
result: false,
3153
reason: 'Specification must contain Paths Object for the available operational paths'
3254
};
3355
}
3456

35-
if (includeWebhooksOption && !spec.hasOwnProperty('paths') &&
36-
!spec.hasOwnProperty('webhooks') && !spec.hasOwnProperty('components')) {
57+
if (includeWebhooksOption && _.isNil(spec.paths) &&
58+
_.isNil(spec.webhooks) && _.isNil(spec.components)) {
3759
return {
3860
result: false,
3961
reason: 'Specification must contain either Paths, Webhooks or Components sections'

0 commit comments

Comments
 (0)