@asyncapi/cli 2.3.13 → 2.4.1
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.
|
@@ -4,7 +4,9 @@ export default class Convert extends Command {
|
|
|
4
4
|
static flags: {
|
|
5
5
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
6
6
|
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
format: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
8
|
'target-version': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
perspective: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
10
|
};
|
|
9
11
|
static args: {
|
|
10
12
|
'spec-file': import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
package/lib/commands/convert.js
CHANGED
|
@@ -27,9 +27,19 @@ class Convert extends base_1.default {
|
|
|
27
27
|
this.specFile = yield (0, SpecificationFile_1.load)(filePath);
|
|
28
28
|
// eslint-disable-next-line sonarjs/no-duplicate-string
|
|
29
29
|
this.metricsMetadata.to_version = flags['target-version'];
|
|
30
|
+
// Determine if the input is OpenAPI or AsyncAPI
|
|
31
|
+
const specJson = this.specFile.toJson();
|
|
32
|
+
const isOpenAPI = flags['format'] === 'openapi';
|
|
33
|
+
const isAsyncAPI = flags['format'] === 'asyncapi';
|
|
30
34
|
// CONVERSION
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
if (isOpenAPI) {
|
|
36
|
+
convertedFile = (0, converter_1.convertOpenAPI)(this.specFile.text(), specJson.openapi, {
|
|
37
|
+
perspective: flags['perspective']
|
|
38
|
+
});
|
|
39
|
+
this.log(`🎉 The OpenAPI document has been successfully converted to AsyncAPI version ${(0, picocolors_1.green)(flags['target-version'])}!`);
|
|
40
|
+
}
|
|
41
|
+
else if (isAsyncAPI) {
|
|
42
|
+
convertedFile = (0, converter_1.convert)(this.specFile.text(), flags['target-version']);
|
|
33
43
|
if (this.specFile.getFilePath()) {
|
|
34
44
|
this.log(`🎉 The ${(0, picocolors_1.cyan)(this.specFile.getFilePath())} file has been successfully converted to version ${(0, picocolors_1.green)(flags['target-version'])}!!`);
|
|
35
45
|
}
|
|
@@ -68,7 +78,7 @@ class Convert extends base_1.default {
|
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
exports.default = Convert;
|
|
71
|
-
Convert.description = 'Convert asyncapi documents older to newer versions';
|
|
81
|
+
Convert.description = 'Convert asyncapi documents older to newer versions or OpenAPI documents to AsyncAPI';
|
|
72
82
|
Convert.flags = (0, convert_flags_1.convertFlags)(latestVersion);
|
|
73
83
|
Convert.args = {
|
|
74
84
|
'spec-file': core_1.Args.string({ description: 'spec path, url, or context-name', required: false }),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const convertFlags: (latestVersion: string) => {
|
|
2
2
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
3
3
|
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
4
|
+
format: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
4
5
|
'target-version': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
perspective: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
5
7
|
};
|
|
@@ -6,7 +6,20 @@ const convertFlags = (latestVersion) => {
|
|
|
6
6
|
return {
|
|
7
7
|
help: core_1.Flags.help({ char: 'h' }),
|
|
8
8
|
output: core_1.Flags.string({ char: 'o', description: 'path to the file where the result is saved' }),
|
|
9
|
-
|
|
9
|
+
format: core_1.Flags.string({
|
|
10
|
+
char: 'f',
|
|
11
|
+
description: 'Specify the format to convert from (openapi or asyncapi)',
|
|
12
|
+
options: ['openapi', 'asyncapi'],
|
|
13
|
+
required: true,
|
|
14
|
+
default: 'asyncapi',
|
|
15
|
+
}),
|
|
16
|
+
'target-version': core_1.Flags.string({ char: 't', description: 'asyncapi version to convert to', default: latestVersion }),
|
|
17
|
+
perspective: core_1.Flags.string({
|
|
18
|
+
char: 'p',
|
|
19
|
+
description: 'Perspective to use when converting OpenAPI to AsyncAPI (client or server). Note: This option is only applicable for OpenAPI to AsyncAPI conversions.',
|
|
20
|
+
options: ['client', 'server'],
|
|
21
|
+
default: 'server',
|
|
22
|
+
}),
|
|
10
23
|
};
|
|
11
24
|
};
|
|
12
25
|
exports.convertFlags = convertFlags;
|
package/oclif.manifest.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"required": false
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
-
"description": "Convert asyncapi documents older to newer versions",
|
|
78
|
+
"description": "Convert asyncapi documents older to newer versions or OpenAPI documents to AsyncAPI",
|
|
79
79
|
"flags": {
|
|
80
80
|
"help": {
|
|
81
81
|
"char": "h",
|
|
@@ -92,6 +92,20 @@
|
|
|
92
92
|
"multiple": false,
|
|
93
93
|
"type": "option"
|
|
94
94
|
},
|
|
95
|
+
"format": {
|
|
96
|
+
"char": "f",
|
|
97
|
+
"description": "Specify the format to convert from (openapi or asyncapi)",
|
|
98
|
+
"name": "format",
|
|
99
|
+
"required": true,
|
|
100
|
+
"default": "asyncapi",
|
|
101
|
+
"hasDynamicHelp": false,
|
|
102
|
+
"multiple": false,
|
|
103
|
+
"options": [
|
|
104
|
+
"openapi",
|
|
105
|
+
"asyncapi"
|
|
106
|
+
],
|
|
107
|
+
"type": "option"
|
|
108
|
+
},
|
|
95
109
|
"target-version": {
|
|
96
110
|
"char": "t",
|
|
97
111
|
"description": "asyncapi version to convert to",
|
|
@@ -100,6 +114,19 @@
|
|
|
100
114
|
"hasDynamicHelp": false,
|
|
101
115
|
"multiple": false,
|
|
102
116
|
"type": "option"
|
|
117
|
+
},
|
|
118
|
+
"perspective": {
|
|
119
|
+
"char": "p",
|
|
120
|
+
"description": "Perspective to use when converting OpenAPI to AsyncAPI (client or server). Note: This option is only applicable for OpenAPI to AsyncAPI conversions.",
|
|
121
|
+
"name": "perspective",
|
|
122
|
+
"default": "server",
|
|
123
|
+
"hasDynamicHelp": false,
|
|
124
|
+
"multiple": false,
|
|
125
|
+
"options": [
|
|
126
|
+
"client",
|
|
127
|
+
"server"
|
|
128
|
+
],
|
|
129
|
+
"type": "option"
|
|
103
130
|
}
|
|
104
131
|
},
|
|
105
132
|
"hasDynamicHelp": false,
|
|
@@ -1587,5 +1614,5 @@
|
|
|
1587
1614
|
]
|
|
1588
1615
|
}
|
|
1589
1616
|
},
|
|
1590
|
-
"version": "2.
|
|
1617
|
+
"version": "2.4.1"
|
|
1591
1618
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asyncapi/cli",
|
|
3
3
|
"description": "All in one CLI for all AsyncAPI tools",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.1",
|
|
5
5
|
"author": "@asyncapi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"asyncapi": "./bin/run_bin"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@asyncapi/avro-schema-parser": "^3.0.23",
|
|
12
12
|
"@asyncapi/bundler": "^0.6.3",
|
|
13
|
-
"@asyncapi/converter": "^1.6.
|
|
13
|
+
"@asyncapi/converter": "^1.6.2",
|
|
14
14
|
"@asyncapi/diff": "^0.4.1",
|
|
15
15
|
"@asyncapi/generator": "^1.17.25",
|
|
16
16
|
"@asyncapi/modelina": "^3.7.0",
|