@scalar/postman-to-openapi 0.7.34 → 0.7.36
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 +12 -0
- package/dist/convert.d.ts.map +1 -1
- package/dist/convert.js +10 -11
- package/dist/helpers/merge-operation.d.ts.map +1 -1
- package/dist/helpers/merge-operation.js +7 -1
- package/dist/helpers/normalize-description.d.ts +4 -0
- package/dist/helpers/normalize-description.d.ts.map +1 -0
- package/dist/helpers/normalize-description.js +7 -0
- package/dist/helpers/parameters.d.ts.map +1 -1
- package/dist/helpers/parameters.js +4 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scalar/postman-to-openapi
|
|
2
2
|
|
|
3
|
+
## 0.7.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#11172](https://github.com/scalar/scalar/pull/11172): Fix invalid empty `responses` on merged Postman operations that have no saved responses.
|
|
8
|
+
|
|
9
|
+
## 0.7.35
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#11125](https://github.com/scalar/scalar/pull/11125): Fix Postman imports that use structured descriptions on query parameters.
|
|
14
|
+
|
|
3
15
|
## 0.7.34
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/convert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAqBxD,OAAO,KAAK,EAAyB,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEvE;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,MAAM,EAAE,CAAA;AAqDvD,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAA;AAisBhD,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAA;IACtD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC,CAAA;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,iBAAiB,EAAE,iBAAiB,GAAG,MAAM,EAC7C,OAAO,GAAE,cAA0C,GAClD,WAAW,CAAC,QAAQ,CA4OtB"}
|
package/dist/convert.js
CHANGED
|
@@ -4,16 +4,11 @@ import { processExternalDocs } from './helpers/external-docs.js';
|
|
|
4
4
|
import { processLicense } from './helpers/license.js';
|
|
5
5
|
import { processLogo } from './helpers/logo.js';
|
|
6
6
|
import { DEFAULT_EXAMPLE_NAME, OPERATION_KEYS, mergePathItem } from './helpers/merge-path-item.js';
|
|
7
|
+
import { normalizeDescription } from './helpers/normalize-description.js';
|
|
7
8
|
import { POSTMAN_EXAMPLE_NAME_EXTENSION, POSTMAN_FOLDER_SEGMENTS_EXTENSION, POSTMAN_POST_RESPONSE_SCRIPTS_EXTENSION, POSTMAN_PRE_REQUEST_SCRIPTS_EXTENSION, processItem, } from './helpers/path-items.js';
|
|
8
9
|
import { pruneDocument } from './helpers/prune-document.js';
|
|
9
10
|
import { analyzeServerDistribution } from './helpers/servers.js';
|
|
10
11
|
import { createCollectionVariableLookup, getPathStructuralSignature, normalizePath } from './helpers/urls.js';
|
|
11
|
-
const normalizeDescription = (description) => {
|
|
12
|
-
if (typeof description === 'string') {
|
|
13
|
-
return description;
|
|
14
|
-
}
|
|
15
|
-
return description?.content;
|
|
16
|
-
};
|
|
17
12
|
const parseCollectionInput = (postmanCollection) => {
|
|
18
13
|
if (typeof postmanCollection !== 'string') {
|
|
19
14
|
return postmanCollection;
|
|
@@ -722,11 +717,15 @@ export function convert(postmanCollection, options = { mergeOperation: false })
|
|
|
722
717
|
continue;
|
|
723
718
|
}
|
|
724
719
|
for (const [method, servers] of methods.entries()) {
|
|
725
|
-
if (method
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
720
|
+
if (!Object.hasOwn(pathItem, method)) {
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
const operation = pathItem[method];
|
|
724
|
+
// Generated custom Postman operations still carry their own responses property before pruning.
|
|
725
|
+
if (operation &&
|
|
726
|
+
typeof operation === 'object' &&
|
|
727
|
+
(OPERATION_KEYS.includes(method) || Object.hasOwn(operation, 'responses'))) {
|
|
728
|
+
operation.servers = isMergingIntoBase ? mergeServerLists(operation.servers, servers) : servers;
|
|
730
729
|
}
|
|
731
730
|
}
|
|
732
731
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-operation.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAmBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,eAAe,GAC1B,YAAY,WAAW,CAAC,eAAe,EACvC,YAAY,WAAW,CAAC,eAAe,KACtC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"merge-operation.d.ts","sourceRoot":"","sources":["../../src/helpers/merge-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAmBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,eAAe,GAC1B,YAAY,WAAW,CAAC,eAAe,EACvC,YAAY,WAAW,CAAC,eAAe,KACtC,WAAW,CAAC,eAgHd,CAAA"}
|
|
@@ -140,10 +140,16 @@ export const mergeOperations = (operation1, operation2) => {
|
|
|
140
140
|
content: Object.fromEntries(contentMediaTypeMap),
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
const responses = {
|
|
144
144
|
...(operation1.responses ?? {}),
|
|
145
145
|
...(operation.responses ?? {}),
|
|
146
146
|
};
|
|
147
|
+
if (Object.keys(responses).length > 0) {
|
|
148
|
+
operation.responses = responses;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
delete operation.responses;
|
|
152
|
+
}
|
|
147
153
|
operation.summary = mergeSummary(operation1.summary, operation.summary);
|
|
148
154
|
operation.description = mergeDescription(operation1.description, operation.description);
|
|
149
155
|
for (const config of SCRIPT_MERGE_CONFIG) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-description.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize-description.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,GAAI,cAAc,WAAW,KAAG,MAAM,GAAG,SAMzE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/helpers/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/helpers/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,SAAS,CAAA;AAwC9C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAC9B,WAAW,CAAC,eAAe,EAAE,CA8D/B;AAoBD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,EACpC,WAAW,EAAE,MAAM,GAClB,WAAW,CAAC,eAAe,CAyD7B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeDescription } from './normalize-description.js';
|
|
1
2
|
import { inferSchemaType } from './schemas.js';
|
|
2
3
|
/**
|
|
3
4
|
* Header keys (lower-case) that never become `parameters[in=header]` on an
|
|
@@ -114,10 +115,11 @@ function extractPathVariablesFromPathArray(pathArray) {
|
|
|
114
115
|
* Creates an OpenAPI parameter object from a Postman parameter.
|
|
115
116
|
*/
|
|
116
117
|
export function createParameterObject(param, paramIn, exampleName) {
|
|
118
|
+
const description = normalizeDescription(param.description);
|
|
117
119
|
const parameter = {
|
|
118
120
|
name: param.key || '',
|
|
119
121
|
in: paramIn,
|
|
120
|
-
description
|
|
122
|
+
description,
|
|
121
123
|
examples: {
|
|
122
124
|
[exampleName]: {
|
|
123
125
|
value: param.value,
|
|
@@ -131,7 +133,7 @@ export function createParameterObject(param, paramIn, exampleName) {
|
|
|
131
133
|
}
|
|
132
134
|
else if (paramIn === 'query') {
|
|
133
135
|
// Check if the parameter is required based on description or name
|
|
134
|
-
const isRequired =
|
|
136
|
+
const isRequired = description?.toLowerCase().includes('[required]') || (param.key && param.key.toLowerCase() === 'required');
|
|
135
137
|
if (isRequired) {
|
|
136
138
|
parameter.required = true;
|
|
137
139
|
// Remove '[required]' from the description
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"export",
|
|
20
20
|
"scalar"
|
|
21
21
|
],
|
|
22
|
-
"version": "0.7.
|
|
22
|
+
"version": "0.7.36",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22"
|
|
25
25
|
},
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"CHANGELOG.md"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@scalar/helpers": "0.
|
|
41
|
+
"@scalar/helpers": "0.20.0",
|
|
42
42
|
"@scalar/openapi-types": "0.9.10"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@scalar/openapi-parser": "0.29.
|
|
45
|
+
"@scalar/openapi-parser": "0.29.28",
|
|
46
46
|
"@types/node": "^24.19.2",
|
|
47
47
|
"vite": "8.3.8"
|
|
48
48
|
},
|