@scalar/openapi-parser 0.10.12 → 0.10.14
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,5 +1,17 @@
|
|
|
1
1
|
# @scalar/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.10.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cf5bf65: fix: migrate file type, basic auth, parameters and responses headers correctly
|
|
8
|
+
|
|
9
|
+
## 0.10.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d5a687f: fix: byte format is ignored when upgrading from OpenAPI 3.0 to OpenAPI 3.1
|
|
14
|
+
|
|
3
15
|
## 0.10.12
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -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,CAAC,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,CAAC,qBAAqB,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;mBAuI9E;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAsBpD"}
|
|
@@ -104,6 +104,18 @@ function upgradeFromThreeToThreeOne(originalSpecification) {
|
|
|
104
104
|
}
|
|
105
105
|
return schema;
|
|
106
106
|
});
|
|
107
|
+
specification = traverse(specification, (schema, path) => {
|
|
108
|
+
if (schema.type === 'string' && schema.format === 'byte') {
|
|
109
|
+
const parentPath = path.slice(0, -1);
|
|
110
|
+
const contentMediaType = parentPath.find((_, index) => path[index - 1] === 'content');
|
|
111
|
+
return {
|
|
112
|
+
type: 'string',
|
|
113
|
+
contentEncoding: 'base64',
|
|
114
|
+
contentMediaType,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return schema;
|
|
118
|
+
});
|
|
107
119
|
// Declaring $schema Dialects to protect against change
|
|
108
120
|
// if (typeof specification.$schema === 'undefined') {
|
|
109
121
|
// specification.$schema = 'http://json-schema.org/draft-07/schema#'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeFromTwoToThree.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromTwoToThree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"upgradeFromTwoToThree.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromTwoToThree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,0CA+PzE"}
|
|
@@ -44,6 +44,13 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
44
44
|
return schema;
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
specification = traverse(specification, (schema) => {
|
|
48
|
+
if (schema.type === 'file') {
|
|
49
|
+
schema.type = 'string';
|
|
50
|
+
schema.format = 'binary';
|
|
51
|
+
}
|
|
52
|
+
return schema;
|
|
53
|
+
});
|
|
47
54
|
// Paths
|
|
48
55
|
if (typeof specification.paths === 'object') {
|
|
49
56
|
for (const path in specification.paths) {
|
|
@@ -109,12 +116,21 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
109
116
|
// Remove formData parameters from the parameters array
|
|
110
117
|
operationItem.parameters = operationItem.parameters.filter((parameter) => parameter.in !== 'formData');
|
|
111
118
|
}
|
|
119
|
+
operationItem.parameters = operationItem.parameters.map((parameter) => transformParameterObject(parameter));
|
|
112
120
|
}
|
|
113
121
|
// Responses
|
|
114
122
|
if (operationItem.responses) {
|
|
115
123
|
for (const response in operationItem.responses) {
|
|
116
124
|
if (Object.hasOwn(operationItem.responses, response)) {
|
|
117
125
|
const responseItem = operationItem.responses[response];
|
|
126
|
+
if (responseItem.headers) {
|
|
127
|
+
responseItem.headers = Object.entries(responseItem.headers).reduce((acc, [name, header]) => {
|
|
128
|
+
return {
|
|
129
|
+
[name]: transformParameterObject(header),
|
|
130
|
+
...acc,
|
|
131
|
+
};
|
|
132
|
+
}, {});
|
|
133
|
+
}
|
|
118
134
|
if (responseItem.schema) {
|
|
119
135
|
const produces = specification.produces ?? operationItem.produces ?? ['application/json'];
|
|
120
136
|
if (typeof responseItem.content !== 'object') {
|
|
@@ -162,6 +178,14 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
162
178
|
},
|
|
163
179
|
});
|
|
164
180
|
}
|
|
181
|
+
else if ('type' in securityScheme && securityScheme.type === 'basic') {
|
|
182
|
+
Object.assign(specification.components.securitySchemes, {
|
|
183
|
+
[key]: {
|
|
184
|
+
type: 'http',
|
|
185
|
+
scheme: 'basic',
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
}
|
|
165
189
|
else {
|
|
166
190
|
Object.assign(specification.components.securitySchemes, {
|
|
167
191
|
[key]: securityScheme,
|
|
@@ -173,5 +197,39 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
173
197
|
}
|
|
174
198
|
return specification;
|
|
175
199
|
}
|
|
200
|
+
function transformItemsObject(obj) {
|
|
201
|
+
const schemaProperties = [
|
|
202
|
+
'type',
|
|
203
|
+
'format',
|
|
204
|
+
'items',
|
|
205
|
+
'maximum',
|
|
206
|
+
'exclusiveMaximum',
|
|
207
|
+
'minimum',
|
|
208
|
+
'exclusiveMinimum',
|
|
209
|
+
'maxLength',
|
|
210
|
+
'minLength',
|
|
211
|
+
'pattern',
|
|
212
|
+
'maxItems',
|
|
213
|
+
'minItems',
|
|
214
|
+
'uniqueItems',
|
|
215
|
+
'enum',
|
|
216
|
+
'multipleOf',
|
|
217
|
+
];
|
|
218
|
+
return schemaProperties.reduce((acc, property) => {
|
|
219
|
+
if (Object.hasOwn(obj, property)) {
|
|
220
|
+
acc[property] = obj[property];
|
|
221
|
+
delete obj[property];
|
|
222
|
+
}
|
|
223
|
+
return acc;
|
|
224
|
+
}, {});
|
|
225
|
+
}
|
|
226
|
+
function transformParameterObject(parameter) {
|
|
227
|
+
delete parameter.collectionFormat;
|
|
228
|
+
delete parameter.default;
|
|
229
|
+
return {
|
|
230
|
+
schema: transformItemsObject(parameter),
|
|
231
|
+
...parameter,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
176
234
|
|
|
177
235
|
export { upgradeFromTwoToThree };
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"parser",
|
|
18
18
|
"typescript"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.10.
|
|
20
|
+
"version": "0.10.14",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"json-to-ast": "^2.1.0",
|
|
65
65
|
"just-diff": "^6.0.2",
|
|
66
66
|
"tinybench": "^2.8.0",
|
|
67
|
-
"@scalar/types": "0.1.2",
|
|
68
67
|
"@scalar/build-tooling": "0.1.17",
|
|
69
|
-
"@scalar/
|
|
68
|
+
"@scalar/types": "0.1.6",
|
|
69
|
+
"@scalar/openapi-types": "0.2.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "scalar-build-rollup",
|