@scalar/openapi-upgrader 0.4.5 → 0.4.6
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,11 @@
|
|
|
1
1
|
# @scalar/openapi-upgrader
|
|
2
2
|
|
|
3
|
+
## 0.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#10701](https://github.com/scalar/scalar/pull/10701): Preserve descriptions and specification extensions on OAuth2 and Basic security schemes, and preserve extensions on form-data fields when upgrading OpenAPI 2.0 API descriptions.
|
|
8
|
+
|
|
3
9
|
## 0.4.5
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -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":"AACA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAgMxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,
|
|
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":"AACA,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAgMxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,qBAAqB,EAAE,aAAa,0CAwczE"}
|
|
@@ -476,6 +476,7 @@ export function upgradeFromTwoToThree(originalSpecification) {
|
|
|
476
476
|
}
|
|
477
477
|
for (const [key, securityScheme] of Object.entries(document.securityDefinitions)) {
|
|
478
478
|
if (typeof securityScheme === 'object') {
|
|
479
|
+
const metadata = Object.fromEntries(Object.entries(securityScheme).filter(([key]) => key === 'description' || key.startsWith('x-')));
|
|
479
480
|
if ('type' in securityScheme && securityScheme.type === 'oauth2') {
|
|
480
481
|
const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme;
|
|
481
482
|
// Convert flow values to OpenAPI 3.1.0 format
|
|
@@ -485,6 +486,7 @@ export function upgradeFromTwoToThree(originalSpecification) {
|
|
|
485
486
|
document.components.securitySchemes) {
|
|
486
487
|
Object.assign(document.components.securitySchemes, {
|
|
487
488
|
[key]: {
|
|
489
|
+
...metadata,
|
|
488
490
|
type: 'oauth2',
|
|
489
491
|
flows: {
|
|
490
492
|
[upgradeFlow(flow || 'implicit')]: Object.assign({}, authorizationUrl && { authorizationUrl }, tokenUrl && { tokenUrl }, scopes && { scopes }),
|
|
@@ -500,6 +502,7 @@ export function upgradeFromTwoToThree(originalSpecification) {
|
|
|
500
502
|
document.components.securitySchemes) {
|
|
501
503
|
Object.assign(document.components.securitySchemes, {
|
|
502
504
|
[key]: {
|
|
505
|
+
...metadata,
|
|
503
506
|
type: 'http',
|
|
504
507
|
scheme: 'basic',
|
|
505
508
|
},
|
|
@@ -798,8 +801,12 @@ function migrateFormDataParameter(parameters, consumes = ['multipart/form-data']
|
|
|
798
801
|
if (formContent?.schema && typeof formContent.schema === 'object' && 'properties' in formContent.schema) {
|
|
799
802
|
for (const param of parameters) {
|
|
800
803
|
if (param.name && formContent.schema.properties) {
|
|
804
|
+
const remainingProperties = structuredClone(param);
|
|
805
|
+
const schema = transformItemsObject(remainingProperties);
|
|
801
806
|
formContent.schema.properties[param.name] = {
|
|
802
|
-
...
|
|
807
|
+
...schema,
|
|
808
|
+
// Keep field extensions after consuming recognized schema keywords such as x-nullable.
|
|
809
|
+
...Object.fromEntries(Object.entries(remainingProperties).filter(([key]) => key.startsWith('x-'))),
|
|
803
810
|
// Only carry the description over when it exists, so a parameter without one does not
|
|
804
811
|
// end up with an explicit `description: undefined` on its schema.
|
|
805
812
|
...(param.description !== undefined ? { description: param.description } : {}),
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"openapi 3.0",
|
|
21
21
|
"openapi 3.1"
|
|
22
22
|
],
|
|
23
|
-
"version": "0.4.
|
|
23
|
+
"version": "0.4.6",
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=22"
|
|
26
26
|
},
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"@scalar/openapi-types": "0.9.8"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@scalar/types": "0.
|
|
79
|
-
"vite": "8.
|
|
78
|
+
"@scalar/types": "0.25.0",
|
|
79
|
+
"vite": "8.3.4"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|