@scalar/postman-to-openapi 0.1.43 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/helpers/formDataHelpers.d.ts.map +1 -1
- package/dist/helpers/formDataHelpers.js +2 -1
- package/dist/helpers/itemHelpers.d.ts.map +1 -1
- package/dist/helpers/itemHelpers.js +6 -3
- package/dist/helpers/licenseContactHelper.d.ts.map +1 -1
- package/dist/helpers/licenseContactHelper.js +4 -2
- package/dist/helpers/logoHelper.d.ts.map +1 -1
- package/dist/helpers/logoHelper.js +2 -1
- package/dist/helpers/md-utils.d.ts.map +1 -1
- package/dist/helpers/md-utils.js +4 -2
- package/dist/helpers/urlHelpers.d.ts.map +1 -1
- package/dist/helpers/urlHelpers.js +2 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scalar/postman-to-openapi
|
|
2
2
|
|
|
3
|
+
## 0.1.45
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @scalar/oas-utils@0.2.122
|
|
8
|
+
|
|
9
|
+
## 0.1.44
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [0f13162]
|
|
14
|
+
- Updated dependencies [0212daa]
|
|
15
|
+
- @scalar/oas-utils@0.2.121
|
|
16
|
+
|
|
3
17
|
## 0.1.43
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formDataHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/formDataHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"formDataHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/formDataHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,YAAY,CA4CzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/itemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAU/C;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,UAAU,GAAE,MAAM,EAAO,EACzB,UAAU,GAAE,MAAW,GACtB;IACD,KAAK,EAAE,WAAW,CAAC,WAAW,CAAA;IAC9B,UAAU,EAAE,WAAW,CAAC,gBAAgB,CAAA;CACzC,
|
|
1
|
+
{"version":3,"file":"itemHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/itemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAU/C;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,UAAU,GAAE,MAAM,EAAO,EACzB,UAAU,GAAE,MAAW,GACtB;IACD,KAAK,EAAE,WAAW,CAAC,WAAW,CAAA;IAC9B,UAAU,EAAE,WAAW,CAAC,gBAAgB,CAAA;CACzC,CAqIA"}
|
|
@@ -112,8 +112,9 @@ export function processItem(item, parentTags = [], parentPath = '') {
|
|
|
112
112
|
if (['post', 'put', 'patch'].includes(method) && typeof request !== 'string' && request.body) {
|
|
113
113
|
operationObject.requestBody = extractRequestBody(request.body);
|
|
114
114
|
}
|
|
115
|
-
if (!paths[path])
|
|
115
|
+
if (!paths[path]) {
|
|
116
116
|
paths[path] = {};
|
|
117
|
+
}
|
|
117
118
|
const pathItem = paths[path];
|
|
118
119
|
pathItem[method] = operationObject;
|
|
119
120
|
return { paths, components };
|
|
@@ -171,12 +172,14 @@ function parseParametersFromDescription(description) {
|
|
|
171
172
|
}
|
|
172
173
|
// Instead of using regex with \s*, let's split this into two steps
|
|
173
174
|
function extractOperationInfo(name) {
|
|
174
|
-
if (!name)
|
|
175
|
+
if (!name) {
|
|
175
176
|
return { operationId: undefined, summary: undefined };
|
|
177
|
+
}
|
|
176
178
|
// First check if the string ends with something in brackets
|
|
177
179
|
const match = name.match(/\[([^[\]]{0,1000})\]$/);
|
|
178
|
-
if (!match)
|
|
180
|
+
if (!match) {
|
|
179
181
|
return { operationId: undefined, summary: name };
|
|
182
|
+
}
|
|
180
183
|
// Get the operation ID from inside brackets
|
|
181
184
|
const operationId = match[1];
|
|
182
185
|
// Trim the brackets part from the end using string operations instead of regex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"licenseContactHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/licenseContactHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAY,MAAM,UAAU,CAAA;AAe3D,KAAK,UAAU,GAAG;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAA;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAA;CACpC,CAAA;
|
|
1
|
+
{"version":3,"file":"licenseContactHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/licenseContactHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAY,MAAM,UAAU,CAAA;AAe3D,KAAK,UAAU,GAAG;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAA;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAA;CACpC,CAAA;AA4CD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,iBAAiB,GAAG,UAAU,CAmBlF"}
|
|
@@ -21,8 +21,9 @@ function findVariable(collection, key) {
|
|
|
21
21
|
*/
|
|
22
22
|
function processLicense(collection) {
|
|
23
23
|
const nameVar = findVariable(collection, VARIABLE_KEYS.LICENSE.NAME);
|
|
24
|
-
if (!nameVar?.value || typeof nameVar.value !== 'string')
|
|
24
|
+
if (!nameVar?.value || typeof nameVar.value !== 'string') {
|
|
25
25
|
return undefined;
|
|
26
|
+
}
|
|
26
27
|
const urlVar = findVariable(collection, VARIABLE_KEYS.LICENSE.URL);
|
|
27
28
|
return {
|
|
28
29
|
name: nameVar.value,
|
|
@@ -36,8 +37,9 @@ function processContact(collection) {
|
|
|
36
37
|
const nameVar = findVariable(collection, VARIABLE_KEYS.CONTACT.NAME);
|
|
37
38
|
const urlVar = findVariable(collection, VARIABLE_KEYS.CONTACT.URL);
|
|
38
39
|
const emailVar = findVariable(collection, VARIABLE_KEYS.CONTACT.EMAIL);
|
|
39
|
-
if (!nameVar?.value && !urlVar?.value && !emailVar?.value)
|
|
40
|
+
if (!nameVar?.value && !urlVar?.value && !emailVar?.value) {
|
|
40
41
|
return undefined;
|
|
42
|
+
}
|
|
41
43
|
return {
|
|
42
44
|
...(nameVar?.value && typeof nameVar.value === 'string' && { name: nameVar.value }),
|
|
43
45
|
...(urlVar?.value && typeof urlVar.value === 'string' && { url: urlVar.value }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logoHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/logoHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,iBAAiB,EAAE,iBAAiB;;;;;
|
|
1
|
+
{"version":3,"file":"logoHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/logoHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,iBAAiB,EAAE,iBAAiB;;;;;SAoB/D"}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function processLogo(postmanCollection) {
|
|
7
7
|
const logoVariables = postmanCollection.variable?.filter((v) => v.key?.startsWith('x-logo.')) || [];
|
|
8
|
-
if (logoVariables.length === 0)
|
|
8
|
+
if (logoVariables.length === 0) {
|
|
9
9
|
return null;
|
|
10
|
+
}
|
|
10
11
|
const logo = {};
|
|
11
12
|
logoVariables.forEach((v) => {
|
|
12
13
|
if (v.key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-utils.d.ts","sourceRoot":"","sources":["../../src/helpers/md-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,UAAU,CAAA;AAItD;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"md-utils.d.ts","sourceRoot":"","sources":["../../src/helpers/md-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,UAAU,CAAA;AAItD;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,CAqCpD"}
|
package/dist/helpers/md-utils.js
CHANGED
|
@@ -4,14 +4,16 @@ const supHeaders = ['object', 'name', 'description', 'example', 'type', 'require
|
|
|
4
4
|
*/
|
|
5
5
|
export function parseMdTable(md) {
|
|
6
6
|
const lines = md.split('\n').filter((line) => line.trim() !== '');
|
|
7
|
-
if (lines.length < 3)
|
|
7
|
+
if (lines.length < 3) {
|
|
8
8
|
return {};
|
|
9
|
+
}
|
|
9
10
|
const header = lines[0]
|
|
10
11
|
.split('|')
|
|
11
12
|
.map((cell) => cell.trim())
|
|
12
13
|
.filter(Boolean);
|
|
13
|
-
if (!header.includes('object') || !header.includes('name'))
|
|
14
|
+
if (!header.includes('object') || !header.includes('name')) {
|
|
14
15
|
return {};
|
|
16
|
+
}
|
|
15
17
|
const headers = header.map((h) => (supHeaders.includes(h) ? h : false));
|
|
16
18
|
const rows = lines.slice(2).map((line) => line
|
|
17
19
|
.split('|')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/urlHelpers.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/urlHelpers.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAYlE;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,MAAyC,CAAA;AAEtF;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAahE"}
|
|
@@ -21,8 +21,9 @@ export function getDomainFromUrl(url) {
|
|
|
21
21
|
* Extracts the path from a given URL, removing any Postman variables.
|
|
22
22
|
*/
|
|
23
23
|
export function extractPathFromUrl(url) {
|
|
24
|
-
if (!url)
|
|
24
|
+
if (!url) {
|
|
25
25
|
return '/';
|
|
26
|
+
}
|
|
26
27
|
// Remove scheme, domain, query parameters, and hash fragments
|
|
27
28
|
const path = url.replace(/^(?:https?:\/\/)?[^/]+(\/|$)/, '/').split(/[?#]/)[0];
|
|
28
29
|
// Replace Postman variables and ensure single leading slash
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"export",
|
|
20
20
|
"scalar"
|
|
21
21
|
],
|
|
22
|
-
"version": "0.1.
|
|
22
|
+
"version": "0.1.45",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=18"
|
|
25
25
|
},
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
],
|
|
39
39
|
"module": "dist/index.js",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@scalar/
|
|
42
|
-
"@scalar/
|
|
41
|
+
"@scalar/openapi-types": "0.1.9",
|
|
42
|
+
"@scalar/oas-utils": "0.2.122"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"vite": "^5.4.10",
|