@scalar/openapi-upgrader 0.1.6 → 0.1.8
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 +13 -0
- package/README.md +13 -103
- package/dist/2.0-to-3.0/upgrade-from-two-to-three.d.ts.map +1 -1
- package/dist/2.0-to-3.0/upgrade-from-two-to-three.js +183 -21
- package/dist/2.0-to-3.0/upgrade-from-two-to-three.js.map +2 -2
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js.map +2 -2
- package/package.json +19 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @scalar/openapi-upgrader
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7842](https://github.com/scalar/scalar/pull/7842): feat: migrate swagger 2.0 responses
|
|
8
|
+
|
|
9
|
+
## 0.1.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#7739](https://github.com/scalar/scalar/pull/7739): fix: upgrade form to multipart/form
|
|
14
|
+
- [#7694](https://github.com/scalar/scalar/pull/7694): feat: migrate x-example and x-examples
|
|
15
|
+
|
|
3
16
|
## 0.1.6
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
This file is auto-generated by the Scalar README generator.
|
|
3
|
+
Command: pnpm --filter @scalar-internal/build-scripts start generate-readme
|
|
4
|
+
|
|
5
|
+
Do not edit this file manually. Changes will be lost when the file is regenerated.
|
|
6
|
+
-->
|
|
7
|
+
|
|
1
8
|
# Scalar OpenAPI Upgrader
|
|
2
9
|
|
|
3
10
|
[](https://www.npmjs.com/package/@scalar/openapi-upgrader)
|
|
@@ -5,116 +12,19 @@
|
|
|
5
12
|
[](https://www.npmjs.com/package/@scalar/openapi-upgrader)
|
|
6
13
|
[](https://discord.gg/scalar)
|
|
7
14
|
|
|
8
|
-
Upgrade
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm add @scalar/openapi-upgrader
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { upgrade } from '@scalar/openapi-upgrader'
|
|
20
|
-
|
|
21
|
-
const document = upgrade({
|
|
22
|
-
swagger: '2.0',
|
|
23
|
-
info: {
|
|
24
|
-
title: 'Hello World',
|
|
25
|
-
version: '1.0.0',
|
|
26
|
-
},
|
|
27
|
-
paths: {},
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
console.log(document.openapi)
|
|
31
|
-
// Output: 3.1.1
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Experimental: Upgrade to OpenAPI 3.2
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
import { upgrade } from '@scalar/openapi-upgrader'
|
|
38
|
-
|
|
39
|
-
const OPENAPI_DOCUMENT = {
|
|
40
|
-
swagger: '2.0',
|
|
41
|
-
info: {
|
|
42
|
-
title: 'Hello World',
|
|
43
|
-
version: '1.0.0',
|
|
44
|
-
},
|
|
45
|
-
paths: {},
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// We need to explicitly pass '3.2' to upgrade to OpenAPI 3.2
|
|
49
|
-
const document = upgrade(OPENAPI_DOCUMENT, '3.2')
|
|
50
|
-
|
|
51
|
-
console.log(document.openapi)
|
|
52
|
-
// Output: 3.2.0
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### CLI
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npx @scalar/cli document upgrade swagger.json --output openapi.json
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### From Swagger 2.0 to OpenAPI 3.0
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { upgradeFromTwoToThree } from '@scalar/openapi-upgrader/2.0-to-3.0'
|
|
65
|
-
|
|
66
|
-
const document = upgradeFromTwoToThree({
|
|
67
|
-
swagger: '2.0',
|
|
68
|
-
info: {
|
|
69
|
-
title: 'Hello World',
|
|
70
|
-
version: '1.0.0',
|
|
71
|
-
},
|
|
72
|
-
paths: {},
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
console.log(document.openapi)
|
|
76
|
-
// Output: 3.0.4
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### From OpenAPI 3.0 to OpenAPI 3.1
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
import { upgradeFromThreeToThreeOne } from '@scalar/openapi-upgrader/3.0-to-3.1'
|
|
83
|
-
|
|
84
|
-
const document = upgradeFromThreeToThreeOne({
|
|
85
|
-
openapi: '3.0.0',
|
|
86
|
-
info: {
|
|
87
|
-
title: 'Hello World',
|
|
88
|
-
version: '1.0.0',
|
|
89
|
-
},
|
|
90
|
-
paths: {},
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
console.log(document.openapi)
|
|
94
|
-
// Output: 3.1.1
|
|
95
|
-
```
|
|
15
|
+
Upgrade OpenAPI documents to the latest and greatest version
|
|
96
16
|
|
|
97
|
-
|
|
17
|
+
## Documentation
|
|
98
18
|
|
|
99
|
-
|
|
100
|
-
import { upgradeFromThreeOneToThreeTwo } from '@scalar/openapi-upgrader/3.1-to-3.2'
|
|
19
|
+
[Read the documentation here](https://scalar.com/tools/openapi-upgrader/getting-started)
|
|
101
20
|
|
|
102
|
-
|
|
103
|
-
openapi: '3.1.0',
|
|
104
|
-
info: {
|
|
105
|
-
title: 'Hello World',
|
|
106
|
-
version: '1.0.0',
|
|
107
|
-
},
|
|
108
|
-
paths: {},
|
|
109
|
-
})
|
|
21
|
+
## Changelog
|
|
110
22
|
|
|
111
|
-
|
|
112
|
-
// Output: 3.2.0
|
|
113
|
-
```
|
|
23
|
+
See [CHANGELOG.md](https://github.com/scalar/scalar/blob/main/packages/openapi-upgrader/CHANGELOG.md) for a list of changes.
|
|
114
24
|
|
|
115
25
|
## Community
|
|
116
26
|
|
|
117
|
-
We are API nerds. You too? Let
|
|
27
|
+
We are API nerds. You too? Let’s chat on Discord: <https://discord.gg/scalar>
|
|
118
28
|
|
|
119
29
|
## License
|
|
120
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-from-two-to-three.d.ts","sourceRoot":"","sources":["../../src/2.0-to-3.0/upgrade-from-two-to-three.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"upgrade-from-two-to-three.d.ts","sourceRoot":"","sources":["../../src/2.0-to-3.0/upgrade-from-two-to-three.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAiGxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,0CA0ZzE"}
|
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
import { traverse } from "../helpers/traverse.js";
|
|
2
|
+
function extractXExampleExtensions(obj) {
|
|
3
|
+
const xExample = obj["x-example"];
|
|
4
|
+
const xExamples = obj["x-examples"];
|
|
5
|
+
delete obj["x-example"];
|
|
6
|
+
delete obj["x-examples"];
|
|
7
|
+
return { xExample, xExamples };
|
|
8
|
+
}
|
|
9
|
+
function isNonEmptyObject(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length > 0;
|
|
11
|
+
}
|
|
12
|
+
function isNamedExamplesCollection(value) {
|
|
13
|
+
return isNonEmptyObject(value) && Object.values(value).every((v) => typeof v === "object" && v !== null && !Array.isArray(v));
|
|
14
|
+
}
|
|
15
|
+
const EXAMPLE_OBJECT_PROPERTIES = /* @__PURE__ */ new Set(["summary", "description", "value", "externalValue"]);
|
|
16
|
+
function isExampleObject(value) {
|
|
17
|
+
if (typeof value !== "object" || value === null) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const obj = value;
|
|
21
|
+
const hasValueOrExternalValue = "value" in obj || "externalValue" in obj;
|
|
22
|
+
const onlyHasAllowedProperties = Object.keys(obj).every((key) => EXAMPLE_OBJECT_PROPERTIES.has(key));
|
|
23
|
+
return hasValueOrExternalValue && onlyHasAllowedProperties;
|
|
24
|
+
}
|
|
25
|
+
function wrapAsExampleObject(value) {
|
|
26
|
+
if (isExampleObject(value)) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return { value };
|
|
30
|
+
}
|
|
31
|
+
function transformXExampleToExamples(xExample) {
|
|
32
|
+
return Object.entries(xExample).reduce(
|
|
33
|
+
(acc, [key, value]) => {
|
|
34
|
+
acc[key] = { value };
|
|
35
|
+
return acc;
|
|
36
|
+
},
|
|
37
|
+
{}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
2
40
|
const upgradeFlow = (flow) => {
|
|
3
41
|
switch (flow) {
|
|
4
42
|
case "application":
|
|
@@ -84,7 +122,10 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
84
122
|
document.consumes ?? ["application/json"]
|
|
85
123
|
);
|
|
86
124
|
} else if (param.in === "formData") {
|
|
87
|
-
bodyParams[name] = migrateFormDataParameter(
|
|
125
|
+
bodyParams[name] = migrateFormDataParameter(
|
|
126
|
+
[param],
|
|
127
|
+
document.consumes
|
|
128
|
+
);
|
|
88
129
|
} else {
|
|
89
130
|
const convertedParam = transformParameterObject(param);
|
|
90
131
|
params[name] = convertedParam;
|
|
@@ -102,6 +143,73 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
102
143
|
}
|
|
103
144
|
delete document.parameters;
|
|
104
145
|
}
|
|
146
|
+
if (Object.hasOwn(document, "responses") && typeof document.responses === "object" && document.responses !== null) {
|
|
147
|
+
document = traverse(document, (schema) => {
|
|
148
|
+
if (typeof schema.$ref === "string" && schema.$ref.startsWith("#/responses/")) {
|
|
149
|
+
schema.$ref = schema.$ref.replace(/^#\/responses\//, "#/components/responses/");
|
|
150
|
+
}
|
|
151
|
+
return schema;
|
|
152
|
+
});
|
|
153
|
+
document.components ??= {};
|
|
154
|
+
const migratedResponses = {};
|
|
155
|
+
const responses = document.responses;
|
|
156
|
+
for (const [name, response] of Object.entries(responses)) {
|
|
157
|
+
if (response && typeof response === "object") {
|
|
158
|
+
if ("$ref" in response) {
|
|
159
|
+
migratedResponses[name] = response;
|
|
160
|
+
} else {
|
|
161
|
+
const responseObj = response;
|
|
162
|
+
const produces = document.produces ?? ["application/json"];
|
|
163
|
+
if (responseObj.schema) {
|
|
164
|
+
if (typeof responseObj.content !== "object") {
|
|
165
|
+
responseObj.content = {};
|
|
166
|
+
}
|
|
167
|
+
for (const type of produces) {
|
|
168
|
+
;
|
|
169
|
+
responseObj.content[type] = {
|
|
170
|
+
schema: responseObj.schema
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
delete responseObj.schema;
|
|
174
|
+
}
|
|
175
|
+
if (responseObj.examples && typeof responseObj.examples === "object") {
|
|
176
|
+
if (typeof responseObj.content !== "object") {
|
|
177
|
+
responseObj.content = {};
|
|
178
|
+
}
|
|
179
|
+
for (const [mediaType, exampleValue] of Object.entries(responseObj.examples)) {
|
|
180
|
+
if (typeof responseObj.content[mediaType] !== "object") {
|
|
181
|
+
;
|
|
182
|
+
responseObj.content[mediaType] = {};
|
|
183
|
+
}
|
|
184
|
+
;
|
|
185
|
+
responseObj.content[mediaType].example = exampleValue;
|
|
186
|
+
}
|
|
187
|
+
delete responseObj.examples;
|
|
188
|
+
}
|
|
189
|
+
if (responseObj.headers && typeof responseObj.headers === "object") {
|
|
190
|
+
responseObj.headers = Object.entries(responseObj.headers).reduce(
|
|
191
|
+
(acc, [headerName, header]) => {
|
|
192
|
+
if (header && typeof header === "object") {
|
|
193
|
+
return {
|
|
194
|
+
[headerName]: transformResponseHeader(header),
|
|
195
|
+
...acc
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return acc;
|
|
199
|
+
},
|
|
200
|
+
{}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
migratedResponses[name] = responseObj;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (Object.keys(migratedResponses).length > 0) {
|
|
208
|
+
;
|
|
209
|
+
document.components.responses = migratedResponses;
|
|
210
|
+
}
|
|
211
|
+
delete document.responses;
|
|
212
|
+
}
|
|
105
213
|
if (typeof document.paths === "object") {
|
|
106
214
|
for (const path in document.paths) {
|
|
107
215
|
if (Object.hasOwn(document.paths, path)) {
|
|
@@ -164,6 +272,18 @@ function upgradeFromTwoToThree(originalSpecification) {
|
|
|
164
272
|
}
|
|
165
273
|
delete responseItem.schema;
|
|
166
274
|
}
|
|
275
|
+
if (responseItem.examples && typeof responseItem.examples === "object") {
|
|
276
|
+
if (typeof responseItem.content !== "object") {
|
|
277
|
+
responseItem.content = {};
|
|
278
|
+
}
|
|
279
|
+
for (const [mediaType, exampleValue] of Object.entries(responseItem.examples)) {
|
|
280
|
+
if (typeof responseItem.content[mediaType] !== "object") {
|
|
281
|
+
responseItem.content[mediaType] = {};
|
|
282
|
+
}
|
|
283
|
+
responseItem.content[mediaType].example = exampleValue;
|
|
284
|
+
}
|
|
285
|
+
delete responseItem.examples;
|
|
286
|
+
}
|
|
167
287
|
}
|
|
168
288
|
}
|
|
169
289
|
}
|
|
@@ -269,6 +389,18 @@ function transformParameterObject(parameter) {
|
|
|
269
389
|
}
|
|
270
390
|
const serializationStyle = getParameterSerializationStyle(parameter);
|
|
271
391
|
const schema = transformItemsObject(parameter);
|
|
392
|
+
const { xExample, xExamples } = extractXExampleExtensions(parameter);
|
|
393
|
+
if (isNonEmptyObject(xExample)) {
|
|
394
|
+
parameter.examples = transformXExampleToExamples(xExample);
|
|
395
|
+
} else if (isNonEmptyObject(xExamples)) {
|
|
396
|
+
parameter.examples = Object.entries(xExamples).reduce(
|
|
397
|
+
(acc, [key, exampleValue]) => {
|
|
398
|
+
acc[key] = wrapAsExampleObject(exampleValue);
|
|
399
|
+
return acc;
|
|
400
|
+
},
|
|
401
|
+
{}
|
|
402
|
+
);
|
|
403
|
+
}
|
|
272
404
|
delete parameter.collectionFormat;
|
|
273
405
|
delete parameter.default;
|
|
274
406
|
if (!parameter.in) {
|
|
@@ -338,6 +470,7 @@ function getParameterSerializationStyle(parameter) {
|
|
|
338
470
|
return {};
|
|
339
471
|
}
|
|
340
472
|
function migrateBodyParameter(bodyParameter, consumes) {
|
|
473
|
+
const { xExample, xExamples } = extractXExampleExtensions(bodyParameter);
|
|
341
474
|
delete bodyParameter.name;
|
|
342
475
|
delete bodyParameter.in;
|
|
343
476
|
const { schema, ...requestBody } = bodyParameter;
|
|
@@ -350,33 +483,62 @@ function migrateBodyParameter(bodyParameter, consumes) {
|
|
|
350
483
|
requestBodyObject.content[type] = {
|
|
351
484
|
schema
|
|
352
485
|
};
|
|
486
|
+
if (isNonEmptyObject(xExample) && type in xExample) {
|
|
487
|
+
requestBodyObject.content[type].example = xExample[type];
|
|
488
|
+
}
|
|
489
|
+
if (isNonEmptyObject(xExamples) && type in xExamples) {
|
|
490
|
+
const examples = xExamples[type];
|
|
491
|
+
const isExamplesCollection = isNonEmptyObject(examples) && Object.values(examples).every((example) => isExampleObject(example));
|
|
492
|
+
if (isExamplesCollection) {
|
|
493
|
+
requestBodyObject.content[type].examples = examples;
|
|
494
|
+
} else if (isNamedExamplesCollection(examples)) {
|
|
495
|
+
requestBodyObject.content[type].examples = Object.entries(examples).reduce(
|
|
496
|
+
(acc, [key, exampleValue]) => {
|
|
497
|
+
acc[key] = wrapAsExampleObject(exampleValue);
|
|
498
|
+
return acc;
|
|
499
|
+
},
|
|
500
|
+
{}
|
|
501
|
+
);
|
|
502
|
+
} else {
|
|
503
|
+
requestBodyObject.content[type].examples = {
|
|
504
|
+
default: wrapAsExampleObject(examples)
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
353
508
|
}
|
|
354
509
|
}
|
|
355
510
|
return requestBodyObject;
|
|
356
511
|
}
|
|
357
|
-
function migrateFormDataParameter(parameters) {
|
|
512
|
+
function migrateFormDataParameter(parameters, consumes = ["multipart/form-data"]) {
|
|
358
513
|
const requestBodyObject = {
|
|
359
514
|
content: {}
|
|
360
515
|
};
|
|
516
|
+
const filtered = consumes.filter(
|
|
517
|
+
(type) => type === "multipart/form-data" || type === "application/x-www-form-urlencoded"
|
|
518
|
+
);
|
|
519
|
+
const contentTypes = filtered.length > 0 ? filtered : ["multipart/form-data"];
|
|
361
520
|
if (requestBodyObject.content) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
formContent.schema.properties
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
521
|
+
for (const contentType of contentTypes) {
|
|
522
|
+
requestBodyObject.content[contentType] = {
|
|
523
|
+
schema: {
|
|
524
|
+
type: "object",
|
|
525
|
+
properties: {},
|
|
526
|
+
required: []
|
|
527
|
+
// Initialize required array
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
const formContent = requestBodyObject.content?.[contentType];
|
|
531
|
+
if (formContent?.schema && typeof formContent.schema === "object" && "properties" in formContent.schema) {
|
|
532
|
+
for (const param of parameters) {
|
|
533
|
+
if (param.name && formContent.schema.properties) {
|
|
534
|
+
formContent.schema.properties[param.name] = {
|
|
535
|
+
type: param.type,
|
|
536
|
+
description: param.description,
|
|
537
|
+
...param.format ? { format: param.format } : {}
|
|
538
|
+
};
|
|
539
|
+
if (param.required && Array.isArray(formContent.schema.required)) {
|
|
540
|
+
formContent.schema.required.push(param.name);
|
|
541
|
+
}
|
|
380
542
|
}
|
|
381
543
|
}
|
|
382
544
|
}
|
|
@@ -396,7 +558,7 @@ function migrateParameters(parameters, consumes) {
|
|
|
396
558
|
}
|
|
397
559
|
const formDataParameters = parameters.filter((parameter) => parameter.in === "formData");
|
|
398
560
|
if (formDataParameters.length > 0) {
|
|
399
|
-
const requestBodyObject = migrateFormDataParameter(formDataParameters);
|
|
561
|
+
const requestBodyObject = migrateFormDataParameter(formDataParameters, consumes);
|
|
400
562
|
if (typeof result.requestBody !== "object") {
|
|
401
563
|
result.requestBody = requestBodyObject;
|
|
402
564
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/2.0-to-3.0/upgrade-from-two-to-three.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV2, OpenAPIV3 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { traverse } from '@/helpers/traverse'\n\n/** Update the flow names to OpenAPI 3.1.0 format */\nconst upgradeFlow = (flow: string): 'implicit' | 'password' | 'clientCredentials' | 'authorizationCode' => {\n switch (flow) {\n case 'application':\n return 'clientCredentials'\n case 'accessCode':\n return 'authorizationCode'\n case 'implicit':\n return 'implicit'\n case 'password':\n return 'password'\n default:\n return flow as never\n }\n}\n\n/**\n * Upgrade Swagger 2.0 to OpenAPI 3.0\n *\n * https://swagger.io/blog/news/whats-new-in-openapi-3-0/\n */\nexport function upgradeFromTwoToThree(originalSpecification: UnknownObject) {\n let document = originalSpecification\n\n // Version\n if (\n document !== null &&\n typeof document === 'object' &&\n typeof document.swagger === 'string' &&\n document.swagger?.startsWith('2.0')\n ) {\n document.openapi = '3.0.4'\n delete document.swagger\n } else {\n // Skip if it's something else than 3.0.x\n return document\n }\n\n // Servers\n if (document.host) {\n const schemes = Array.isArray(document.schemes) && document.schemes?.length ? document.schemes : ['http']\n\n document.servers = schemes.map((scheme: string[]) => ({\n url: `${scheme}://${document.host}${document.basePath ?? ''}`,\n }))\n\n delete document.basePath\n delete document.schemes\n delete document.host\n } else if (document.basePath) {\n document.servers = [{ url: document.basePath }]\n delete document.basePath\n }\n\n // Schemas\n if (document.definitions) {\n document.components = Object.assign({}, document.components, {\n schemas: document.definitions,\n })\n\n delete document.definitions\n\n // Rewrite $refs to definitions\n document = traverse(document, (schema) => {\n // Rewrite $refs to components\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/definitions/')) {\n schema.$ref = schema.$ref.replace(/^#\\/definitions\\//, '#/components/schemas/')\n }\n\n return schema\n })\n }\n\n // Transform file type to string with binary format\n document = traverse(document, (schema) => {\n if (schema.type === 'file') {\n schema.type = 'string'\n schema.format = 'binary'\n }\n\n return schema\n })\n\n if (Object.hasOwn(document, 'parameters')) {\n // update all the $refs before we do any transformations\n document = traverse(document, (schema) => {\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/parameters/')) {\n const schemaName = schema.$ref.split('/')[2]\n\n if (!schemaName) {\n return schema\n }\n\n const param =\n document.parameters && typeof document.parameters === 'object' && schemaName in document.parameters\n ? (document.parameters as Record<string, unknown>)[schemaName]\n : undefined\n\n if (param && typeof param === 'object' && 'in' in param && (param.in === 'body' || param.in === 'formData')) {\n schema.$ref = schema.$ref.replace(/^#\\/parameters\\//, '#/components/requestBodies/')\n } else {\n schema.$ref = schema.$ref.replace(/^#\\/parameters\\//, '#/components/parameters/')\n }\n }\n\n return schema\n })\n\n document.components ??= {}\n\n const params: Record<string, OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject> = {}\n const bodyParams: Record<string, OpenAPIV3.RequestBodyObject> = {}\n const parameters =\n document.parameters && typeof document.parameters === 'object'\n ? (document.parameters as Record<string, unknown>)\n : {}\n for (const [name, param] of Object.entries(parameters)) {\n if (param && typeof param === 'object') {\n // Handle reference objects\n if ('$ref' in param) {\n const convertedParam = transformParameterObject(param as OpenAPIV2.ReferenceObject)\n params[name] = convertedParam\n } else if ('in' in param) {\n if (param.in === 'body') {\n bodyParams[name] = migrateBodyParameter(\n param as OpenAPIV2.ParameterObject,\n (document.consumes as string[] | undefined) ?? ['application/json'],\n )\n } else if (param.in === 'formData') {\n bodyParams[name] = migrateFormDataParameter([param as OpenAPIV2.ParameterObject])\n } else {\n const convertedParam = transformParameterObject(param as OpenAPIV2.ParameterObject)\n params[name] = convertedParam\n }\n }\n }\n }\n\n if (Object.keys(params).length > 0) {\n ;(document.components as UnknownObject).parameters = params\n }\n\n if (Object.keys(bodyParams).length > 0) {\n ;(document.components as UnknownObject).requestBodies = bodyParams\n }\n\n delete document.parameters\n }\n\n // Paths\n if (typeof document.paths === 'object') {\n for (const path in document.paths) {\n if (Object.hasOwn(document.paths, path)) {\n const pathItem =\n document.paths && typeof document.paths === 'object' && path in document.paths\n ? (document.paths as Record<string, unknown>)[path]\n : undefined\n\n if (!pathItem || typeof pathItem !== 'object') {\n continue\n }\n\n let requestBodyObject: OpenAPIV3.RequestBodyObject | undefined\n\n for (const methodOrParameters in pathItem) {\n if (methodOrParameters === 'parameters' && Object.hasOwn(pathItem, methodOrParameters)) {\n const pathItemParameters = migrateParameters(\n (pathItem as any).parameters,\n (document.consumes as string[] | undefined) ?? ['application/json'],\n )\n\n ;(pathItem as any).parameters = pathItemParameters.parameters\n requestBodyObject = pathItemParameters.requestBody\n } else if (Object.hasOwn(pathItem, methodOrParameters)) {\n const operationItem = (pathItem as any)[methodOrParameters]\n\n if (requestBodyObject) {\n operationItem.requestBody = requestBodyObject\n }\n\n if (operationItem.parameters) {\n const migrationResult = migrateParameters(\n operationItem.parameters,\n operationItem.consumes ?? document.consumes ?? ['application/json'],\n )\n\n operationItem.parameters = migrationResult.parameters\n\n if (migrationResult.requestBody) {\n operationItem.requestBody = migrationResult.requestBody\n }\n }\n\n delete operationItem.consumes\n\n // Responses\n if (operationItem.responses) {\n for (const response in operationItem.responses) {\n if (Object.hasOwn(operationItem.responses, response)) {\n const responseItem = operationItem.responses[response]\n\n if (responseItem.headers && typeof responseItem.headers === 'object') {\n responseItem.headers = Object.entries(responseItem.headers).reduce(\n (acc, [name, header]) => {\n if (header && typeof header === 'object') {\n return {\n [name]: transformResponseHeader(header as OpenAPIV2.HeaderObject),\n ...acc,\n }\n }\n return acc\n },\n {} as Record<string, OpenAPIV3.HeaderObject | OpenAPIV3.ReferenceObject>,\n )\n }\n if (responseItem.schema) {\n const produces = document.produces ?? operationItem.produces ?? ['application/json']\n\n if (typeof responseItem.content !== 'object') {\n responseItem.content = {}\n }\n\n for (const type of produces) {\n responseItem.content[type] = {\n schema: responseItem.schema,\n }\n }\n\n delete responseItem.schema\n }\n }\n }\n }\n\n delete operationItem.produces\n\n // Delete empty parameters\n if (operationItem.parameters?.length === 0) {\n delete operationItem.parameters\n }\n }\n }\n }\n }\n }\n\n // Upgrade securityDefinitions\n if (document.securityDefinitions) {\n if (typeof document.components !== 'object' || document.components === null) {\n document.components = {}\n }\n\n if (document.components && typeof document.components === 'object') {\n Object.assign(document.components, { securitySchemes: {} })\n }\n\n for (const [key, securityScheme] of Object.entries(document.securityDefinitions)) {\n if (typeof securityScheme === 'object') {\n if ('type' in securityScheme && securityScheme.type === 'oauth2') {\n const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme as {\n type: 'oauth2'\n flow?: string\n authorizationUrl?: string\n tokenUrl?: string\n scopes?: Record<string, string>\n }\n\n // Convert flow values to OpenAPI 3.1.0 format\n\n if (\n document.components &&\n typeof document.components === 'object' &&\n 'securitySchemes' in document.components &&\n document.components.securitySchemes\n ) {\n Object.assign(document.components.securitySchemes, {\n [key]: {\n type: 'oauth2',\n flows: {\n [upgradeFlow(flow || 'implicit')]: Object.assign(\n {},\n authorizationUrl && { authorizationUrl },\n tokenUrl && { tokenUrl },\n scopes && { scopes },\n ),\n },\n },\n })\n }\n } else if ('type' in securityScheme && securityScheme.type === 'basic') {\n if (\n document.components &&\n typeof document.components === 'object' &&\n 'securitySchemes' in document.components &&\n document.components.securitySchemes\n ) {\n Object.assign(document.components.securitySchemes, {\n [key]: {\n type: 'http',\n scheme: 'basic',\n },\n })\n }\n } else {\n if (\n document.components &&\n typeof document.components === 'object' &&\n 'securitySchemes' in document.components &&\n document.components.securitySchemes\n ) {\n Object.assign(document.components.securitySchemes, {\n [key]: securityScheme,\n })\n }\n }\n }\n }\n\n delete document.securityDefinitions\n }\n\n delete document.consumes\n delete document.produces\n\n return document as OpenAPIV3.Document\n}\n\nfunction transformItemsObject<T extends Record<PropertyKey, unknown>>(obj: T): OpenAPIV3.SchemaObject {\n const schemaProperties = [\n 'type',\n 'format',\n 'items',\n 'maximum',\n 'exclusiveMaximum',\n 'minimum',\n 'exclusiveMinimum',\n 'maxLength',\n 'minLength',\n 'pattern',\n 'maxItems',\n 'minItems',\n 'uniqueItems',\n 'enum',\n 'multipleOf',\n ]\n\n return schemaProperties.reduce((acc, property) => {\n if (Object.hasOwn(obj, property)) {\n acc[property] = obj[property]\n delete obj[property]\n }\n\n return acc\n }, {} as OpenAPIV3.SchemaObject)\n}\n\nfunction getParameterLocation(location: OpenAPIV2.ParameterLocation): OpenAPIV3.ParameterLocation {\n if (location === 'formData') {\n throw new Error('Encountered a formData parameter which should have been filtered out by the caller')\n }\n if (location === 'body') {\n throw new Error('Encountered a body parameter which should have been filtered out by the caller')\n }\n return location as OpenAPIV3.ParameterLocation\n}\n\nfunction transformParameterObject(\n parameter: OpenAPIV2.ParameterObject | OpenAPIV2.ReferenceObject,\n): OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject {\n if (Object.hasOwn(parameter, '$ref') && '$ref' in parameter) {\n return {\n $ref: parameter.$ref,\n }\n }\n\n // it is important to call getParameterSerializationStyle first because transformItemsObject modifies properties on which getParameterSerializationStyle rely on\n const serializationStyle = getParameterSerializationStyle(parameter)\n const schema = transformItemsObject(parameter)\n\n delete parameter.collectionFormat\n delete parameter.default\n\n if (!parameter.in) {\n throw new Error('Parameter object must have an \"in\" property')\n }\n\n return {\n schema,\n ...serializationStyle,\n ...parameter,\n in: getParameterLocation(parameter.in),\n }\n}\n\n/**\n * Transform OpenAPI 2.0 response header to OpenAPI 3.0 format.\n * Response headers do not have \"in\", \"name\", \"style\", or \"explode\" properties.\n */\nfunction transformResponseHeader(\n header: OpenAPIV2.HeaderObject | OpenAPIV2.ReferenceObject,\n): OpenAPIV3.HeaderObject | OpenAPIV3.ReferenceObject {\n if (Object.hasOwn(header, '$ref') && '$ref' in header) {\n return {\n $ref: header.$ref,\n }\n }\n\n const schema = transformItemsObject(header)\n\n return {\n ...header,\n schema,\n }\n}\n\ntype CollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi'\n\ntype ParameterSerializationStyle = { style?: OpenAPIV3.ParameterStyle; explode?: boolean }\n\nconst querySerialization: Record<CollectionFormat, ParameterSerializationStyle> = {\n ssv: {\n style: 'spaceDelimited',\n explode: false,\n },\n pipes: {\n style: 'pipeDelimited',\n explode: false,\n },\n multi: {\n style: 'form',\n explode: true,\n },\n csv: {\n style: 'form',\n explode: false,\n },\n tsv: {},\n}\n\nconst pathAndHeaderSerialization: Record<CollectionFormat, ParameterSerializationStyle> = {\n ssv: {},\n pipes: {},\n multi: {},\n csv: {\n style: 'simple',\n explode: false,\n },\n tsv: {},\n}\n\nconst serializationStyles = {\n header: pathAndHeaderSerialization,\n query: querySerialization,\n path: pathAndHeaderSerialization,\n} as const\n\nfunction getParameterSerializationStyle(parameter: OpenAPIV2.ParameterObject): ParameterSerializationStyle {\n if (\n parameter.type !== 'array' ||\n !(parameter.in === 'query' || parameter.in === 'path' || parameter.in === 'header')\n ) {\n return {}\n }\n\n const collectionFormat = parameter.collectionFormat ?? 'csv'\n\n if (\n parameter.in in serializationStyles &&\n collectionFormat in serializationStyles[parameter.in as keyof typeof serializationStyles]\n ) {\n return serializationStyles[parameter.in as keyof typeof serializationStyles][collectionFormat as CollectionFormat]\n }\n\n return {}\n}\n\ntype ParameterMigrationResult = {\n parameters: (OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject)[]\n requestBody?: OpenAPIV3.RequestBodyObject\n}\n\nfunction migrateBodyParameter(\n bodyParameter: OpenAPIV2.ParameterObject,\n consumes: string[],\n): OpenAPIV3.RequestBodyObject {\n delete bodyParameter.name\n delete bodyParameter.in\n\n const { schema, ...requestBody } = bodyParameter\n\n const requestBodyObject: OpenAPIV3.RequestBodyObject = {\n content: {},\n ...requestBody,\n }\n\n if (requestBodyObject.content) {\n for (const type of consumes) {\n requestBodyObject.content[type] = {\n schema: schema,\n }\n }\n }\n\n return requestBodyObject\n}\n\nfunction migrateFormDataParameter(parameters: OpenAPIV2.ParameterObject[]): OpenAPIV3.RequestBodyObject {\n const requestBodyObject: OpenAPIV3.RequestBodyObject = {\n content: {},\n }\n\n if (requestBodyObject.content) {\n requestBodyObject.content['application/x-www-form-urlencoded'] = {\n schema: {\n type: 'object',\n properties: {},\n required: [], // Initialize required array\n },\n }\n\n const formContent = requestBodyObject.content?.['application/x-www-form-urlencoded']\n if (formContent?.schema && typeof formContent.schema === 'object' && 'properties' in formContent.schema) {\n for (const param of parameters) {\n if (param.name && formContent.schema.properties) {\n formContent.schema.properties[param.name] = {\n type: param.type,\n description: param.description,\n }\n\n // Add to required array if param is required\n if (param.required && Array.isArray(formContent.schema.required)) {\n formContent.schema.required.push(param.name)\n }\n }\n }\n }\n }\n\n return requestBodyObject\n}\n\nfunction migrateParameters(parameters: OpenAPIV2.ParameterObject[], consumes: string[]): ParameterMigrationResult {\n const result: ParameterMigrationResult = {\n parameters: parameters\n .filter((parameter) => !(parameter.in === 'body' || parameter.in === 'formData'))\n .map((parameter) => transformParameterObject(parameter)),\n }\n\n const bodyParameter = structuredClone(\n parameters.find((parameter: OpenAPIV2.ParameterObject) => parameter.in === 'body') ?? {},\n )\n\n if (bodyParameter && Object.keys(bodyParameter).length) {\n result.requestBody = migrateBodyParameter(bodyParameter, consumes)\n }\n\n const formDataParameters = parameters.filter((parameter: OpenAPIV2.ParameterObject) => parameter.in === 'formData')\n\n if (formDataParameters.length > 0) {\n const requestBodyObject = migrateFormDataParameter(formDataParameters)\n\n if (typeof result.requestBody !== 'object') {\n result.requestBody = requestBodyObject\n } else {\n result.requestBody = {\n ...result.requestBody,\n content: {\n ...result.requestBody.content,\n ...requestBodyObject.content,\n },\n }\n }\n\n if (typeof result.requestBody !== 'object') {\n result.requestBody = {\n content: {},\n }\n }\n }\n\n return result\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,gBAAgB;AAGzB,MAAM,cAAc,CAAC,SAAsF;AACzG,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAOO,SAAS,sBAAsB,uBAAsC;AAC1E,MAAI,WAAW;AAGf,MACE,aAAa,QACb,OAAO,aAAa,YACpB,OAAO,SAAS,YAAY,YAC5B,SAAS,SAAS,WAAW,KAAK,GAClC;AACA,aAAS,UAAU;AACnB,WAAO,SAAS;AAAA,EAClB,OAAO;AAEL,WAAO;AAAA,EACT;AAGA,MAAI,SAAS,MAAM;AACjB,UAAM,UAAU,MAAM,QAAQ,SAAS,OAAO,KAAK,SAAS,SAAS,SAAS,SAAS,UAAU,CAAC,MAAM;AAExG,aAAS,UAAU,QAAQ,IAAI,CAAC,YAAsB;AAAA,MACpD,KAAK,GAAG,MAAM,MAAM,SAAS,IAAI,GAAG,SAAS,YAAY,EAAE;AAAA,IAC7D,EAAE;AAEF,WAAO,SAAS;AAChB,WAAO,SAAS;AAChB,WAAO,SAAS;AAAA,EAClB,WAAW,SAAS,UAAU;AAC5B,aAAS,UAAU,CAAC,EAAE,KAAK,SAAS,SAAS,CAAC;AAC9C,WAAO,SAAS;AAAA,EAClB;AAGA,MAAI,SAAS,aAAa;AACxB,aAAS,aAAa,OAAO,OAAO,CAAC,GAA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,IACvC,YAAY,WACT,OAAO,CAAC,cAAc,EAAE,UAAU,OAAO,UAAU,UAAU,OAAO,WAAW,EAC/E,IAAI,CAAC,cAAc,yBAAyB,SAAS,CAAC;AAAA,EAC3D;AAEA,QAAM,gBAAgB;AAAA,IACpB,WAAW,KAAK,CAAC,cAAyC,UAAU,OAAO,MAAM,KAAK,CAAC;AAAA,EACzF;AAEA,MAAI,iBAAiB,OAAO,KAAK,aAAa,EAAE,QAAQ;AACtD,WAAO,cAAc,qBAAqB,eAAe,QAAQ;AAAA,EACnE;AAEA,QAAM,qBAAqB,WAAW,OAAO,CAAC,cAAyC,UAAU,OAAO,UAAU;AAElH,MAAI,mBAAmB,SAAS,GAAG;AACjC,UAAM,oBAAoB,yBAAyB,kBAAkB;AAErE,QAAI,OAAO,OAAO,gBAAgB,UAAU;AAC1C,aAAO,cAAc;AAAA,IACvB,OAAO;AACL,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAG,OAAO,YAAY;AAAA,UACtB,GAAG,kBAAkB;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,gBAAgB,UAAU;AAC1C,aAAO,cAAc;AAAA,QACnB,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import type { OpenAPIV2, OpenAPIV3 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { traverse } from '@/helpers/traverse'\n\ntype XExampleExtensions = {\n xExample: Record<string, unknown> | undefined\n xExamples: Record<string, unknown> | undefined\n}\n\n/** Extracts and removes x-example and x-examples extensions from an object */\nfunction extractXExampleExtensions(obj: Record<string, unknown>): XExampleExtensions {\n const xExample = obj['x-example'] as Record<string, unknown> | undefined\n const xExamples = obj['x-examples'] as Record<string, unknown> | undefined\n\n delete obj['x-example']\n delete obj['x-examples']\n\n return { xExample, xExamples }\n}\n\n/** Checks if a value is a non-null, non-array object with at least one entry */\nfunction isNonEmptyObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value) && Object.keys(value).length > 0\n}\n\n/**\n * Checks if a value looks like a collection of named examples (all values are objects).\n * This helps distinguish between:\n * - A single example: { message: 'OK', type: 'success' } - values are primitives\n * - Named examples: { 'my-example': { message: 'OK' } } - values are objects\n */\nfunction isNamedExamplesCollection(value: unknown): value is Record<string, Record<string, unknown>> {\n return (\n isNonEmptyObject(value) &&\n Object.values(value).every((v) => typeof v === 'object' && v !== null && !Array.isArray(v))\n )\n}\n\n/** The allowed properties for an OpenAPI 3.x ExampleObject */\nconst EXAMPLE_OBJECT_PROPERTIES = new Set(['summary', 'description', 'value', 'externalValue'])\n\n/**\n * Checks if a value is a valid OpenAPI 3.x ExampleObject.\n *\n * An ExampleObject must have a `value` (or `externalValue`) property and can only contain\n * properties from the allowed set: `summary`, `description`, `value`, `externalValue`.\n *\n * This prevents false positives when user's example data happens to have a `value` property\n * (e.g., `{ value: \"some data\", count: 5 }` should NOT be treated as an ExampleObject).\n */\nfunction isExampleObject(value: unknown): value is OpenAPIV3.ExampleObject {\n if (typeof value !== 'object' || value === null) {\n return false\n }\n\n const obj = value as Record<string, unknown>\n const hasValueOrExternalValue = 'value' in obj || 'externalValue' in obj\n const onlyHasAllowedProperties = Object.keys(obj).every((key) => EXAMPLE_OBJECT_PROPERTIES.has(key))\n\n return hasValueOrExternalValue && onlyHasAllowedProperties\n}\n\n/** Wraps a value as an ExampleObject, preserving existing structure if valid */\nfunction wrapAsExampleObject(value: unknown): OpenAPIV3.ExampleObject {\n if (isExampleObject(value)) {\n return value\n }\n return { value }\n}\n\n/** Transforms x-example entries to OpenAPI 3.x examples format */\nfunction transformXExampleToExamples(xExample: Record<string, unknown>): Record<string, OpenAPIV3.ExampleObject> {\n return Object.entries(xExample).reduce(\n (acc, [key, value]) => {\n acc[key] = { value }\n return acc\n },\n {} as Record<string, OpenAPIV3.ExampleObject>,\n )\n}\n\n/** Update the flow names to OpenAPI 3.1.0 format */\nconst upgradeFlow = (flow: string): 'implicit' | 'password' | 'clientCredentials' | 'authorizationCode' => {\n switch (flow) {\n case 'application':\n return 'clientCredentials'\n case 'accessCode':\n return 'authorizationCode'\n case 'implicit':\n return 'implicit'\n case 'password':\n return 'password'\n default:\n return flow as never\n }\n}\n\n/**\n * Upgrade Swagger 2.0 to OpenAPI 3.0\n *\n * https://swagger.io/blog/news/whats-new-in-openapi-3-0/\n */\nexport function upgradeFromTwoToThree(originalSpecification: UnknownObject) {\n let document = originalSpecification\n\n // Version\n if (\n document !== null &&\n typeof document === 'object' &&\n typeof document.swagger === 'string' &&\n document.swagger?.startsWith('2.0')\n ) {\n document.openapi = '3.0.4'\n delete document.swagger\n } else {\n // Skip if it's something else than 3.0.x\n return document\n }\n\n // Servers\n if (document.host) {\n const schemes = Array.isArray(document.schemes) && document.schemes?.length ? document.schemes : ['http']\n\n document.servers = schemes.map((scheme: string[]) => ({\n url: `${scheme}://${document.host}${document.basePath ?? ''}`,\n }))\n\n delete document.basePath\n delete document.schemes\n delete document.host\n } else if (document.basePath) {\n document.servers = [{ url: document.basePath }]\n delete document.basePath\n }\n\n // Schemas\n if (document.definitions) {\n document.components = Object.assign({}, document.components, {\n schemas: document.definitions,\n })\n\n delete document.definitions\n\n // Rewrite $refs to definitions\n document = traverse(document, (schema) => {\n // Rewrite $refs to components\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/definitions/')) {\n schema.$ref = schema.$ref.replace(/^#\\/definitions\\//, '#/components/schemas/')\n }\n\n return schema\n })\n }\n\n // Transform file type to string with binary format\n document = traverse(document, (schema) => {\n if (schema.type === 'file') {\n schema.type = 'string'\n schema.format = 'binary'\n }\n\n return schema\n })\n\n if (Object.hasOwn(document, 'parameters')) {\n // update all the $refs before we do any transformations\n document = traverse(document, (schema) => {\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/parameters/')) {\n const schemaName = schema.$ref.split('/')[2]\n\n if (!schemaName) {\n return schema\n }\n\n const param =\n document.parameters && typeof document.parameters === 'object' && schemaName in document.parameters\n ? (document.parameters as Record<string, unknown>)[schemaName]\n : undefined\n\n if (param && typeof param === 'object' && 'in' in param && (param.in === 'body' || param.in === 'formData')) {\n schema.$ref = schema.$ref.replace(/^#\\/parameters\\//, '#/components/requestBodies/')\n } else {\n schema.$ref = schema.$ref.replace(/^#\\/parameters\\//, '#/components/parameters/')\n }\n }\n\n return schema\n })\n\n document.components ??= {}\n\n const params: Record<string, OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject> = {}\n const bodyParams: Record<string, OpenAPIV3.RequestBodyObject> = {}\n const parameters =\n document.parameters && typeof document.parameters === 'object'\n ? (document.parameters as Record<string, unknown>)\n : {}\n for (const [name, param] of Object.entries(parameters)) {\n if (param && typeof param === 'object') {\n // Handle reference objects\n if ('$ref' in param) {\n const convertedParam = transformParameterObject(param as OpenAPIV2.ReferenceObject)\n params[name] = convertedParam\n } else if ('in' in param) {\n if (param.in === 'body') {\n bodyParams[name] = migrateBodyParameter(\n param as OpenAPIV2.ParameterObject,\n (document.consumes as string[] | undefined) ?? ['application/json'],\n )\n } else if (param.in === 'formData') {\n bodyParams[name] = migrateFormDataParameter(\n [param as OpenAPIV2.ParameterObject],\n document.consumes as string[] | undefined,\n )\n } else {\n const convertedParam = transformParameterObject(param as OpenAPIV2.ParameterObject)\n params[name] = convertedParam\n }\n }\n }\n }\n\n if (Object.keys(params).length > 0) {\n ;(document.components as UnknownObject).parameters = params\n }\n\n if (Object.keys(bodyParams).length > 0) {\n ;(document.components as UnknownObject).requestBodies = bodyParams\n }\n\n delete document.parameters\n }\n\n // Handle global responses defined in #/responses\n if (Object.hasOwn(document, 'responses') && typeof document.responses === 'object' && document.responses !== null) {\n // Update all $refs from #/responses/ to #/components/responses/\n document = traverse(document, (schema) => {\n if (typeof schema.$ref === 'string' && schema.$ref.startsWith('#/responses/')) {\n schema.$ref = schema.$ref.replace(/^#\\/responses\\//, '#/components/responses/')\n }\n return schema\n })\n\n document.components ??= {}\n\n const migratedResponses: Record<string, OpenAPIV3.ResponseObject | OpenAPIV3.ReferenceObject> = {}\n const responses = document.responses as Record<string, unknown>\n\n for (const [name, response] of Object.entries(responses)) {\n if (response && typeof response === 'object') {\n // Handle reference objects\n if ('$ref' in response) {\n migratedResponses[name] = response as OpenAPIV3.ReferenceObject\n } else {\n // Transform the response object\n const responseObj = response as Record<string, unknown>\n const produces = (document.produces as string[] | undefined) ?? ['application/json']\n\n // Transform schema to content\n if (responseObj.schema) {\n if (typeof responseObj.content !== 'object') {\n responseObj.content = {}\n }\n\n for (const type of produces) {\n ;(responseObj.content as Record<string, unknown>)[type] = {\n schema: responseObj.schema,\n }\n }\n\n delete responseObj.schema\n }\n\n // Transform examples from Swagger 2.0 to OpenAPI 3.0 format\n if (responseObj.examples && typeof responseObj.examples === 'object') {\n if (typeof responseObj.content !== 'object') {\n responseObj.content = {}\n }\n\n for (const [mediaType, exampleValue] of Object.entries(responseObj.examples as Record<string, unknown>)) {\n if (typeof (responseObj.content as Record<string, unknown>)[mediaType] !== 'object') {\n ;(responseObj.content as Record<string, unknown>)[mediaType] = {}\n }\n ;((responseObj.content as Record<string, unknown>)[mediaType] as Record<string, unknown>).example =\n exampleValue\n }\n\n delete responseObj.examples\n }\n\n // Transform headers if present\n if (responseObj.headers && typeof responseObj.headers === 'object') {\n responseObj.headers = Object.entries(responseObj.headers as Record<string, unknown>).reduce(\n (acc, [headerName, header]) => {\n if (header && typeof header === 'object') {\n return {\n [headerName]: transformResponseHeader(header as OpenAPIV2.HeaderObject),\n ...acc,\n }\n }\n return acc\n },\n {} as Record<string, OpenAPIV3.HeaderObject | OpenAPIV3.ReferenceObject>,\n )\n }\n\n migratedResponses[name] = responseObj as OpenAPIV3.ResponseObject\n }\n }\n }\n\n if (Object.keys(migratedResponses).length > 0) {\n ;(document.components as UnknownObject).responses = migratedResponses\n }\n\n delete document.responses\n }\n\n // Paths\n if (typeof document.paths === 'object') {\n for (const path in document.paths) {\n if (Object.hasOwn(document.paths, path)) {\n const pathItem =\n document.paths && typeof document.paths === 'object' && path in document.paths\n ? (document.paths as Record<string, unknown>)[path]\n : undefined\n\n if (!pathItem || typeof pathItem !== 'object') {\n continue\n }\n\n let requestBodyObject: OpenAPIV3.RequestBodyObject | undefined\n\n for (const methodOrParameters in pathItem) {\n if (methodOrParameters === 'parameters' && Object.hasOwn(pathItem, methodOrParameters)) {\n const pathItemParameters = migrateParameters(\n (pathItem as any).parameters,\n (document.consumes as string[] | undefined) ?? ['application/json'],\n )\n\n ;(pathItem as any).parameters = pathItemParameters.parameters\n requestBodyObject = pathItemParameters.requestBody\n } else if (Object.hasOwn(pathItem, methodOrParameters)) {\n const operationItem = (pathItem as any)[methodOrParameters]\n\n if (requestBodyObject) {\n operationItem.requestBody = requestBodyObject\n }\n\n if (operationItem.parameters) {\n const migrationResult = migrateParameters(\n operationItem.parameters,\n operationItem.consumes ?? document.consumes ?? ['application/json'],\n )\n\n operationItem.parameters = migrationResult.parameters\n\n if (migrationResult.requestBody) {\n operationItem.requestBody = migrationResult.requestBody\n }\n }\n\n delete operationItem.consumes\n\n // Responses\n if (operationItem.responses) {\n for (const response in operationItem.responses) {\n if (Object.hasOwn(operationItem.responses, response)) {\n const responseItem = operationItem.responses[response]\n\n if (responseItem.headers && typeof responseItem.headers === 'object') {\n responseItem.headers = Object.entries(responseItem.headers).reduce(\n (acc, [name, header]) => {\n if (header && typeof header === 'object') {\n return {\n [name]: transformResponseHeader(header as OpenAPIV2.HeaderObject),\n ...acc,\n }\n }\n return acc\n },\n {} as Record<string, OpenAPIV3.HeaderObject | OpenAPIV3.ReferenceObject>,\n )\n }\n if (responseItem.schema) {\n const produces = document.produces ?? operationItem.produces ?? ['application/json']\n\n if (typeof responseItem.content !== 'object') {\n responseItem.content = {}\n }\n\n for (const type of produces) {\n responseItem.content[type] = {\n schema: responseItem.schema,\n }\n }\n\n delete responseItem.schema\n }\n\n // Transform response examples from Swagger 2.0 to OpenAPI 3.0 format\n // In Swagger 2.0, examples are at response level: examples: { 'application/json': {...} }\n // In OpenAPI 3.0, examples move inside content: content: { 'application/json': { example: {...} } }\n if (responseItem.examples && typeof responseItem.examples === 'object') {\n if (typeof responseItem.content !== 'object') {\n responseItem.content = {}\n }\n\n for (const [mediaType, exampleValue] of Object.entries(responseItem.examples)) {\n if (typeof responseItem.content[mediaType] !== 'object') {\n responseItem.content[mediaType] = {}\n }\n responseItem.content[mediaType].example = exampleValue\n }\n\n delete responseItem.examples\n }\n }\n }\n }\n\n delete operationItem.produces\n\n // Delete empty parameters\n if (operationItem.parameters?.length === 0) {\n delete operationItem.parameters\n }\n }\n }\n }\n }\n }\n\n // Upgrade securityDefinitions\n if (document.securityDefinitions) {\n if (typeof document.components !== 'object' || document.components === null) {\n document.components = {}\n }\n\n if (document.components && typeof document.components === 'object') {\n Object.assign(document.components, { securitySchemes: {} })\n }\n\n for (const [key, securityScheme] of Object.entries(document.securityDefinitions)) {\n if (typeof securityScheme === 'object') {\n if ('type' in securityScheme && securityScheme.type === 'oauth2') {\n const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme as {\n type: 'oauth2'\n flow?: string\n authorizationUrl?: string\n tokenUrl?: string\n scopes?: Record<string, string>\n }\n\n // Convert flow values to OpenAPI 3.1.0 format\n\n if (\n document.components &&\n typeof document.components === 'object' &&\n 'securitySchemes' in document.components &&\n document.components.securitySchemes\n ) {\n Object.assign(document.components.securitySchemes, {\n [key]: {\n type: 'oauth2',\n flows: {\n [upgradeFlow(flow || 'implicit')]: Object.assign(\n {},\n authorizationUrl && { authorizationUrl },\n tokenUrl && { tokenUrl },\n scopes && { scopes },\n ),\n },\n },\n })\n }\n } else if ('type' in securityScheme && securityScheme.type === 'basic') {\n if (\n document.components &&\n typeof document.components === 'object' &&\n 'securitySchemes' in document.components &&\n document.components.securitySchemes\n ) {\n Object.assign(document.components.securitySchemes, {\n [key]: {\n type: 'http',\n scheme: 'basic',\n },\n })\n }\n } else {\n if (\n document.components &&\n typeof document.components === 'object' &&\n 'securitySchemes' in document.components &&\n document.components.securitySchemes\n ) {\n Object.assign(document.components.securitySchemes, {\n [key]: securityScheme,\n })\n }\n }\n }\n }\n\n delete document.securityDefinitions\n }\n\n delete document.consumes\n delete document.produces\n\n return document as OpenAPIV3.Document\n}\n\nfunction transformItemsObject<T extends Record<PropertyKey, unknown>>(obj: T): OpenAPIV3.SchemaObject {\n const schemaProperties = [\n 'type',\n 'format',\n 'items',\n 'maximum',\n 'exclusiveMaximum',\n 'minimum',\n 'exclusiveMinimum',\n 'maxLength',\n 'minLength',\n 'pattern',\n 'maxItems',\n 'minItems',\n 'uniqueItems',\n 'enum',\n 'multipleOf',\n ]\n\n return schemaProperties.reduce((acc, property) => {\n if (Object.hasOwn(obj, property)) {\n acc[property] = obj[property]\n delete obj[property]\n }\n\n return acc\n }, {} as OpenAPIV3.SchemaObject)\n}\n\nfunction getParameterLocation(location: OpenAPIV2.ParameterLocation): OpenAPIV3.ParameterLocation {\n if (location === 'formData') {\n throw new Error('Encountered a formData parameter which should have been filtered out by the caller')\n }\n if (location === 'body') {\n throw new Error('Encountered a body parameter which should have been filtered out by the caller')\n }\n return location as OpenAPIV3.ParameterLocation\n}\n\nfunction transformParameterObject(\n parameter: OpenAPIV2.ParameterObject | OpenAPIV2.ReferenceObject,\n): OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject {\n if (Object.hasOwn(parameter, '$ref') && '$ref' in parameter) {\n return {\n $ref: parameter.$ref,\n }\n }\n\n // it is important to call getParameterSerializationStyle first because transformItemsObject modifies properties on which getParameterSerializationStyle rely on\n const serializationStyle = getParameterSerializationStyle(parameter)\n const schema = transformItemsObject(parameter)\n\n const { xExample, xExamples } = extractXExampleExtensions(parameter as Record<string, unknown>)\n\n // Input:\n // x-example:\n // application/json:\n // message: OK\n // type: success\n // text/plain: 'OK'\n\n // Output:\n // examples:\n // application/json:\n // value:\n // message: OK\n // type: success\n // text/plain:\n // value: 'OK'\n\n // We need to transform the x-example to an examples object and add \"value\" to the structure\n if (isNonEmptyObject(xExample)) {\n parameter.examples = transformXExampleToExamples(xExample)\n } else if (isNonEmptyObject(xExamples)) {\n parameter.examples = Object.entries(xExamples).reduce(\n (acc, [key, exampleValue]) => {\n acc[key] = wrapAsExampleObject(exampleValue)\n return acc\n },\n {} as Record<string, OpenAPIV3.ExampleObject>,\n )\n }\n\n delete parameter.collectionFormat\n delete parameter.default\n\n if (!parameter.in) {\n throw new Error('Parameter object must have an \"in\" property')\n }\n\n return {\n schema,\n ...serializationStyle,\n ...parameter,\n in: getParameterLocation(parameter.in),\n }\n}\n\n/**\n * Transform OpenAPI 2.0 response header to OpenAPI 3.0 format.\n * Response headers do not have \"in\", \"name\", \"style\", or \"explode\" properties.\n */\nfunction transformResponseHeader(\n header: OpenAPIV2.HeaderObject | OpenAPIV2.ReferenceObject,\n): OpenAPIV3.HeaderObject | OpenAPIV3.ReferenceObject {\n if (Object.hasOwn(header, '$ref') && '$ref' in header) {\n return {\n $ref: header.$ref,\n }\n }\n\n const schema = transformItemsObject(header)\n\n return {\n ...header,\n schema,\n }\n}\n\ntype CollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi'\n\ntype ParameterSerializationStyle = { style?: OpenAPIV3.ParameterStyle; explode?: boolean }\n\nconst querySerialization: Record<CollectionFormat, ParameterSerializationStyle> = {\n ssv: {\n style: 'spaceDelimited',\n explode: false,\n },\n pipes: {\n style: 'pipeDelimited',\n explode: false,\n },\n multi: {\n style: 'form',\n explode: true,\n },\n csv: {\n style: 'form',\n explode: false,\n },\n tsv: {},\n}\n\nconst pathAndHeaderSerialization: Record<CollectionFormat, ParameterSerializationStyle> = {\n ssv: {},\n pipes: {},\n multi: {},\n csv: {\n style: 'simple',\n explode: false,\n },\n tsv: {},\n}\n\nconst serializationStyles = {\n header: pathAndHeaderSerialization,\n query: querySerialization,\n path: pathAndHeaderSerialization,\n} as const\n\nfunction getParameterSerializationStyle(parameter: OpenAPIV2.ParameterObject): ParameterSerializationStyle {\n if (\n parameter.type !== 'array' ||\n !(parameter.in === 'query' || parameter.in === 'path' || parameter.in === 'header')\n ) {\n return {}\n }\n\n const collectionFormat = parameter.collectionFormat ?? 'csv'\n\n if (\n parameter.in in serializationStyles &&\n collectionFormat in serializationStyles[parameter.in as keyof typeof serializationStyles]\n ) {\n return serializationStyles[parameter.in as keyof typeof serializationStyles][collectionFormat as CollectionFormat]\n }\n\n return {}\n}\n\ntype ParameterMigrationResult = {\n parameters: (OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject)[]\n requestBody?: OpenAPIV3.RequestBodyObject\n}\n\nfunction migrateBodyParameter(\n bodyParameter: OpenAPIV2.ParameterObject,\n consumes: string[],\n): OpenAPIV3.RequestBodyObject {\n // Extract x-example and x-examples before deleting other properties\n // @see https://redocly.com/docs-legacy/api-reference-docs/specification-extensions/x-examples\n const { xExample, xExamples } = extractXExampleExtensions(bodyParameter as Record<string, unknown>)\n\n delete bodyParameter.name\n delete bodyParameter.in\n\n const { schema, ...requestBody } = bodyParameter\n\n const requestBodyObject: OpenAPIV3.RequestBodyObject = {\n content: {},\n ...requestBody,\n }\n\n if (requestBodyObject.content) {\n for (const type of consumes) {\n requestBodyObject.content[type] = {\n schema: schema,\n }\n\n // Handle x-example (singular) - Redocly extension for Swagger 2.0\n // Transforms to OpenAPI 3.x `example` field\n if (isNonEmptyObject(xExample) && type in xExample) {\n requestBodyObject.content[type].example = xExample[type]\n }\n\n // Handle x-examples (plural) - Redocly extension for Swagger 2.0\n // Transforms to OpenAPI 3.x `examples` field (named examples with summary/value)\n if (isNonEmptyObject(xExamples) && type in xExamples) {\n const examples = xExamples[type]\n\n // Check if examples is already in proper OpenAPI 3.x format (object with entries that are valid ExampleObjects)\n const isExamplesCollection =\n isNonEmptyObject(examples) && Object.values(examples).every((example) => isExampleObject(example))\n\n if (isExamplesCollection) {\n requestBodyObject.content[type].examples = examples as Record<string, OpenAPIV3.ExampleObject>\n }\n // Named examples without value wrappers - wrap each individually\n else if (isNamedExamplesCollection(examples)) {\n requestBodyObject.content[type].examples = Object.entries(examples).reduce(\n (acc, [key, exampleValue]) => {\n acc[key] = wrapAsExampleObject(exampleValue)\n return acc\n },\n {} as Record<string, OpenAPIV3.ExampleObject>,\n )\n }\n // Single example value - wrap as default\n else {\n requestBodyObject.content[type].examples = {\n default: wrapAsExampleObject(examples),\n }\n }\n }\n }\n }\n\n return requestBodyObject\n}\n\nfunction migrateFormDataParameter(\n parameters: OpenAPIV2.ParameterObject[],\n consumes: string[] | undefined = ['multipart/form-data'],\n): OpenAPIV3.RequestBodyObject {\n const requestBodyObject: OpenAPIV3.RequestBodyObject = {\n content: {},\n }\n\n // Ensure consumes contains a form data content type\n const filtered = consumes.filter(\n (type) => type === 'multipart/form-data' || type === 'application/x-www-form-urlencoded',\n )\n const contentTypes = filtered.length > 0 ? filtered : ['multipart/form-data']\n\n if (requestBodyObject.content) {\n for (const contentType of contentTypes) {\n requestBodyObject.content[contentType] = {\n schema: {\n type: 'object',\n properties: {},\n required: [], // Initialize required array\n },\n }\n\n const formContent = requestBodyObject.content?.[contentType]\n if (formContent?.schema && typeof formContent.schema === 'object' && 'properties' in formContent.schema) {\n for (const param of parameters) {\n if (param.name && formContent.schema.properties) {\n formContent.schema.properties[param.name] = {\n type: param.type,\n description: param.description,\n ...(param.format ? { format: param.format } : {}),\n }\n\n // Add to required array if param is required\n if (param.required && Array.isArray(formContent.schema.required)) {\n formContent.schema.required.push(param.name)\n }\n }\n }\n }\n }\n }\n\n return requestBodyObject\n}\n\nfunction migrateParameters(parameters: OpenAPIV2.ParameterObject[], consumes: string[]): ParameterMigrationResult {\n const result: ParameterMigrationResult = {\n parameters: parameters\n .filter((parameter) => !(parameter.in === 'body' || parameter.in === 'formData'))\n .map((parameter) => transformParameterObject(parameter)),\n }\n\n const bodyParameter = structuredClone(\n parameters.find((parameter: OpenAPIV2.ParameterObject) => parameter.in === 'body') ?? {},\n )\n\n if (bodyParameter && Object.keys(bodyParameter).length) {\n result.requestBody = migrateBodyParameter(bodyParameter, consumes)\n }\n\n const formDataParameters = parameters.filter((parameter: OpenAPIV2.ParameterObject) => parameter.in === 'formData')\n\n if (formDataParameters.length > 0) {\n const requestBodyObject = migrateFormDataParameter(formDataParameters, consumes)\n\n if (typeof result.requestBody !== 'object') {\n result.requestBody = requestBodyObject\n } else {\n result.requestBody = {\n ...result.requestBody,\n content: {\n ...result.requestBody.content,\n ...requestBodyObject.content,\n },\n }\n }\n\n if (typeof result.requestBody !== 'object') {\n result.requestBody = {\n content: {},\n }\n }\n }\n\n return result\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,gBAAgB;AAQzB,SAAS,0BAA0B,KAAkD;AACnF,QAAM,WAAW,IAAI,WAAW;AAChC,QAAM,YAAY,IAAI,YAAY;AAElC,SAAO,IAAI,WAAW;AACtB,SAAO,IAAI,YAAY;AAEvB,SAAO,EAAE,UAAU,UAAU;AAC/B;AAGA,SAAS,iBAAiB,OAAkD;AAC1E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,SAAS;AAC7G;AAQA,SAAS,0BAA0B,OAAkE;AACnG,SACE,iBAAiB,KAAK,KACtB,OAAO,OAAO,KAAK,EAAE,MAAM,CAAC,MAAM,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC,CAAC;AAE9F;AAGA,MAAM,4BAA4B,oBAAI,IAAI,CAAC,WAAW,eAAe,SAAS,eAAe,CAAC;AAW9F,SAAS,gBAAgB,OAAkD;AACzE,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,MAAM;AACZ,QAAM,0BAA0B,WAAW,OAAO,mBAAmB;AACrE,QAAM,2BAA2B,OAAO,KAAK,GAAG,EAAE,MAAM,CAAC,QAAQ,0BAA0B,IAAI,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,OAAO,WAAW,EAC/E,IAAI,CAAC,cAAc,yBAAyB,SAAS,CAAC;AAAA,EAC3D;AAEA,QAAM,gBAAgB;AAAA,IACpB,WAAW,KAAK,CAAC,cAAyC,UAAU,OAAO,MAAM,KAAK,CAAC;AAAA,EACzF;AAEA,MAAI,iBAAiB,OAAO,KAAK,aAAa,EAAE,QAAQ;AACtD,WAAO,cAAc,qBAAqB,eAAe,QAAQ;AAAA,EACnE;AAEA,QAAM,qBAAqB,WAAW,OAAO,CAAC,cAAyC,UAAU,OAAO,UAAU;AAElH,MAAI,mBAAmB,SAAS,GAAG;AACjC,UAAM,oBAAoB,yBAAyB,oBAAoB,QAAQ;AAE/E,QAAI,OAAO,OAAO,gBAAgB,UAAU;AAC1C,aAAO,cAAc;AAAA,IACvB,OAAO;AACL,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAG,OAAO,YAAY;AAAA,UACtB,GAAG,kBAAkB;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,gBAAgB,UAAU;AAC1C,aAAO,cAAc;AAAA,QACnB,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/upgrade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../src/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../src/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAOxD;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAA;AACvF,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAA;AACzF,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAA"}
|
package/dist/upgrade.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/upgrade.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from '@scalar/openapi-types'\n\nimport { upgradeFromThreeOneToThreeTwo } from '@/3.1-to-3.2'\n\nimport { upgradeFromTwoToThree } from './2.0-to-3.0'\nimport { upgradeFromThreeToThreeOne } from './3.0-to-3.1'\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from '@scalar/openapi-types'\nimport type { UnknownObject } from '@scalar/types/utils'\n\nimport { upgradeFromThreeOneToThreeTwo } from '@/3.1-to-3.2'\n\nimport { upgradeFromTwoToThree } from './2.0-to-3.0'\nimport { upgradeFromThreeToThreeOne } from './3.0-to-3.1'\n\n/**\n * Upgrade OpenAPI documents from Swagger 2.0 or OpenAPI 3.0 to the specified target version\n */\nexport function upgrade(value: UnknownObject, targetVersion: '3.0'): OpenAPIV3.Document\nexport function upgrade(value: UnknownObject, targetVersion: '3.1'): OpenAPIV3_1.Document\nexport function upgrade(value: UnknownObject, targetVersion: '3.2'): OpenAPIV3_2.Document\nexport function upgrade(\n value: UnknownObject,\n targetVersion: '3.0' | '3.1' | '3.2',\n): OpenAPIV3.Document | OpenAPIV3_1.Document | OpenAPIV3_2.Document {\n // Swagger 2.0 -> OpenAPI 3.0\n const openapi30 = upgradeFromTwoToThree(value)\n if (targetVersion === '3.0') {\n return openapi30 as OpenAPIV3.Document\n }\n\n // OpenAPI 3.0 -> OpenAPI 3.1\n const openapi31 = upgradeFromThreeToThreeOne(openapi30)\n if (targetVersion === '3.1') {\n return openapi31 as OpenAPIV3_1.Document\n }\n\n // OpenAPI 3.1 -> OpenAPI 3.2\n const openapi32 = upgradeFromThreeOneToThreeTwo(openapi31)\n if (targetVersion === '3.2') {\n return openapi32 as OpenAPIV3_2.Document\n }\n\n return openapi32\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,qCAAqC;AAE9C,SAAS,6BAA6B;AACtC,SAAS,kCAAkC;AAQpC,SAAS,QACd,OACA,eACkE;AAElE,QAAM,YAAY,sBAAsB,KAAK;AAC7C,MAAI,kBAAkB,OAAO;AAC3B,WAAO;AAAA,EACT;AAGA,QAAM,YAAY,2BAA2B,SAAS;AACtD,MAAI,kBAAkB,OAAO;AAC3B,WAAO;AAAA,EACT;AAGA,QAAM,YAAY,8BAA8B,SAAS;AACzD,MAAI,kBAAkB,OAAO;AAC3B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"openapi 3.0",
|
|
21
21
|
"openapi 3.1"
|
|
22
22
|
],
|
|
23
|
-
"version": "0.1.
|
|
23
|
+
"version": "0.1.8",
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=20"
|
|
26
26
|
},
|
|
@@ -54,15 +54,29 @@
|
|
|
54
54
|
"dist",
|
|
55
55
|
"CHANGELOG.md"
|
|
56
56
|
],
|
|
57
|
+
"readme": {
|
|
58
|
+
"title": "Scalar OpenAPI Upgrader",
|
|
59
|
+
"badges": [
|
|
60
|
+
{
|
|
61
|
+
"type": "npm-version"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "npm-downloads"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "npm-license"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"documentation": "https://scalar.com/tools/openapi-upgrader/getting-started"
|
|
71
|
+
},
|
|
57
72
|
"sideEffects": false,
|
|
58
73
|
"dependencies": {
|
|
59
74
|
"@scalar/openapi-types": "0.5.3"
|
|
60
75
|
},
|
|
61
76
|
"devDependencies": {
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"@scalar/
|
|
65
|
-
"@scalar/types": "0.5.2"
|
|
77
|
+
"vite": "^7.3.1",
|
|
78
|
+
"@scalar/build-tooling": "0.4.1",
|
|
79
|
+
"@scalar/types": "0.5.8"
|
|
66
80
|
},
|
|
67
81
|
"scripts": {
|
|
68
82
|
"build": "scalar-build-esbuild",
|