@scalar/openapi-parser 0.10.1 → 0.10.2
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeFromThreeToThreeOne.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromThreeToThreeOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"upgradeFromThreeToThreeOne.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromThreeToThreeOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;mBAmIrC;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAsBpD"}
|
|
@@ -63,25 +63,38 @@ function upgradeFromThreeToThreeOne(originalSpecification) {
|
|
|
63
63
|
return schema;
|
|
64
64
|
});
|
|
65
65
|
// Multipart file uploads with a binary file
|
|
66
|
-
specification = traverse(specification, (schema) => {
|
|
66
|
+
specification = traverse(specification, (schema, path) => {
|
|
67
67
|
if (schema.type === 'object' && schema.properties !== undefined) {
|
|
68
|
-
//
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
// Check if this is a multipart request body schema
|
|
69
|
+
const parentPath = path.slice(0, -1);
|
|
70
|
+
const isMultipart = parentPath.some((segment, index) => {
|
|
71
|
+
return (segment === 'content' && path[index + 1] === 'multipart/form-data');
|
|
72
|
+
});
|
|
73
|
+
if (isMultipart) {
|
|
74
|
+
// Types
|
|
75
|
+
const entries = Object.entries(schema.properties);
|
|
76
|
+
for (const [_, value] of entries) {
|
|
77
|
+
if (typeof value === 'object' &&
|
|
78
|
+
value.type === 'string' &&
|
|
79
|
+
value.format === 'binary') {
|
|
80
|
+
value.contentMediaType = 'application/octet-stream';
|
|
81
|
+
delete value.format;
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
return schema;
|
|
80
87
|
});
|
|
81
88
|
// Uploading a binary file in a POST request
|
|
82
|
-
specification = traverse(specification, (schema) => {
|
|
89
|
+
specification = traverse(specification, (schema, path) => {
|
|
90
|
+
if (path.includes('content') && path.includes('application/octet-stream')) {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
83
93
|
if (schema.type === 'string' && schema.format === 'binary') {
|
|
84
|
-
return
|
|
94
|
+
return {
|
|
95
|
+
type: 'string',
|
|
96
|
+
contentMediaType: 'application/octet-stream',
|
|
97
|
+
};
|
|
85
98
|
}
|
|
86
99
|
return schema;
|
|
87
100
|
});
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"parser",
|
|
18
18
|
"typescript"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.10.
|
|
20
|
+
"version": "0.10.2",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
60
60
|
"@babel/code-frame": "^7.24.7",
|
|
61
61
|
"@google-cloud/storage": "^7.12.1",
|
|
62
|
-
"@types/node": "^20.
|
|
62
|
+
"@types/node": "^20.17.10",
|
|
63
63
|
"glob": "^10.3.10",
|
|
64
64
|
"json-to-ast": "^2.1.0",
|
|
65
65
|
"just-diff": "^6.0.2",
|
|
66
66
|
"tinybench": "^2.8.0",
|
|
67
|
-
"@scalar/build-tooling": "0.1.12",
|
|
68
67
|
"@scalar/openapi-types": "0.1.5",
|
|
68
|
+
"@scalar/build-tooling": "0.1.12",
|
|
69
69
|
"@scalar/types": "0.0.25"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|