Skip to content

Commit 581f619

Browse files
committed
Merge branch 'develop' into fix/allOfStringProp
2 parents 877e750 + 72f2a10 commit 581f619

19 files changed

+1103
-29
lines changed

CHANGELOG.md

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

3+
#### v4.1.0 (July 20, 2022)
4+
* Fixed issue where conversion was failing for definitions with info object as null.
5+
* Fixed issue where generated collection did not have correct examples value from XML type of content.
6+
* Fixed issue [#518](https://github.com/postmanlabs/openapi-to-postman/issues/518) where generated collection were having NaN as value for integer query params with enum values.
7+
* Fixed issue [#496](https://github.com/postmanlabs/openapi-to-postman/issues/496) where validateTransactions() was returning missing endpoints even though corresponding requests are present in collection.
8+
* Fixed issue [#478](https://github.com/postmanlabs/openapi-to-postman/issues/478) where updation of path parameter in collection resulted in MISSING_IN_REQUEST error.
9+
* Fixed issue [#559](https://github.com/postmanlabs/openapi-to-postman/issues/559) where parameter description was undefined for formdata type of content even if defined.
10+
* Fixed issue where bundle() API didn't handle circular references correctly.
11+
* Added non-required files to be published as npm module in .npmignore
12+
* Fixed issue where disableBodyPruning option was not set for requests with no request body.
13+
314
#### v4.0.0 (July 12, 2022)
415
* Added support for new multi-file API detectRootFiles() for OpenAPI 3 and Swagger 2 formats to support detection of root files among multiple files.
516
* 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.

assets/json-schema-faker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23782,7 +23782,7 @@ function extend() {
2378223782
var min = Math.max(params.minimum || 0, 0);
2378323783
var max = Math.min(params.maximum || Infinity, Infinity);
2378423784
min = handleExclusiveMinimum(schema, min);
23785-
max = handleExclusiveMaximum(schema, min);
23785+
max = handleExclusiveMaximum(schema, max);
2378623786
// discard out-of-bounds enumerations
2378723787
schema.enum = schema.enum.filter(function (x) {
2378823788
if (x >= min && x <= max) {

lib/schemaUtils.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/sc
2828
APP_JSON = 'application/json',
2929
APP_JS = 'application/javascript',
3030
TEXT_XML = 'text/xml',
31+
APP_XML = 'application/xml',
3132
TEXT_PLAIN = 'text/plain',
3233
TEXT_HTML = 'text/html',
3334
FORM_DATA = 'multipart/form-data',
@@ -1914,6 +1915,7 @@ module.exports = {
19141915
else if (contentObj.hasOwnProperty(APP_JSON)) { bodyType = APP_JSON; }
19151916
else if (contentObj.hasOwnProperty(TEXT_HTML)) { bodyType = TEXT_HTML; }
19161917
else if (contentObj.hasOwnProperty(TEXT_PLAIN)) { bodyType = TEXT_PLAIN; }
1918+
else if (contentObj.hasOwnProperty(APP_XML)) { bodyType = APP_XML; }
19171919
else if (contentObj.hasOwnProperty(TEXT_XML)) { bodyType = TEXT_XML; }
19181920
else {
19191921
// take the first property it has
@@ -1934,12 +1936,29 @@ module.exports = {
19341936
};
19351937
}
19361938
else {
1939+
let getXmlVersionContent = (bodyContent) => {
1940+
const regExp = new RegExp('([<\\?xml]+[\\s{1,}]+[version="\\d.\\d"]+[\\sencoding="]+.{1,15}"\\?>)');
1941+
let xmlBody = bodyContent;
1942+
1943+
if (!bodyContent.match(regExp)) {
1944+
const versionContent = '<?xml version="1.0" encoding="UTF-8"?>\n';
1945+
xmlBody = versionContent + xmlBody;
1946+
}
1947+
return xmlBody;
1948+
};
1949+
19371950
bodyData = this.convertToPmBodyData(contentObj[bodyType], requestType, bodyType,
19381951
PARAMETER_SOURCE.REQUEST, options.indentCharacter, components, options, schemaCache);
19391952

1953+
bodyData = (bodyType === TEXT_XML || bodyType === APP_XML) ?
1954+
getXmlVersionContent(bodyData) :
1955+
bodyData;
1956+
19401957
updateOptions = {
19411958
mode: rDataMode,
1942-
raw: JSON.stringify(bodyData, null, options.indentCharacter)
1959+
raw: bodyType !== APP_JSON ?
1960+
bodyData.toString() :
1961+
JSON.stringify(bodyData, null, options.indentCharacter)
19431962
};
19441963
}
19451964

lib/swaggerUtils/inputValidationSwagger.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const _ = require('lodash');
32
module.exports = {
43

package-lock.json

Lines changed: 15 additions & 15 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": "openapi-to-postmanv2",
3-
"version": "4.0.0",
3+
"version": "4.1.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",
@@ -138,7 +138,7 @@
138138
"eslint": "5.16.0",
139139
"eslint-plugin-jsdoc": "3.8.0",
140140
"eslint-plugin-mocha": "5.3.0",
141-
"eslint-plugin-security": "1.4.0",
141+
"eslint-plugin-security": "1.5.0",
142142
"expect.js": "0.3.1",
143143
"mocha": "7.2.0",
144144
"nyc": "15.1.0",
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"version": "1.0.0",
5+
"title": null
6+
},
7+
"version": "v1.0",
8+
"title": "API",
9+
"servers": [
10+
{
11+
"url": "http://localhost:3000"
12+
}
13+
],
14+
"paths": {
15+
"/user": {
16+
"get": {
17+
"summary": "Returns details about a particular user",
18+
"operationId": "listUser",
19+
"tags": [
20+
"user"
21+
],
22+
"parameters": [
23+
{
24+
"name": "id",
25+
"in": "query",
26+
"description": "ID of the user",
27+
"required": true,
28+
"schema": {
29+
"type": "integer",
30+
"format": "int32"
31+
}
32+
}
33+
],
34+
"responses": {
35+
"200": {
36+
"description": "Details about a user by ID",
37+
"headers": {
38+
"x-next": {
39+
"description": "A link to the next page of responses",
40+
"schema": {
41+
"type": "string"
42+
}
43+
}
44+
},
45+
"content": {
46+
"application/json": {
47+
"schema": {
48+
"$ref": "\\'#/components/schemas/User\\'"
49+
}
50+
}
51+
}
52+
},
53+
"default": {
54+
"description": "Unexpected error",
55+
"content": {
56+
"application/json": {
57+
"schema": {
58+
"$ref": "\\'#/components/schemas/Error\\'"
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
},
67+
"components": {
68+
"schemas": {
69+
"User": {
70+
"type": "object",
71+
"required": [
72+
"id",
73+
"name"
74+
],
75+
"properties": {
76+
"id": {
77+
"type": "integer",
78+
"format": "int64"
79+
},
80+
"name": {
81+
"type": "string"
82+
},
83+
"tag": {
84+
"type": "string"
85+
}
86+
}
87+
},
88+
"Error": {
89+
"type": "object",
90+
"required": [
91+
"code",
92+
"message"
93+
],
94+
"properties": {
95+
"code": {
96+
"type": "integer",
97+
"format": "int32"
98+
},
99+
"message": {
100+
"type": "string"
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"version": null,
5+
"title": "title"
6+
},
7+
"version": "v1.0",
8+
"title": "API",
9+
"servers": [
10+
{
11+
"url": "http://localhost:3000"
12+
}
13+
],
14+
"paths": {
15+
"/user": {
16+
"get": {
17+
"summary": "Returns details about a particular user",
18+
"operationId": "listUser",
19+
"tags": [
20+
"user"
21+
],
22+
"parameters": [
23+
{
24+
"name": "id",
25+
"in": "query",
26+
"description": "ID of the user",
27+
"required": true,
28+
"schema": {
29+
"type": "integer",
30+
"format": "int32"
31+
}
32+
}
33+
],
34+
"responses": {
35+
"200": {
36+
"description": "Details about a user by ID",
37+
"headers": {
38+
"x-next": {
39+
"description": "A link to the next page of responses",
40+
"schema": {
41+
"type": "string"
42+
}
43+
}
44+
},
45+
"content": {
46+
"application/json": {
47+
"schema": {
48+
"$ref": "\\'#/components/schemas/User\\'"
49+
}
50+
}
51+
}
52+
},
53+
"default": {
54+
"description": "Unexpected error",
55+
"content": {
56+
"application/json": {
57+
"schema": {
58+
"$ref": "\\'#/components/schemas/Error\\'"
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
},
67+
"components": {
68+
"schemas": {
69+
"User": {
70+
"type": "object",
71+
"required": [
72+
"id",
73+
"name"
74+
],
75+
"properties": {
76+
"id": {
77+
"type": "integer",
78+
"format": "int64"
79+
},
80+
"name": {
81+
"type": "string"
82+
},
83+
"tag": {
84+
"type": "string"
85+
}
86+
}
87+
},
88+
"Error": {
89+
"type": "object",
90+
"required": [
91+
"code",
92+
"message"
93+
],
94+
"properties": {
95+
"code": {
96+
"type": "integer",
97+
"format": "int32"
98+
},
99+
"message": {
100+
"type": "string"
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)