Skip to content

Commit 3044fb8

Browse files
authored
Merge pull request #901 from postmanlabs/release/v5.4.0
Release version v5.4.0
2 parents e6b51b1 + b5e67a9 commit 3044fb8

File tree

11 files changed

+591
-21
lines changed

11 files changed

+591
-21
lines changed

CHANGELOG.md

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

33
## [Unreleased]
44

5+
## [v5.4.0] - 2025-11-13
6+
57
## [v5.3.5] - 2025-11-10
68

79
## [v5.3.4] - 2025-11-06
@@ -675,7 +677,9 @@ Newer releases follow the [Keep a Changelog](https://keepachangelog.com/en/1.0.0
675677

676678
- Base release
677679

678-
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.3.5...HEAD
680+
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.4.0...HEAD
681+
682+
[v5.4.0]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.3.5...v5.4.0
679683

680684
[v5.3.5]: https://github.com/postmanlabs/openapi-to-postman/compare/v5.3.4...v5.3.5
681685

assets/validationRequestListSchema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
"type": "integer"
268268
}
269269
},
270-
"required": ["id", "code"]
270+
"required": ["id"]
271271
}
272272
}
273273
},

lib/common/schemaUtilsCommon.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
const parse = require('../parse.js'),
66
_ = require('lodash'),
7+
DEFAULT_RESPONSE_CODE_IN_OAS = 'default',
78
typesMap = {
89
integer: {
910
int32: '<integer>',
@@ -208,6 +209,7 @@ function checkIsCorrectType(value, schema) {
208209
}
209210

210211
module.exports = {
212+
DEFAULT_RESPONSE_CODE_IN_OAS,
211213

212214
/**
213215
* Parses an OAS string/object as a YAML or JSON

libV2/schemaUtils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const schemaFaker = require('../assets/json-schema-faker'),
66
mergeAllOf = require('json-schema-merge-allof'),
77
xmlFaker = require('./xmlSchemaFaker.js'),
88
URLENCODED = 'application/x-www-form-urlencoded',
9+
{ DEFAULT_RESPONSE_CODE_IN_OAS } = require('../lib/common/schemaUtilsCommon.js'),
910
APP_JSON = 'application/json',
1011
APP_JS = 'application/javascript',
1112
TEXT_XML = 'text/xml',
@@ -2693,9 +2694,9 @@ let QUERYPARAM = 'query',
26932694

26942695
// replace 'X' char in code with '0' | E.g. 5xx -> 500
26952696
code = code.replace(/X|x/g, '0');
2696-
code = code === 'default' ? 500 : _.toSafeInteger(code);
2697+
code = code === DEFAULT_RESPONSE_CODE_IN_OAS ? undefined : _.toSafeInteger(code);
26972698

2698-
Object.assign(responseTypes, { [code]: responseBodyHeaderObj });
2699+
Object.assign(responseTypes, { [code || DEFAULT_RESPONSE_CODE_IN_OAS]: responseBodyHeaderObj });
26992700

27002701
_.forOwn(resolvedExamples, (resolvedExample = {}) => {
27012702
let { body, contentHeader = [], bodyType, acceptHeader, name } = resolvedExample,

libV2/validationUtils.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const _ = require('lodash'),
2222
ajvValidationError = require('../lib/ajValidation/ajvValidationError'),
2323
{ validateSchema } = require('../lib/ajValidation/ajvValidation'),
2424
{ formatDataPath, checkIsCorrectType, isKnownType,
25-
getServersPathVars } = require('../lib/common/schemaUtilsCommon.js'),
25+
getServersPathVars, DEFAULT_RESPONSE_CODE_IN_OAS } = require('../lib/common/schemaUtilsCommon.js'),
2626

2727
{ findMatchingRequestFromSchema, isPmVariable } = require('./requestMatchingUtils'),
2828

@@ -2424,7 +2424,7 @@ function checkResponses (context, transaction, transactionPathPrefix, schemaPath
24242424
// loop through all responses
24252425
// for each response, find the appropriate response from schemaPath, and then validate response body and headers
24262426
async.map(responses, (response, responseCallback) => {
2427-
let thisResponseCode = _.toString(response.code),
2427+
let thisResponseCode = _.toString(response.code) || DEFAULT_RESPONSE_CODE_IN_OAS,
24282428
thisSchemaResponse = _.get(schemaPath, ['responses', thisResponseCode], _.get(schemaPath, 'responses.default')),
24292429
responsePathPrefix = thisResponseCode;
24302430

@@ -2503,8 +2503,6 @@ function checkResponses (context, transaction, transactionPathPrefix, schemaPath
25032503
missingResponses = [];
25042504

25052505
_.each(_.get(schemaPath, 'responses'), (responseObj, responseCode) => {
2506-
responseCode = responseCode === 'default' ? '500' : responseCode;
2507-
25082506
if (!_.includes(matchedResponses, responseCode)) {
25092507
let mismatchObj = {
25102508
property: 'RESPONSE',

package-lock.json

Lines changed: 2 additions & 2 deletions
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": "5.3.5",
3+
"version": "5.4.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/data/validationData/ignoreUnresolvedVariablesCollection.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
}
9797
},
9898
"status": "Internal Server Error",
99-
"code": 500,
10099
"header": [
101100
{
102101
"key": "Content-Type",

test/unit/ValidateV2.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function getFoldersByVersion(folder30Path, folder31Path) {
103103

104104
describe('Validate with servers', function () {
105105

106-
it('Fix for GITHUB#496: Should identify url with fragment', function () {
106+
it('Fix for GITHUB#496: Should identify url with fragment', function (done) {
107107
const openAPI = path.join(__dirname, VALID_OPENAPI_FOLDER_PATH + '/explicit_server_in_path.json'),
108108
openAPIData = fs.readFileSync(openAPI, 'utf8'),
109109
options = {
@@ -136,6 +136,8 @@ describe('Validate with servers', function () {
136136
expect(result.requests[requestId].endpoints[0]).to.not.be.undefined;
137137
expect(result.requests[requestId].endpoints[0].matched).to.be.true;
138138
});
139+
140+
done();
139141
});
140142
});
141143
});

test/unit/convertV2.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,13 +2723,13 @@ describe('The convert v2 Function', function() {
27232723
expect(JSON.parse(item.response[1].body)).to.eql(okResExample);
27242724

27252725
expect(item.response[2].name).to.eql('ok_example');
2726-
expect(item.response[2].code).to.eql(500);
2726+
expect(item.response[2].code).to.eql(undefined);
27272727
expect(item.response[2]._postman_previewlanguage).to.eql('json');
27282728
expect(JSON.parse(item.response[2].originalRequest.body.raw)).to.eql(okReqExample);
27292729
expect(JSON.parse(item.response[2].body)).to.eql(failResExample);
27302730

27312731
expect(item.response[3].name).to.eql('not_ok_example');
2732-
expect(item.response[3].code).to.eql(500);
2732+
expect(item.response[3].code).to.eql(undefined);
27332733
expect(item.response[3]._postman_previewlanguage).to.eql('json');
27342734
expect(JSON.parse(item.response[3].originalRequest.body.raw)).to.eql(failReqExample);
27352735
expect(JSON.parse(item.response[3].body)).to.eql(failResExample);

0 commit comments

Comments
 (0)