@scalar/openapi-upgrader 0.3.1 → 0.4.0
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 +6 -0
- package/dist/3.1-to-3.2/migrate-objects.d.ts +2 -2
- package/dist/3.1-to-3.2/migrate-objects.d.ts.map +1 -1
- package/dist/3.1-to-3.2/migrate-objects.js +3 -3
- package/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.d.ts +1 -1
- package/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.d.ts.map +1 -1
- package/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +2 -2
- package/dist/upgrade.d.ts +4 -3
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scalar/openapi-upgrader
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#10346](https://github.com/scalar/scalar/pull/10346): Add `onIncompatible: 'ignore'` for best-effort OpenAPI 3.2 upgrades. Apply available migrations and return the document despite compatibility issues, without mutating the input. Strict mode remains the default; malformed versions and clone errors still throw.
|
|
8
|
+
|
|
3
9
|
## 0.3.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { UnknownObject } from '@scalar/types/utils';
|
|
2
|
-
/**
|
|
3
|
-
export declare const migrateObjects: (document: UnknownObject) => Set<string>;
|
|
2
|
+
/** Apply migrations, optionally tolerating incompatibilities established within this document. */
|
|
3
|
+
export declare const migrateObjects: (document: UnknownObject, onIncompatible?: "throw" | "ignore") => Set<string>;
|
|
4
4
|
//# sourceMappingURL=migrate-objects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-objects.d.ts","sourceRoot":"","sources":["../../src/3.1-to-3.2/migrate-objects.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AA2CxD,
|
|
1
|
+
{"version":3,"file":"migrate-objects.d.ts","sourceRoot":"","sources":["../../src/3.1-to-3.2/migrate-objects.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AA2CxD,kGAAkG;AAClG,eAAO,MAAM,cAAc,GAAI,UAAU,aAAa,EAAE,iBAAgB,OAAO,GAAG,QAAkB,KAAG,GAAG,CAAC,MAAM,CAmahH,CAAA"}
|
|
@@ -17,8 +17,8 @@ const schemaSingles = [
|
|
|
17
17
|
'else',
|
|
18
18
|
'contentSchema',
|
|
19
19
|
];
|
|
20
|
-
/**
|
|
21
|
-
export const migrateObjects = (document) => {
|
|
20
|
+
/** Apply migrations, optionally tolerating incompatibilities established within this document. */
|
|
21
|
+
export const migrateObjects = (document, onIncompatible = 'throw') => {
|
|
22
22
|
// A cloned JSON object still inherits Object.prototype. Keep traversal in own
|
|
23
23
|
// data properties, including when the host already has polluted prototypes.
|
|
24
24
|
// Maps also allow literal __proto__ and constructor reference segments safely.
|
|
@@ -404,7 +404,7 @@ export const migrateObjects = (document) => {
|
|
|
404
404
|
for (const { schema, path, dialect } of xmlRoots) {
|
|
405
405
|
validateXmlNames(schema, path, { inferredName: false, propertyName: false, dialect });
|
|
406
406
|
}
|
|
407
|
-
if (errors.length > 0) {
|
|
407
|
+
if (errors.length > 0 && onIncompatible === 'throw') {
|
|
408
408
|
throw new UpgradeIncompatibilityError(errors);
|
|
409
409
|
}
|
|
410
410
|
return operationTags;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UnknownObject } from '@scalar/types/utils';
|
|
2
2
|
/** Apply the final migration to a document already owned by the upgrade pipeline. */
|
|
3
|
-
export declare const migrateThreeOneToThreeTwo: (document: UnknownObject) => UnknownObject;
|
|
3
|
+
export declare const migrateThreeOneToThreeTwo: (document: UnknownObject, onIncompatible?: "throw" | "ignore") => UnknownObject;
|
|
4
4
|
/**
|
|
5
5
|
* Upgrade OpenAPI 3.1.x to 3.2 without changing the input.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-from-three-one-to-three-two.d.ts","sourceRoot":"","sources":["../../src/3.1-to-3.2/upgrade-from-three-one-to-three-two.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAsBxD,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"upgrade-from-three-one-to-three-two.d.ts","sourceRoot":"","sources":["../../src/3.1-to-3.2/upgrade-from-three-one-to-three-two.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAsBxD,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,GACpC,UAAU,aAAa,EACvB,iBAAgB,OAAO,GAAG,QAAkB,KAC3C,aAQF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GAAI,kBAAkB,aAAa,KAAG,aAK/E,CAAA"}
|
|
@@ -16,11 +16,11 @@ const isThreeOneDocument = (document) => {
|
|
|
16
16
|
return false;
|
|
17
17
|
};
|
|
18
18
|
/** Apply the final migration to a document already owned by the upgrade pipeline. */
|
|
19
|
-
export const migrateThreeOneToThreeTwo = (document) => {
|
|
19
|
+
export const migrateThreeOneToThreeTwo = (document, onIncompatible = 'throw') => {
|
|
20
20
|
if (!isThreeOneDocument(document)) {
|
|
21
21
|
return document;
|
|
22
22
|
}
|
|
23
|
-
const operationTags = migrateObjects(document);
|
|
23
|
+
const operationTags = migrateObjects(document, onIncompatible);
|
|
24
24
|
migrateTagGroups(document, operationTags);
|
|
25
25
|
document.openapi = '3.2.0';
|
|
26
26
|
return document;
|
package/dist/upgrade.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from '@scalar/openapi-types'
|
|
|
2
2
|
import type { UnknownObject } from '@scalar/types/utils';
|
|
3
3
|
/** Control how compatibility issues in the OpenAPI 3.2 migration are reported. */
|
|
4
4
|
export type UpgradeOptions = {
|
|
5
|
-
/** Defaults to throwing. Collect
|
|
6
|
-
onIncompatible: 'throw' | 'collect';
|
|
5
|
+
/** Defaults to throwing. Collect retains 3.1; ignore applies best-effort migrations despite incompatibilities. */
|
|
6
|
+
onIncompatible: 'throw' | 'collect' | 'ignore';
|
|
7
7
|
};
|
|
8
8
|
/** A complete document and the compatibility issues that prevented upgrading it to OpenAPI 3.2. */
|
|
9
9
|
export type UpgradeResult = {
|
|
@@ -16,11 +16,12 @@ export type UpgradeResult = {
|
|
|
16
16
|
* Upgrade a Swagger 2.0 or OpenAPI description to the specified target version.
|
|
17
17
|
* Targeting 3.2 is strict by default. Collect mode returns compatibility diagnostics
|
|
18
18
|
* with a complete 3.1 fallback instead of throwing for migration incompatibilities.
|
|
19
|
+
* Ignore mode returns a best-effort 3.2 document that may change meaning or be invalid.
|
|
19
20
|
*/
|
|
20
21
|
export declare function upgrade(value: UnknownObject, targetVersion: '3.0'): OpenAPIV3.Document;
|
|
21
22
|
export declare function upgrade(value: UnknownObject, targetVersion: '3.1'): OpenAPIV3_1.Document;
|
|
22
23
|
export declare function upgrade(value: UnknownObject, targetVersion: '3.2', options?: {
|
|
23
|
-
onIncompatible: 'throw';
|
|
24
|
+
onIncompatible: 'throw' | 'ignore';
|
|
24
25
|
}): OpenAPIV3_2.Document;
|
|
25
26
|
export declare function upgrade(value: UnknownObject, targetVersion: '3.2', options: {
|
|
26
27
|
onIncompatible: 'collect';
|
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,EAA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AA;AAChB,wBAAgB,OAAO,CACrB,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,KAAK,EACpB,OAAO,EAAE,cAAc,GACtB,WAAW,CAAC,QAAQ,GAAG,aAAa,CAAA"}
|
package/dist/upgrade.js
CHANGED
|
@@ -10,7 +10,7 @@ export function upgrade(value, targetVersion, options) {
|
|
|
10
10
|
const openapi30 = upgradeFromTwoToThree(input);
|
|
11
11
|
const openapi31 = upgradeFromThreeToThreeOne(openapi30);
|
|
12
12
|
try {
|
|
13
|
-
const document = migrateThreeOneToThreeTwo(openapi31);
|
|
13
|
+
const document = migrateThreeOneToThreeTwo(openapi31, options?.onIncompatible === 'ignore' ? 'ignore' : 'throw');
|
|
14
14
|
return options?.onIncompatible === 'collect' ? { document, diagnostics: [] } : document;
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"openapi 3.0",
|
|
21
21
|
"openapi 3.1"
|
|
22
22
|
],
|
|
23
|
-
"version": "0.
|
|
23
|
+
"version": "0.4.0",
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=22"
|
|
26
26
|
},
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false,
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@scalar/helpers": "0.
|
|
74
|
+
"@scalar/helpers": "0.15.0",
|
|
75
75
|
"@scalar/openapi-types": "0.9.7"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@scalar/types": "0.22.
|
|
78
|
+
"@scalar/types": "0.22.1",
|
|
79
79
|
"vite": "8.1.5"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|