@skmtc/core 0.0.651 → 0.0.653
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.
|
@@ -12,8 +12,8 @@ export const stringToSchema = (schema) => {
|
|
|
12
12
|
};
|
|
13
13
|
export const toV3Document = async (schema) => {
|
|
14
14
|
return await match(schema)
|
|
15
|
-
.with({ openapi: P.string.startsWith('3.0
|
|
16
|
-
.with({ openapi: P.string.startsWith('3.1
|
|
15
|
+
.with({ openapi: P.string.startsWith('3.0') }, doc => doc)
|
|
16
|
+
.with({ openapi: P.string.startsWith('3.1') }, doc => {
|
|
17
17
|
const options = {
|
|
18
18
|
verbose: false,
|
|
19
19
|
deleteExampleWithId: false,
|
|
@@ -22,9 +22,9 @@ export const toV3Document = async (schema) => {
|
|
|
22
22
|
const converter = new ThreeOneToThreeZeroConverter(doc, options);
|
|
23
23
|
return converter.convert();
|
|
24
24
|
})
|
|
25
|
-
.with({ swagger: '2.0
|
|
25
|
+
.with({ swagger: P.string.startsWith('2.0') }, async (doc) => {
|
|
26
26
|
const parsed = await converter.convertObj(doc, {});
|
|
27
|
-
return parsed;
|
|
27
|
+
return parsed.openapi;
|
|
28
28
|
})
|
|
29
29
|
.otherwise(() => {
|
|
30
30
|
console.log('Unrecognized OpenAPI version', JSON.stringify(schema, null, 2).substring(0, 1000));
|
package/package.json
CHANGED
|
@@ -19,8 +19,8 @@ const stringToSchema = (schema) => {
|
|
|
19
19
|
exports.stringToSchema = stringToSchema;
|
|
20
20
|
const toV3Document = async (schema) => {
|
|
21
21
|
return await (0, ts_pattern_1.match)(schema)
|
|
22
|
-
.with({ openapi: ts_pattern_1.P.string.startsWith('3.0
|
|
23
|
-
.with({ openapi: ts_pattern_1.P.string.startsWith('3.1
|
|
22
|
+
.with({ openapi: ts_pattern_1.P.string.startsWith('3.0') }, doc => doc)
|
|
23
|
+
.with({ openapi: ts_pattern_1.P.string.startsWith('3.1') }, doc => {
|
|
24
24
|
const options = {
|
|
25
25
|
verbose: false,
|
|
26
26
|
deleteExampleWithId: false,
|
|
@@ -29,9 +29,9 @@ const toV3Document = async (schema) => {
|
|
|
29
29
|
const converter = new openapi_down_convert_1.Converter(doc, options);
|
|
30
30
|
return converter.convert();
|
|
31
31
|
})
|
|
32
|
-
.with({ swagger: '2.0
|
|
32
|
+
.with({ swagger: ts_pattern_1.P.string.startsWith('2.0') }, async (doc) => {
|
|
33
33
|
const parsed = await swagger2openapi_1.default.convertObj(doc, {});
|
|
34
|
-
return parsed;
|
|
34
|
+
return parsed.openapi;
|
|
35
35
|
})
|
|
36
36
|
.otherwise(() => {
|
|
37
37
|
console.log('Unrecognized OpenAPI version', JSON.stringify(schema, null, 2).substring(0, 1000));
|