Skip to content

Commit 1a38668

Browse files
authored
Merge pull request #92 from postmanlabs/release/v0.4.0
Release version v0.4.0
2 parents 043a63b + c5556f3 commit 1a38668

File tree

7 files changed

+67
-49
lines changed

7 files changed

+67
-49
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44

5+
## [v0.4.0] - 2024-07-10
6+
7+
### Chore
8+
9+
- Updated postman-collection to v4.4.0.
10+
511
## [v0.3.0] - 2024-06-07
612

713
### Fixed
@@ -71,7 +77,9 @@ Newer releases follow the [Keep a Changelog](https://keepachangelog.com/en/1.0.0
7177

7278
- Base release
7379

74-
[Unreleased]: https://github.com/postmanlabs/raml1-to-postman/compare/v0.3.0...HEAD
80+
[Unreleased]: https://github.com/postmanlabs/raml1-to-postman/compare/v0.4.0...HEAD
81+
82+
[v0.4.0]: https://github.com/postmanlabs/raml1-to-postman/compare/v0.3.0...v0.4.0
7583

7684
[v0.3.0]: https://github.com/postmanlabs/raml1-to-postman/compare/v0.2.0...v0.3.0
7785

lib/convert.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const raml = require('./../assets/raml-1-parser'),
22
_ = require('lodash'),
33
fs = require('fs'),
44
path = require('path-browserify'),
5-
SDK = require('postman-collection'),
5+
{ Collection } = require('postman-collection/lib/collection/collection'),
6+
{ Variable } = require('postman-collection/lib/collection/variable'),
67
helper = require('./helper.js'),
78
getOptions = require('./options').getOptions,
89
{ Node, Trie } = require('./trie.js'),
@@ -167,7 +168,7 @@ var converter = {
167168
}
168169
}
169170

170-
let collection = new SDK.Collection(),
171+
let collection = new Collection(),
171172
content = browser ? fileDataResolver : fileResolver,
172173
ramlAPI,
173174
ramlJSON,
@@ -226,7 +227,7 @@ var converter = {
226227
});
227228

228229
// convrtedBaseUrl is URL containing baseUrl in form of PM collection variable
229-
convertedBaseUrl = new SDK.Variable({
230+
convertedBaseUrl = new Variable({
230231
key: 'baseUrl',
231232
value: '{{baseUrl}}',
232233
type: 'string'

lib/helper.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
const SDK = require('postman-collection'),
2-
_ = require('lodash'),
1+
const _ = require('lodash'),
2+
{ QueryParam } = require('postman-collection/lib/collection/query-param'),
3+
{ Header } = require('postman-collection/lib/collection/header'),
4+
{ ItemGroup } = require('postman-collection/lib/collection/item-group'),
5+
{ Item } = require('postman-collection/lib/collection/item'),
6+
{ FormParam } = require('postman-collection/lib/collection/form-param'),
7+
{ RequestAuth } = require('postman-collection/lib/collection/request-auth'),
8+
{ Request } = require('postman-collection/lib/collection/request.js'),
9+
{ Response } = require('postman-collection/lib/collection/response'),
10+
{ RequestBody } = require('postman-collection/lib/collection/request-body'),
11+
{ Url } = require('postman-collection/lib/collection/url'),
12+
{ Variable } = require('postman-collection/lib/collection/variable'),
313
schemaFaker = require('../assets/json-schema-faker.js'),
414
resolver = require('./resolver.js'),
515
Node = require('./trie.js').Node,
@@ -193,7 +203,7 @@ helper = {
193203
* @returns {Object} convertedHeader - postman sdk header object
194204
*/
195205
convertHeader: function(header, types, resolveTo) {
196-
let convertedHeader = new SDK.Header(),
206+
let convertedHeader = new Header(),
197207
fakedHeader = safeSchemaFaker(header, types, resolveTo);
198208

199209
convertedHeader.key = header.name;
@@ -273,7 +283,7 @@ helper = {
273283
param,
274284
paramArray = [],
275285
updateOptions = {},
276-
reqBody = new SDK.RequestBody(),
286+
reqBody = new RequestBody(),
277287
contentHeader,
278288
rDataMode,
279289
cType;
@@ -293,7 +303,7 @@ helper = {
293303

294304
// create query parameters and add it to the request body object
295305
_.forOwn(bodyData, (value, key) => {
296-
param = new SDK.QueryParam({
306+
param = new QueryParam({
297307
key: key,
298308
value: (typeof value === 'object' ? JSON.stringify(value) : value)
299309
});
@@ -306,7 +316,7 @@ helper = {
306316
};
307317

308318
// add a content type header for each media type for the request body
309-
contentHeader = new SDK.Header({
319+
contentHeader = new Header({
310320
key: 'Content-Type',
311321
value: URLENCODED
312322
});
@@ -320,7 +330,7 @@ helper = {
320330

321331
// create the form parameters and add it to the request body object
322332
_.forOwn(bodyData, (value, key) => {
323-
param = new SDK.FormParam({
333+
param = new FormParam({
324334
key: key,
325335
value: (typeof value === 'object' ? JSON.stringify(value) : value)
326336
});
@@ -332,7 +342,7 @@ helper = {
332342
formdata: paramArray
333343
};
334344
// add a content type header for the pertaining media type
335-
contentHeader = new SDK.Header({
345+
contentHeader = new Header({
336346
key: 'Content-Type',
337347
value: FORM_DATA
338348
});
@@ -387,7 +397,7 @@ helper = {
387397
}
388398
};
389399

390-
contentHeader = new SDK.Header({
400+
contentHeader = new Header({
391401
key: 'Content-Type',
392402
value: bodyType
393403
});
@@ -463,7 +473,7 @@ helper = {
463473
responseHeaders.push(contentHeader);
464474
}
465475

466-
convertedResponse = new SDK.Response({
476+
convertedResponse = new Response({
467477
name: res.name || res.code,
468478
code: res.code ? Number(res.code) : 500,
469479
header: responseHeaders,
@@ -561,7 +571,7 @@ helper = {
561571
* @returns {Object} auth - postman sdk RequestAuth object
562572
*/
563573
convertSecurityScheme: function(securedBy, securitySchemes) {
564-
let auth = new SDK.RequestAuth();
574+
let auth = new RequestAuth();
565575

566576
// map RAML schema security schema and PM request auths. set null by default.
567577
auth.type = _.get(authTypeMap, _.get(securitySchemes[securedBy], 'type'), null);
@@ -588,14 +598,14 @@ helper = {
588598
_.forOwn(variablesToAdd, (value, key) => {
589599
// 'version' is reserved base URI parameter for RAML 1.0, value of it recieved in enum so special handling
590600
if (key === 'version') {
591-
variables.push(new SDK.Variable({
601+
variables.push(new Variable({
592602
id: key,
593603
value: _.get(value, 'enum[0]', ''),
594604
description: value.description || 'This is version of API schema.'
595605
}));
596606
}
597607
else {
598-
variables.push(new SDK.Variable({
608+
variables.push(new Variable({
599609
id: key,
600610
value: value.default || _.get(value.enum, '[0]') || '',
601611
description: value.description + (value.enum ? ' (is one of ' + value.enum + ')' : '')
@@ -606,7 +616,7 @@ helper = {
606616
});
607617
}
608618
if (keyName) {
609-
variables.push(new SDK.Variable({
619+
variables.push(new Variable({
610620
id: keyName,
611621
value: convertedBaseUrl,
612622
type: 'string'
@@ -629,8 +639,8 @@ helper = {
629639
* @returns {Object} request - postman sdk request object
630640
*/
631641
convertToPmRequest: function(method, url, globalParameters, options, pathVariables) {
632-
let request = new SDK.Request(),
633-
requestUrl = new SDK.Url(),
642+
let request = new Request(),
643+
requestUrl = new Url(),
634644
securedBy = method.securedBy || globalParameters.securedBy,
635645
pmRequestBody;
636646

@@ -684,7 +694,7 @@ helper = {
684694
* @returns {Object} item - postman sdk item object
685695
*/
686696
convertRequestToItem: function (method, url, globalParameters, options, pathVariables) {
687-
let item = new SDK.Item(),
697+
let item = new Item(),
688698
requestName = _.get(method, 'displayName', url.replace('{{baseUrl}}', '')),
689699
pmRequest = helper.convertToPmRequest(method, url, globalParameters, options, pathVariables),
690700
optionsForResponse;
@@ -758,7 +768,7 @@ helper = {
758768
* @returns {Object} folder - postman sdk ItemGroup object
759769
*/
760770
convertResources: function(baseUrl, res, globalParameters, options, pathVariables = []) {
761-
var folder = new SDK.ItemGroup(),
771+
var folder = new ItemGroup(),
762772
url,
763773
// used to store url after path variables of url is resolved
764774
convertedBaseUrl = _.cloneDeepWith(baseUrl),
@@ -845,7 +855,7 @@ helper = {
845855
if (resource.requestCount > 1 || !resource.collapsible) {
846856
// only return a Postman folder if this folder has>1 children in its subtree or it's not collapsible
847857
// otherwise we can end up with 10 levels of unwanted folders with 1 request in the end
848-
itemGroup = new SDK.ItemGroup({
858+
itemGroup = new ItemGroup({
849859
name: displayName === relativeUrl ? resource.name : displayName,
850860
description: _.get(resource, 'resourceInfo.description', '')
851861
});

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raml1-to-postman",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Converts RAML 1.0 files to postman v2 collection",
55
"homepage": "https://github.com/postmanlabs/raml1-to-postman",
66
"bugs": "https://github.com/postmanlabs/raml1-to-postman/issues",
@@ -43,7 +43,7 @@
4343
"async": "3.2.5",
4444
"lodash": "4.17.21",
4545
"path-browserify": "1.0.1",
46-
"postman-collection": "4.2.1"
46+
"postman-collection": "^4.4.0"
4747
},
4848
"devDependencies": {
4949
"chai": "4.1.2",

test/system/repository.test.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ describe('project repository', function () {
4444
expect(json.dependencies).to.be.a('object');
4545
});
4646

47-
it('must point to a valid and precise (no * or ^) semver', function () {
48-
for (let item in json.dependencies) {
49-
expect(json.dependencies[item]).to.match(new RegExp('^((\\d+)\\.(\\d+)\\.(\\d+))(?:-' +
50-
// eslint-disable-next-line max-len
51-
'([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?(?:\\+([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?$|^git\+.*.+$'));
52-
}
47+
it('should have a valid version string in form of <major>.<minor>.<revision>', function () {
48+
expect(json.version)
49+
// eslint-disable-next-line max-len, security/detect-unsafe-regex
50+
.to.match(/^((\d+)\.(\d+)\.(\d+))(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/);
5351
});
5452
});
5553

@@ -58,12 +56,12 @@ describe('project repository', function () {
5856
expect(json.devDependencies).to.be.a('object');
5957
});
6058

61-
it('must point to a valid and precise (no * or ^) semver', function () {
62-
for (let item in json.devDependencies) {
63-
expect(json.devDependencies[item]).to.match(new RegExp('^((\\d+)\\.(\\d+)\\.(\\d+))(?:-' +
64-
// eslint-disable-next-line max-len
65-
'([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?(?:\\+([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?$|^git\+.*.+$'));
66-
}
59+
it('should point to a valid semver', function () {
60+
Object.keys(json.devDependencies).forEach(function (dependencyName) {
61+
// eslint-disable-next-line security/detect-non-literal-regexp
62+
expect(json.devDependencies[dependencyName]).to.match(new RegExp('((\\d+)\\.(\\d+)\\.(\\d+))(?:-' +
63+
'([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?(?:\\+([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?$'));
64+
});
6765
});
6866
});
6967

test/unit/converter.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const expect = require('chai').expect,
22
fs = require('fs'),
33
converter = require('../../index'),
44
helper = require('./../../lib/helper.js'),
5-
SDK = require('postman-collection'),
5+
{ Collection } = require('postman-collection/lib/collection/collection'),
6+
{ Header } = require('postman-collection/lib/collection/header'),
67
VALID_RAML_DIR_PATH = './test/fixtures/valid-raml',
78
INVALID_VERSION_PATH = './test/fixtures/invalid-raml/invalidVersion.raml';
89

@@ -126,7 +127,7 @@ describe('helper functions', function() {
126127
description: 'This is the description.',
127128
version: '1.1'
128129
},
129-
collection = new SDK.Collection(),
130+
collection = new Collection(),
130131
modified_collection = helper.setCollectionInfo(info, collection);
131132

132133
expect(modified_collection.name).to.equal('My sample api');
@@ -252,7 +253,7 @@ describe('helper functions', function() {
252253
types = {},
253254
postmanHeader = helper.convertHeader(ramlHeader, types, 'schema');
254255

255-
expect(SDK.Header.isHeader(postmanHeader)).to.be.true;
256+
expect(Header.isHeader(postmanHeader)).to.be.true;
256257
expect(postmanHeader.disabled).to.be.true;
257258
});
258259

0 commit comments

Comments
 (0)