@asyncapi/cli 0.41.0 → 0.43.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/README.md +1 -0
- package/lib/commands/generate/models.d.ts +4 -1
- package/lib/commands/generate/models.js +43 -10
- package/oclif.manifest.json +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc
|
|
|
77
77
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/CyberHippo"><img src="https://avatars.githubusercontent.com/u/18269437?v=4?s=100" width="100px;" alt="Hippolyte Vergnol"/><br /><sub><b>Hippolyte Vergnol</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=CyberHippo" title="Code">💻</a> <a href="#infra-CyberHippo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
78
78
|
<td align="center" valign="top" width="14.28%"><a href="https://www.jentevets.com"><img src="https://avatars.githubusercontent.com/u/22449126?v=4?s=100" width="100px;" alt="Jente Vets"/><br /><sub><b>Jente Vets</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=Vetsoo" title="Code">💻</a></td>
|
|
79
79
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kaushik-rishi"><img src="https://avatars.githubusercontent.com/u/52498617?v=4?s=100" width="100px;" alt="Rishi"/><br /><sub><b>Rishi</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=kaushik-rishi" title="Code">💻</a></td>
|
|
80
|
+
<td align="center" valign="top" width="14.28%"><a href="http://ashishpadhy.live"><img src="https://avatars.githubusercontent.com/u/100484401?v=4?s=100" width="100px;" alt="Ashish Padhy"/><br /><sub><b>Ashish Padhy</b></sub></a><br /><a href="https://github.com/asyncapi/cli/commits?author=Shurtu-gal" title="Code">💻</a></td>
|
|
80
81
|
</tr>
|
|
81
82
|
</tbody>
|
|
82
83
|
</table>
|
|
@@ -32,14 +32,17 @@ export default class Models extends Command {
|
|
|
32
32
|
*/
|
|
33
33
|
packageName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
34
34
|
/**
|
|
35
|
-
* C++ and C# specific namespace to use for the generated models
|
|
35
|
+
* C++ and C# and PHP specific namespace to use for the generated models
|
|
36
36
|
*/
|
|
37
37
|
namespace: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
38
38
|
/**
|
|
39
39
|
* C# specific options
|
|
40
40
|
*/
|
|
41
41
|
csharpAutoImplement: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
42
|
+
csharpNewtonsoft: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
42
43
|
csharpArrayType: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
44
|
+
csharpHashcode: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
45
|
+
csharpEqual: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
43
46
|
};
|
|
44
47
|
run(): Promise<void>;
|
|
45
48
|
}
|
|
@@ -26,7 +26,7 @@ class Models extends base_1.default {
|
|
|
26
26
|
run() {
|
|
27
27
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
const { args, flags } = yield this.parse(Models);
|
|
29
|
-
const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, packageName, output } = flags;
|
|
29
|
+
const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, packageName, output } = flags;
|
|
30
30
|
const { language, file } = args;
|
|
31
31
|
const inputFile = (yield (0, SpecificationFile_1.load)(file)) || (yield (0, SpecificationFile_1.load)());
|
|
32
32
|
const { document, status } = yield (0, parser_1.parse)(this, inputFile, flags);
|
|
@@ -83,15 +83,36 @@ class Models extends base_1.default {
|
|
|
83
83
|
if (namespace === undefined) {
|
|
84
84
|
throw new Error('In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.');
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
presets
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
if (csharpAutoImplement) {
|
|
87
|
+
presets.push({
|
|
88
|
+
preset: modelina_1.CSHARP_DEFAULT_PRESET,
|
|
89
|
+
options: {
|
|
90
|
+
autoImplementedProperties: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (csharpNewtonsoft) {
|
|
95
|
+
presets.push(modelina_1.CSHARP_NEWTONSOFT_SERIALIZER_PRESET);
|
|
96
|
+
}
|
|
97
|
+
if (csharpAutoImplement) {
|
|
98
|
+
presets.push({
|
|
99
|
+
preset: modelina_1.CSHARP_DEFAULT_PRESET,
|
|
100
|
+
options: {
|
|
101
|
+
autoImplementedProperties: true
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (csharpHashcode || csharpEqual) {
|
|
106
|
+
presets.push({
|
|
107
|
+
preset: modelina_1.CSHARP_COMMON_PRESET,
|
|
108
|
+
options: {
|
|
109
|
+
hashCode: csharpHashcode,
|
|
110
|
+
equals: csharpEqual
|
|
93
111
|
}
|
|
94
|
-
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
fileGenerator = new modelina_1.CSharpFileGenerator({
|
|
115
|
+
presets,
|
|
95
116
|
collectionType: csharpArrayType
|
|
96
117
|
});
|
|
97
118
|
fileOptions = {
|
|
@@ -234,7 +255,7 @@ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: c
|
|
|
234
255
|
required: false
|
|
235
256
|
}),
|
|
236
257
|
/**
|
|
237
|
-
* C++ and C# specific namespace to use for the generated models
|
|
258
|
+
* C++ and C# and PHP specific namespace to use for the generated models
|
|
238
259
|
*/
|
|
239
260
|
namespace: core_1.Flags.string({
|
|
240
261
|
description: 'C#, C++ and PHP specific, define the namespace to use for the generated models. This is required when language is `csharp`,`c++` or `php`.',
|
|
@@ -247,10 +268,22 @@ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: c
|
|
|
247
268
|
description: 'C# specific, define whether to generate auto-implemented properties or not.',
|
|
248
269
|
required: false,
|
|
249
270
|
default: false
|
|
271
|
+
}), csharpNewtonsoft: core_1.Flags.boolean({
|
|
272
|
+
description: 'C# specific, generate the models with newtonsoft serialization support',
|
|
273
|
+
required: false,
|
|
274
|
+
default: false
|
|
250
275
|
}), csharpArrayType: core_1.Flags.string({
|
|
251
276
|
type: 'option',
|
|
252
277
|
description: 'C# specific, define which type of array needs to be generated.',
|
|
253
278
|
options: ['Array', 'List'],
|
|
254
279
|
required: false,
|
|
255
280
|
default: 'Array'
|
|
281
|
+
}), csharpHashcode: core_1.Flags.boolean({
|
|
282
|
+
description: 'C# specific, generate the models with the GetHashCode method overwritten',
|
|
283
|
+
required: false,
|
|
284
|
+
default: false
|
|
285
|
+
}), csharpEqual: core_1.Flags.boolean({
|
|
286
|
+
description: 'C# specific, generate the models with the Equal method overwritten',
|
|
287
|
+
required: false,
|
|
288
|
+
default: false
|
|
256
289
|
}) }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.43.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"bundle": {
|
|
5
5
|
"id": "bundle",
|
|
@@ -553,6 +553,13 @@
|
|
|
553
553
|
"required": false,
|
|
554
554
|
"allowNo": false
|
|
555
555
|
},
|
|
556
|
+
"csharpNewtonsoft": {
|
|
557
|
+
"name": "csharpNewtonsoft",
|
|
558
|
+
"type": "boolean",
|
|
559
|
+
"description": "C# specific, generate the models with newtonsoft serialization support",
|
|
560
|
+
"required": false,
|
|
561
|
+
"allowNo": false
|
|
562
|
+
},
|
|
556
563
|
"csharpArrayType": {
|
|
557
564
|
"name": "csharpArrayType",
|
|
558
565
|
"type": "option",
|
|
@@ -565,6 +572,20 @@
|
|
|
565
572
|
],
|
|
566
573
|
"default": "Array"
|
|
567
574
|
},
|
|
575
|
+
"csharpHashcode": {
|
|
576
|
+
"name": "csharpHashcode",
|
|
577
|
+
"type": "boolean",
|
|
578
|
+
"description": "C# specific, generate the models with the GetHashCode method overwritten",
|
|
579
|
+
"required": false,
|
|
580
|
+
"allowNo": false
|
|
581
|
+
},
|
|
582
|
+
"csharpEqual": {
|
|
583
|
+
"name": "csharpEqual",
|
|
584
|
+
"type": "boolean",
|
|
585
|
+
"description": "C# specific, generate the models with the Equal method overwritten",
|
|
586
|
+
"required": false,
|
|
587
|
+
"allowNo": false
|
|
588
|
+
},
|
|
568
589
|
"log-diagnostics": {
|
|
569
590
|
"name": "log-diagnostics",
|
|
570
591
|
"type": "boolean",
|