@asyncapi/cli 0.41.0 → 0.42.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 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,7 +32,7 @@ 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
  /**
@@ -40,6 +40,8 @@ export default class Models extends Command {
40
40
  */
41
41
  csharpAutoImplement: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
42
42
  csharpArrayType: import("@oclif/core/lib/interfaces").OptionFlag<string>;
43
+ csharpHashcode: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
44
+ csharpEqual: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
43
45
  };
44
46
  run(): Promise<void>;
45
47
  }
@@ -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, 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,25 @@ 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
- fileGenerator = new modelina_1.CSharpFileGenerator({
87
- presets: csharpAutoImplement ? [
88
- {
89
- preset: modelina_1.CSHARP_DEFAULT_PRESET,
90
- options: {
91
- autoImplementedProperties: true
92
- }
86
+ if (csharpAutoImplement) {
87
+ presets.push({
88
+ preset: modelina_1.CSHARP_DEFAULT_PRESET,
89
+ options: {
90
+ autoImplementedProperties: true
91
+ }
92
+ });
93
+ }
94
+ if (csharpHashcode || csharpEqual) {
95
+ presets.push({
96
+ preset: modelina_1.CSHARP_COMMON_PRESET,
97
+ options: {
98
+ hashCode: csharpHashcode,
99
+ equals: csharpEqual
93
100
  }
94
- ] : [],
101
+ });
102
+ }
103
+ fileGenerator = new modelina_1.CSharpFileGenerator({
104
+ presets,
95
105
  collectionType: csharpArrayType
96
106
  });
97
107
  fileOptions = {
@@ -234,7 +244,7 @@ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: c
234
244
  required: false
235
245
  }),
236
246
  /**
237
- * C++ and C# specific namespace to use for the generated models
247
+ * C++ and C# and PHP specific namespace to use for the generated models
238
248
  */
239
249
  namespace: core_1.Flags.string({
240
250
  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`.',
@@ -253,4 +263,12 @@ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: c
253
263
  options: ['Array', 'List'],
254
264
  required: false,
255
265
  default: 'Array'
266
+ }), csharpHashcode: core_1.Flags.boolean({
267
+ description: 'C# specific, generate the models with the GetHashCode method overwritten',
268
+ required: false,
269
+ default: false
270
+ }), csharpEqual: core_1.Flags.boolean({
271
+ description: 'C# specific, generate the models with the Equal method overwritten',
272
+ required: false,
273
+ default: false
256
274
  }) }, (0, parser_1.validationFlags)({ logDiagnostics: false }));
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.41.0",
2
+ "version": "0.42.0",
3
3
  "commands": {
4
4
  "bundle": {
5
5
  "id": "bundle",
@@ -565,6 +565,20 @@
565
565
  ],
566
566
  "default": "Array"
567
567
  },
568
+ "csharpHashcode": {
569
+ "name": "csharpHashcode",
570
+ "type": "boolean",
571
+ "description": "C# specific, generate the models with the GetHashCode method overwritten",
572
+ "required": false,
573
+ "allowNo": false
574
+ },
575
+ "csharpEqual": {
576
+ "name": "csharpEqual",
577
+ "type": "boolean",
578
+ "description": "C# specific, generate the models with the Equal method overwritten",
579
+ "required": false,
580
+ "allowNo": false
581
+ },
568
582
  "log-diagnostics": {
569
583
  "name": "log-diagnostics",
570
584
  "type": "boolean",
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": "0.41.0",
4
+ "version": "0.42.0",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run"