From 98583d1f8b0cc6694adf5c7afbb1827a1a2d9b8f Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Thu, 18 May 2023 13:23:02 +0200 Subject: [PATCH 01/25] fix: update @asyncapi/generator to 1.10.0 version (#565) --- package-lock.json | 114 ++++++---------------------------------------- package.json | 2 +- 2 files changed, 16 insertions(+), 100 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88de1517df9..ba2a5703e9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@asyncapi/bundler": "^0.3.8", "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", - "@asyncapi/generator": "^1.9.17", + "@asyncapi/generator": "^1.10.0", "@asyncapi/modelina": "^1.5.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", @@ -272,15 +272,15 @@ } }, "node_modules/@asyncapi/generator": { - "version": "1.9.17", - "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.9.17.tgz", - "integrity": "sha512-VHtZn6f+2w0rqFS+0e7QxH7vkyZGbLkuFSNOGWfVGaQqkmtCHY70pYxpF5ojCvMrqAAQyKKKXvzjIfjCabDKhA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.10.0.tgz", + "integrity": "sha512-Tcs4lz4BU5cpuZ/smxm7mmzPSpXL2+yppAnq1FocFl6ObAvCpG4vHqwoH8aZT6licsn7TTv+5VDrgi4N+MdvPQ==", "dependencies": { - "@asyncapi/avro-schema-parser": "^1.1.0", + "@asyncapi/avro-schema-parser": "^3.0.0", "@asyncapi/generator-react-sdk": "^0.2.23", - "@asyncapi/openapi-schema-parser": "^2.0.1", - "@asyncapi/parser": "^1.18.0", - "@asyncapi/raml-dt-schema-parser": "^2.0.1", + "@asyncapi/openapi-schema-parser": "^3.0.0", + "@asyncapi/parser": "^2.0.0", + "@asyncapi/raml-dt-schema-parser": "^4.0.0", "@npmcli/arborist": "^2.2.4", "ajv": "^6.10.2", "chokidar": "^3.4.0", @@ -420,48 +420,6 @@ "node": ">=0.10.0" } }, - "node_modules/@asyncapi/generator/node_modules/@asyncapi/avro-schema-parser": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@asyncapi/avro-schema-parser/-/avro-schema-parser-1.1.0.tgz", - "integrity": "sha512-7J7pzSw0/jF2bXy/Mf+80VKJfXRRfyLTJz413MkKLbLXbbz9rV4sVpYfp31ofqXgyZ9bhfmHJzunbi0Bt7Jcww==", - "dependencies": { - "avsc": "^5.7.3" - } - }, - "node_modules/@asyncapi/generator/node_modules/@asyncapi/openapi-schema-parser": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-2.0.3.tgz", - "integrity": "sha512-o9fvibjx2n3L2SKNlWUQ59CxO2x2BKhbHxh81U39NMLgowN/avk1wfxkMvzL3G9pg4FlgCdcayDhu4+TzDX47A==", - "dependencies": { - "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", - "conventional-changelog-conventionalcommits": "^5.0.0" - } - }, - "node_modules/@asyncapi/generator/node_modules/@asyncapi/parser": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-1.18.1.tgz", - "integrity": "sha512-7sU9DajLV+vA2vShTYmD5lbtbTY6TOcGxB4Z4IcpRp8x5pejOsN32iU05eIYCnuamsi5SMscFxoi6fIO2vPK3Q==", - "dependencies": { - "@apidevtools/json-schema-ref-parser": "^9.0.6", - "@asyncapi/specs": "^4.1.1", - "@fmvilas/pseudo-yaml-ast": "^0.3.1", - "ajv": "^6.10.1", - "js-yaml": "^3.13.1", - "json-to-ast": "^2.1.0", - "lodash.clonedeep": "^4.5.0", - "node-fetch": "^2.6.0", - "tiny-merge-patch": "^0.1.2" - } - }, - "node_modules/@asyncapi/generator/node_modules/@asyncapi/raml-dt-schema-parser": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@asyncapi/raml-dt-schema-parser/-/raml-dt-schema-parser-2.0.1.tgz", - "integrity": "sha512-R7i35IbVbvGyPNm3t5ToPDtYUwDtVjWF/oCgCVPK/wLpNQ0uVZX5Y0JFhO78VUHEep0NKuuI2CZh6oLz0ebMVQ==", - "dependencies": { - "js-yaml": "^3.13.1", - "ramldt2jsonschema": "^1.1.0" - } - }, "node_modules/@asyncapi/generator/node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -23817,15 +23775,15 @@ } }, "@asyncapi/generator": { - "version": "1.9.17", - "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.9.17.tgz", - "integrity": "sha512-VHtZn6f+2w0rqFS+0e7QxH7vkyZGbLkuFSNOGWfVGaQqkmtCHY70pYxpF5ojCvMrqAAQyKKKXvzjIfjCabDKhA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.10.0.tgz", + "integrity": "sha512-Tcs4lz4BU5cpuZ/smxm7mmzPSpXL2+yppAnq1FocFl6ObAvCpG4vHqwoH8aZT6licsn7TTv+5VDrgi4N+MdvPQ==", "requires": { - "@asyncapi/avro-schema-parser": "^1.1.0", + "@asyncapi/avro-schema-parser": "^3.0.0", "@asyncapi/generator-react-sdk": "^0.2.23", - "@asyncapi/openapi-schema-parser": "^2.0.1", - "@asyncapi/parser": "^1.18.0", - "@asyncapi/raml-dt-schema-parser": "^2.0.1", + "@asyncapi/openapi-schema-parser": "^3.0.0", + "@asyncapi/parser": "^2.0.0", + "@asyncapi/raml-dt-schema-parser": "^4.0.0", "@npmcli/arborist": "^2.2.4", "ajv": "^6.10.2", "chokidar": "^3.4.0", @@ -23851,48 +23809,6 @@ "typescript": "^4.9.3" }, "dependencies": { - "@asyncapi/avro-schema-parser": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@asyncapi/avro-schema-parser/-/avro-schema-parser-1.1.0.tgz", - "integrity": "sha512-7J7pzSw0/jF2bXy/Mf+80VKJfXRRfyLTJz413MkKLbLXbbz9rV4sVpYfp31ofqXgyZ9bhfmHJzunbi0Bt7Jcww==", - "requires": { - "avsc": "^5.7.3" - } - }, - "@asyncapi/openapi-schema-parser": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-2.0.3.tgz", - "integrity": "sha512-o9fvibjx2n3L2SKNlWUQ59CxO2x2BKhbHxh81U39NMLgowN/avk1wfxkMvzL3G9pg4FlgCdcayDhu4+TzDX47A==", - "requires": { - "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", - "conventional-changelog-conventionalcommits": "^5.0.0" - } - }, - "@asyncapi/parser": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-1.18.1.tgz", - "integrity": "sha512-7sU9DajLV+vA2vShTYmD5lbtbTY6TOcGxB4Z4IcpRp8x5pejOsN32iU05eIYCnuamsi5SMscFxoi6fIO2vPK3Q==", - "requires": { - "@apidevtools/json-schema-ref-parser": "^9.0.6", - "@asyncapi/specs": "^4.1.1", - "@fmvilas/pseudo-yaml-ast": "^0.3.1", - "ajv": "^6.10.1", - "js-yaml": "^3.13.1", - "json-to-ast": "^2.1.0", - "lodash.clonedeep": "^4.5.0", - "node-fetch": "^2.6.0", - "tiny-merge-patch": "^0.1.2" - } - }, - "@asyncapi/raml-dt-schema-parser": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@asyncapi/raml-dt-schema-parser/-/raml-dt-schema-parser-2.0.1.tgz", - "integrity": "sha512-R7i35IbVbvGyPNm3t5ToPDtYUwDtVjWF/oCgCVPK/wLpNQ0uVZX5Y0JFhO78VUHEep0NKuuI2CZh6oLz0ebMVQ==", - "requires": { - "js-yaml": "^3.13.1", - "ramldt2jsonschema": "^1.1.0" - } - }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", diff --git a/package.json b/package.json index 4060082a47c..bb2a931d64a 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@asyncapi/bundler": "^0.3.8", "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", - "@asyncapi/generator": "^1.9.17", + "@asyncapi/generator": "^1.10.0", "@asyncapi/modelina": "^1.5.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", From 30359db96d9fe28a54742a1c7af0ae9dcc74f1e2 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Thu, 18 May 2023 13:34:21 +0200 Subject: [PATCH 02/25] chore(release): v0.40.7 (#566) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ba2a5703e9b..809b3e89e03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.40.6", + "version": "0.40.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.40.6", + "version": "0.40.7", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index bb2a931d64a..99c981ac1be 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.40.6", + "version": "0.40.7", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 78ca23a250414afd5f4dda7a5e38f000dc27dfc1 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 22 May 2023 15:56:55 +0200 Subject: [PATCH 03/25] fix: update @asyncapi/modelina to 1.6.0 version (#569) --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 809b3e89e03..e593b258a31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", "@asyncapi/generator": "^1.10.0", - "@asyncapi/modelina": "^1.5.0", + "@asyncapi/modelina": "^1.6.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", "@asyncapi/parser": "^2.0.0", @@ -479,9 +479,9 @@ "link": true }, "node_modules/@asyncapi/modelina": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.5.0.tgz", - "integrity": "sha512-YFoVCqf9YgZ/1xd6tVtFfkNhWcXq9cTLiVqUB/e/Fso8DHAEqYxOkKHSO/ywlhvnWdg+D3OO8BDse9x8cOZL6Q==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.0.tgz", + "integrity": "sha512-m2TVkLIfZWXClHMba7M+8YHJ0wuix/qGED/7yEBdW8CA40lcpQOKyVJaTrGfGK+6IPq+o7ReU8LUnKK2llO4Pg==", "dependencies": { "@apidevtools/json-schema-ref-parser": "^9.0.9", "@apidevtools/swagger-parser": "^10.0.3", @@ -23942,9 +23942,9 @@ } }, "@asyncapi/modelina": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.5.0.tgz", - "integrity": "sha512-YFoVCqf9YgZ/1xd6tVtFfkNhWcXq9cTLiVqUB/e/Fso8DHAEqYxOkKHSO/ywlhvnWdg+D3OO8BDse9x8cOZL6Q==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.0.tgz", + "integrity": "sha512-m2TVkLIfZWXClHMba7M+8YHJ0wuix/qGED/7yEBdW8CA40lcpQOKyVJaTrGfGK+6IPq+o7ReU8LUnKK2llO4Pg==", "requires": { "@apidevtools/json-schema-ref-parser": "^9.0.9", "@apidevtools/swagger-parser": "^10.0.3", diff --git a/package.json b/package.json index 99c981ac1be..c476a2de302 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", "@asyncapi/generator": "^1.10.0", - "@asyncapi/modelina": "^1.5.0", + "@asyncapi/modelina": "^1.6.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", "@asyncapi/parser": "^2.0.0", From c2b5cb38ce9fb544139a6fab2da6a5639d018e29 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 22 May 2023 16:07:58 +0200 Subject: [PATCH 04/25] chore(release): v0.40.8 (#570) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e593b258a31..8f6fa699e58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.40.7", + "version": "0.40.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.40.7", + "version": "0.40.8", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index c476a2de302..3895a90c3ba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.40.7", + "version": "0.40.8", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From bc0d47a39870ea462d4f5dbeb013da35af595469 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Tue, 23 May 2023 11:05:26 +0200 Subject: [PATCH 05/25] fix: update @asyncapi/modelina to 1.6.1 version (#577) --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8f6fa699e58..3145a591e6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", "@asyncapi/generator": "^1.10.0", - "@asyncapi/modelina": "^1.6.0", + "@asyncapi/modelina": "^1.6.1", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", "@asyncapi/parser": "^2.0.0", @@ -479,9 +479,9 @@ "link": true }, "node_modules/@asyncapi/modelina": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.0.tgz", - "integrity": "sha512-m2TVkLIfZWXClHMba7M+8YHJ0wuix/qGED/7yEBdW8CA40lcpQOKyVJaTrGfGK+6IPq+o7ReU8LUnKK2llO4Pg==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.1.tgz", + "integrity": "sha512-BF6vIkKU2iMmzm1sHFVnE3sbYwvJ7nAyFekjEWVA9tfo9hPYSTtth42p06hkJQAlL8muqwlKvlU78TnmNZgy5A==", "dependencies": { "@apidevtools/json-schema-ref-parser": "^9.0.9", "@apidevtools/swagger-parser": "^10.0.3", @@ -23942,9 +23942,9 @@ } }, "@asyncapi/modelina": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.0.tgz", - "integrity": "sha512-m2TVkLIfZWXClHMba7M+8YHJ0wuix/qGED/7yEBdW8CA40lcpQOKyVJaTrGfGK+6IPq+o7ReU8LUnKK2llO4Pg==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.1.tgz", + "integrity": "sha512-BF6vIkKU2iMmzm1sHFVnE3sbYwvJ7nAyFekjEWVA9tfo9hPYSTtth42p06hkJQAlL8muqwlKvlU78TnmNZgy5A==", "requires": { "@apidevtools/json-schema-ref-parser": "^9.0.9", "@apidevtools/swagger-parser": "^10.0.3", diff --git a/package.json b/package.json index 3895a90c3ba..d5ca39eb5b8 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", "@asyncapi/generator": "^1.10.0", - "@asyncapi/modelina": "^1.6.0", + "@asyncapi/modelina": "^1.6.1", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", "@asyncapi/parser": "^2.0.0", From 37994f7c1d38f3d22573770ac5c77b4935622d4b Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Tue, 23 May 2023 11:19:24 +0200 Subject: [PATCH 06/25] chore(release): v0.40.9 (#578) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3145a591e6f..6a30e24fb35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.40.8", + "version": "0.40.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.40.8", + "version": "0.40.9", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index d5ca39eb5b8..12729ca13b8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.40.8", + "version": "0.40.9", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 3c4721979577a956ae70926b4c78fc9adbc467c9 Mon Sep 17 00:00:00 2001 From: Rishi <52498617+kaushik-rishi@users.noreply.github.com> Date: Tue, 23 May 2023 16:58:10 +0530 Subject: [PATCH 07/25] feat: add C++ model generation support (#575) Co-authored-by: Lukasz Gornicki --- src/commands/generate/models.ts | 27 ++++++++++++++++++++------- test/commands/generate/models.test.ts | 25 ++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index ffd33d44954..8557d1cc1d4 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,4 +1,4 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, CplusplusFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; import Command from '../../base'; import { load } from '../../models/SpecificationFile'; @@ -15,7 +15,8 @@ enum Languages { dart = 'dart', python = 'python', rust = 'rust', - kotlin='kotlin' + kotlin='kotlin', + cplusplus='cplusplus' } const possibleLanguageValues = Object.values(Languages).join(', '); @@ -61,7 +62,7 @@ export default class Models extends Command { description: 'TypeScript specific, define the module system to be used.', required: false, default: 'ESM', - + }), tsIncludeComments: Flags.boolean({ description: 'TypeScript specific, if enabled add comments while generating models.', @@ -87,14 +88,18 @@ export default class Models extends Command { description: 'Go, Java and Kotlin specific, define the package to use for the generated models. This is required when language is `go`, `java` or `kotlin`.', required: false }), + /** - * C# specific options + * C++ and C# specific namespace to use for the generated models */ namespace: Flags.string({ - description: 'C# specific, define the namespace to use for the generated models. This is required when language is `csharp`.', + description: 'C++ and C# specific, define the namespace to use for the generated models. This is required when language is `cplusplus` or `csharp`.', required: false }), + /** + * C# specific options + */ csharpAutoImplement: Flags.boolean({ description: 'C# specific, define whether to generate auto-implemented properties or not.', required: false, @@ -109,7 +114,7 @@ export default class Models extends Command { }), ...validationFlags({ logDiagnostics: false }), }; - + /* eslint-disable sonarjs/cognitive-complexity */ async run() { const { args, flags } = await this.parse(Models); @@ -183,11 +188,19 @@ export default class Models extends Command { ] : [], collectionType: csharpArrayType as 'Array' | 'List' }); - + fileOptions = { namespace }; break; + case Languages.cplusplus: + if (namespace === undefined) { + 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.'); + } + fileGenerator = new CplusplusFileGenerator({ + namespace + }); + break; case Languages.golang: if (packageName === undefined) { throw new Error('In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.'); diff --git a/test/commands/generate/models.test.ts b/test/commands/generate/models.test.ts index 77f7329c8d2..06d62af2f1d 100644 --- a/test/commands/generate/models.test.ts +++ b/test/commands/generate/models.test.ts @@ -21,7 +21,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'random', './test/specification.yml', `-o=${ path.resolve(outputDir, './random')}`]) .it('fails when it dont know the language', (ctx, done) => { - expect(ctx.stderr).toEqual('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin\nSee more help with --help\n'); + expect(ctx.stderr).toEqual('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, cplusplus\nSee more help with --help\n'); expect(ctx.stdout).toEqual(''); done(); }); @@ -157,6 +157,29 @@ describe('models', () => { }); }); + describe('for C++', () => { + test + .stderr() + .stdout() + .command([...generalOptions, 'cplusplus', './test/specification.yml', `-o=${path.resolve(outputDir, './cplusplus')}`, '--namespace=\'AsyncapiModels\'']) + .it('works when file path is passed', (ctx, done) => { + expect(ctx.stderr).toEqual(''); + expect(ctx.stdout).toContain( + 'Successfully generated the following models: ' + ); + done(); + }); + test + .stderr() + .stdout() + .command([...generalOptions, 'cplusplus', './test/specification.yml', `-o=${ path.resolve(outputDir, './cplusplus')}`]) + .it('fails when no namespace provided', (ctx, done) => { + expect(ctx.stderr).toEqual('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.\n'); + expect(ctx.stdout).toEqual(''); + done(); + }); + }); + describe('for Java', () => { test .stderr() From 784caa975ee4106132552a0548df7b5ea618ceb5 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 13:30:14 +0200 Subject: [PATCH 08/25] docs: add kaushik-rishi as a contributor for code (#579) --- .all-contributorsrc | 9 +++++++++ README.md | 1 + 2 files changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index bdacc7798f3..28800b35e1a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -179,6 +179,15 @@ "contributions": [ "code" ] + }, + { + "login": "kaushik-rishi", + "name": "Rishi", + "avatar_url": "https://avatars.githubusercontent.com/u/52498617?v=4", + "profile": "https://github.com/kaushik-rishi", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index f7511823fbb..433f674f8bc 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc Sambhav Gupta
Sambhav Gupta

💻 ⚠️ Hippolyte Vergnol
Hippolyte Vergnol

💻 🚇 Jente Vets
Jente Vets

💻 + Rishi
Rishi

💻 From 5b0f793d80e6fc0ae7bd7a293e352bfaceaa688c Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Tue, 23 May 2023 19:51:45 +0530 Subject: [PATCH 09/25] feat: add php support for models generation (#576) Co-authored-by: Lukasz Gornicki --- docs/usage.md | 6 +++++- src/commands/generate/models.ts | 14 ++++++++++++-- test/commands/generate/models.test.ts | 27 ++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 523438e8758..2bc42daf1a8 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -6,11 +6,13 @@ weight: 40 The AsyncAPI CLI makes it easier to work with AsyncAPI documents. To get **help**, run this command in your terminal: + ```sh asyncapi --help ``` It should print something similar to this: + ```sh All in one CLI for all AsyncAPI tools @@ -39,5 +41,7 @@ COMMANDS dart generate the models for Dart rust generate the models for Rust kotlin generate the models for Kotlin - fromTemplate generate whatever you want using templates compatible with AsyncAPI Generator + php generate the models for PHP + cplusplus generate the models for C++ + fromTemplate generate whatever you want using templates compatible with AsyncAPI Generator ``` diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index 8557d1cc1d4..b248f2f906e 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,4 +1,4 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, CplusplusFileGenerator } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; import Command from '../../base'; import { load } from '../../models/SpecificationFile'; @@ -16,6 +16,7 @@ enum Languages { python = 'python', rust = 'rust', kotlin='kotlin', + php='php', cplusplus='cplusplus' } const possibleLanguageValues = Object.values(Languages).join(', '); @@ -93,7 +94,7 @@ export default class Models extends Command { * C++ and C# specific namespace to use for the generated models */ namespace: Flags.string({ - description: 'C++ and C# specific, define the namespace to use for the generated models. This is required when language is `cplusplus` or `csharp`.', + 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`.', required: false }), @@ -240,6 +241,15 @@ export default class Models extends Command { packageName }; break; + case Languages.php: + if (namespace === undefined) { + throw new Error('In order to generate models to PHP, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.'); + } + fileGenerator = new PhpFileGenerator(); + fileOptions = { + namespace + }; + break; default: throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`); } diff --git a/test/commands/generate/models.test.ts b/test/commands/generate/models.test.ts index 06d62af2f1d..a7c48e1471c 100644 --- a/test/commands/generate/models.test.ts +++ b/test/commands/generate/models.test.ts @@ -21,11 +21,10 @@ describe('models', () => { .stdout() .command([...generalOptions, 'random', './test/specification.yml', `-o=${ path.resolve(outputDir, './random')}`]) .it('fails when it dont know the language', (ctx, done) => { - expect(ctx.stderr).toEqual('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, cplusplus\nSee more help with --help\n'); + expect(ctx.stderr).toEqual('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, php, cplusplus\nSee more help with --help\n'); expect(ctx.stdout).toEqual(''); done(); }); - test .stderr() .stdout() @@ -271,7 +270,29 @@ describe('models', () => { done(); }); }); - + + describe('for PHP', () => { + test + .stderr() + .stdout() + .command([...generalOptions, 'php', './test/specification.yml', `-o=${ path.resolve(outputDir, './php')}`, '--namespace=\'asyncapi.models\'']) + .it('works when file path is passed', (ctx, done) => { + expect(ctx.stderr).toEqual(''); + expect(ctx.stdout).toContain( + 'Successfully generated the following models: ' + ); + done(); + }); + test + .stderr() + .stdout() + .command([...generalOptions, 'php', './test/specification.yml', `-o=${ path.resolve(outputDir, './php')}`]) + .it('fails when no namespace defined', (ctx, done) => { + expect(ctx.stderr).toEqual('Error: In order to generate models to PHP, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); + expect(ctx.stdout).toEqual(''); + done(); + }); + }); describe('with logging diagnostics', () => { test .stderr() From 0eff96e784a6b803bf83c0f572a1401c417c0532 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 16:45:37 +0200 Subject: [PATCH 10/25] docs: add Shurtu-gal as a contributor for code (#580) --- .all-contributorsrc | 9 +++++++++ README.md | 1 + 2 files changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 28800b35e1a..772bb854318 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -188,6 +188,15 @@ "contributions": [ "code" ] + }, + { + "login": "Shurtu-gal", + "name": "Ashish Padhy", + "avatar_url": "https://avatars.githubusercontent.com/u/100484401?v=4", + "profile": "http://ashishpadhy.live", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index 433f674f8bc..726b7a203e2 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc Hippolyte Vergnol
Hippolyte Vergnol

💻 🚇 Jente Vets
Jente Vets

💻 Rishi
Rishi

💻 + Ashish Padhy
Ashish Padhy

💻 From ad66ed7c75d15c5292d04b510b6228d7c24b2361 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Tue, 23 May 2023 17:03:51 +0200 Subject: [PATCH 11/25] chore(release): v0.41.0 (#581) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6a30e24fb35..52432fbc78a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.40.9", + "version": "0.41.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.40.9", + "version": "0.41.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index 12729ca13b8..1660a95f9b7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.40.9", + "version": "0.41.0", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 7cc496dcae85860266ed7e97ea391f063bf5eea0 Mon Sep 17 00:00:00 2001 From: Meet Agrawal Date: Tue, 23 May 2023 20:54:08 +0530 Subject: [PATCH 12/25] ci: extend release workflow to throw errors when it fails (#564) Co-authored-by: Lukasz Gornicki --- .github/workflows/upload-release-assets.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/upload-release-assets.yml b/.github/workflows/upload-release-assets.yml index f491d7d8235..bf11cd4ab5c 100644 --- a/.github/workflows/upload-release-assets.yml +++ b/.github/workflows/upload-release-assets.yml @@ -68,3 +68,12 @@ jobs: files: dist/${{ matrix.dist_folder }}/asyncapi.${{ matrix.extension }} tag_name: v${{ steps.extractver.outputs.version }} token: ${{ secrets.GH_TOKEN }} + - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel + name: Report workflow run status to Slack + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,action,workflow + text: 'AsyncAPI CLI release build artifacts failed' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} From c7d730a8501ffe73fc6313ba748802a43b5d8428 Mon Sep 17 00:00:00 2001 From: Rishi <52498617+kaushik-rishi@users.noreply.github.com> Date: Wed, 24 May 2023 15:01:32 +0530 Subject: [PATCH 13/25] feat: add hashcode and equals flags for csharp code generation (#583) Co-authored-by: Lukasz Gornicki --- src/commands/generate/models.ts | 43 ++++++++++++++++++------ test/commands/generate/models.test.ts | 48 ++++++++++++++++++++------- 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index b248f2f906e..8d4b393c59a 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,4 +1,4 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_COMMON_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; import Command from '../../base'; import { load } from '../../models/SpecificationFile'; @@ -91,7 +91,7 @@ export default class Models extends Command { }), /** - * C++ and C# specific namespace to use for the generated models + * C++ and C# and PHP specific namespace to use for the generated models */ namespace: Flags.string({ 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`.', @@ -113,13 +113,23 @@ export default class Models extends Command { required: false, default: 'Array' }), + csharpHashcode: Flags.boolean({ + description: 'C# specific, generate the models with the GetHashCode method overwritten', + required: false, + default: false + }), + csharpEqual: Flags.boolean({ + description: 'C# specific, generate the models with the Equal method overwritten', + required: false, + default: false + }), ...validationFlags({ logDiagnostics: false }), }; /* eslint-disable sonarjs/cognitive-complexity */ async run() { const { args, flags } = await this.parse(Models); - const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, packageName, output } = flags; + const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpHashcode, csharpEqual, packageName, output } = flags; const { language, file } = args; const inputFile = (await load(file)) || (await load()); const { document, status } = await parse(this, inputFile, flags); @@ -178,15 +188,26 @@ export default class Models extends Command { 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.'); } - fileGenerator = new CSharpFileGenerator({ - presets: csharpAutoImplement ? [ - { - preset: CSHARP_DEFAULT_PRESET, - options: { - autoImplementedProperties: true - } + if (csharpAutoImplement) { + presets.push({ + preset: CSHARP_DEFAULT_PRESET, + options: { + autoImplementedProperties: true + } + }); + } + if (csharpHashcode || csharpEqual) { + presets.push({ + preset: CSHARP_COMMON_PRESET, + options: { + hashCode: csharpHashcode, + equals: csharpEqual } - ] : [], + }); + } + + fileGenerator = new CSharpFileGenerator({ + presets, collectionType: csharpArrayType as 'Array' | 'List' }); diff --git a/test/commands/generate/models.test.ts b/test/commands/generate/models.test.ts index a7c48e1471c..1ae93e6278a 100644 --- a/test/commands/generate/models.test.ts +++ b/test/commands/generate/models.test.ts @@ -15,7 +15,7 @@ describe('models', () => { expect(ctx.stdout).toMatchSnapshot(); done(); }); - + test .stderr() .stdout() @@ -34,8 +34,8 @@ describe('models', () => { expect(ctx.stdout).toMatchSnapshot(); done(); }); - - describe('for TypeScript', () => { + + describe('for TypeScript', () => { test .stderr() .stdout() @@ -69,7 +69,7 @@ describe('models', () => { }); }); - describe('for JavaScript', () => { + describe('for JavaScript', () => { test .stderr() .stdout() @@ -83,7 +83,7 @@ describe('models', () => { }); }); - describe('for Python', () => { + describe('for Python', () => { test .stderr() .stdout() @@ -97,7 +97,7 @@ describe('models', () => { }); }); - describe('for Rust', () => { + describe('for Rust', () => { test .stderr() .stdout() @@ -146,7 +146,31 @@ describe('models', () => { test .stderr() .stdout() - .command([...generalOptions, 'csharp', './test/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpArrayType=List']) + .command([...generalOptions, 'csharp', './test/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpHashcode']) + .it('works when hash code flag is passed', (ctx, done) => { + expect(ctx.stderr).toEqual(''); + expect(ctx.stdout).toContain( + 'Successfully generated the following models: ' + ); + done(); + }); + + test + .stderr() + .stdout() + .command([...generalOptions, 'csharp', './test/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpEqual']) + .it('works when equal flag is passed', (ctx, done) => { + expect(ctx.stderr).toEqual(''); + expect(ctx.stdout).toContain( + 'Successfully generated the following models: ' + ); + done(); + }); + + test + .stderr() + .stdout() + .command([...generalOptions, 'csharp', './test/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpArrayType=List']) .it('works when array type is provided', (ctx, done) => { expect(ctx.stderr).toEqual(''); expect(ctx.stdout).toContain( @@ -201,8 +225,8 @@ describe('models', () => { done(); }); }); - - describe('for Go', () => { + + describe('for Go', () => { test .stderr() .stdout() @@ -225,7 +249,7 @@ describe('models', () => { }); }); - describe('for Kotlin', () => { + describe('for Kotlin', () => { test .stderr() .stdout() @@ -248,7 +272,7 @@ describe('models', () => { }); }); - describe('for Dart', () => { + describe('for Dart', () => { test .stderr() .stdout() @@ -270,7 +294,7 @@ describe('models', () => { done(); }); }); - + describe('for PHP', () => { test .stderr() From 3bc95a5e1067cc00ea28c32372eba809478dd07a Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Wed, 24 May 2023 11:40:40 +0200 Subject: [PATCH 14/25] chore(release): v0.42.0 (#585) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52432fbc78a..ce3b1b8b053 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.41.0", + "version": "0.42.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.41.0", + "version": "0.42.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index 1660a95f9b7..32d6f9c2a84 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.41.0", + "version": "0.42.0", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 7e7a2602a714ca4ea80c97931222b70768ae5f9e Mon Sep 17 00:00:00 2001 From: Rishi <52498617+kaushik-rishi@users.noreply.github.com> Date: Wed, 24 May 2023 15:48:49 +0530 Subject: [PATCH 15/25] feat: add csharp newtonsoft based model generation support (#584) --- src/commands/generate/models.ts | 21 +++++++++++++++++++-- test/commands/generate/models.test.ts | 11 +++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index 8d4b393c59a..fa337010284 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,4 +1,4 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_COMMON_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; import Command from '../../base'; import { load } from '../../models/SpecificationFile'; @@ -106,6 +106,11 @@ export default class Models extends Command { required: false, default: false }), + csharpNewtonsoft: Flags.boolean({ + description: 'C# specific, generate the models with newtonsoft serialization support', + required: false, + default: false + }), csharpArrayType: Flags.string({ type: 'option', description: 'C# specific, define which type of array needs to be generated.', @@ -129,7 +134,7 @@ export default class Models extends Command { /* eslint-disable sonarjs/cognitive-complexity */ async run() { const { args, flags } = await this.parse(Models); - const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpHashcode, csharpEqual, packageName, output } = flags; + const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, packageName, output } = flags; const { language, file } = args; const inputFile = (await load(file)) || (await load()); const { document, status } = await parse(this, inputFile, flags); @@ -187,6 +192,18 @@ export default class Models extends Command { if (namespace === undefined) { 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.'); } + if (csharpAutoImplement) { + presets.push({ + preset: CSHARP_DEFAULT_PRESET, + options: { + autoImplementedProperties: true + } + }); + } + + if (csharpNewtonsoft) { + presets.push(CSHARP_NEWTONSOFT_SERIALIZER_PRESET); + } if (csharpAutoImplement) { presets.push({ diff --git a/test/commands/generate/models.test.ts b/test/commands/generate/models.test.ts index 1ae93e6278a..d6ce9f295b1 100644 --- a/test/commands/generate/models.test.ts +++ b/test/commands/generate/models.test.ts @@ -143,6 +143,17 @@ describe('models', () => { ); done(); }); + test + .stderr() + .stdout() + .command([...generalOptions, 'csharp', './test/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpNewtonsoft']) + .it('works when newtonsoft flag is passed', (ctx, done) => { + expect(ctx.stderr).toEqual(''); + expect(ctx.stdout).toContain( + 'Successfully generated the following models: ' + ); + done(); + }); test .stderr() .stdout() From a6209fe586a257fc7a361459ee634f1c461e46d1 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Wed, 24 May 2023 13:08:37 +0200 Subject: [PATCH 16/25] chore(release): v0.43.0 (#587) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ce3b1b8b053..a931e6c8e63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.42.0", + "version": "0.43.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.42.0", + "version": "0.43.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index 32d6f9c2a84..6c9b5a1940a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.42.0", + "version": "0.43.0", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 18a4016484e821ffabe2b13c80fe901a5a15c855 Mon Sep 17 00:00:00 2001 From: Rishi <52498617+kaushik-rishi@users.noreply.github.com> Date: Wed, 24 May 2023 16:50:17 +0530 Subject: [PATCH 17/25] feat: add csharp json serialization support (#586) Co-authored-by: Lukasz Gornicki --- src/commands/generate/models.ts | 21 ++++++++++----------- test/commands/generate/models.test.ts | 12 ++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index fa337010284..e77c704ee12 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,4 +1,4 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; import Command from '../../base'; import { load } from '../../models/SpecificationFile'; @@ -128,13 +128,18 @@ export default class Models extends Command { required: false, default: false }), + csharpSystemJson: Flags.boolean({ + description: 'C# specific, generate the models with System.Text.Json serialization support', + required: false, + default: false + }), ...validationFlags({ logDiagnostics: false }), }; /* eslint-disable sonarjs/cognitive-complexity */ async run() { const { args, flags } = await this.parse(Models); - const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, packageName, output } = flags; + const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, csharpSystemJson, packageName, output } = flags; const { language, file } = args; const inputFile = (await load(file)) || (await load()); const { document, status } = await parse(this, inputFile, flags); @@ -192,6 +197,7 @@ export default class Models extends Command { if (namespace === undefined) { 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.'); } + if (csharpAutoImplement) { presets.push({ preset: CSHARP_DEFAULT_PRESET, @@ -200,18 +206,11 @@ export default class Models extends Command { } }); } - if (csharpNewtonsoft) { presets.push(CSHARP_NEWTONSOFT_SERIALIZER_PRESET); } - - if (csharpAutoImplement) { - presets.push({ - preset: CSHARP_DEFAULT_PRESET, - options: { - autoImplementedProperties: true - } - }); + if (csharpSystemJson) { + presets.push(CSHARP_JSON_SERIALIZER_PRESET); } if (csharpHashcode || csharpEqual) { presets.push({ diff --git a/test/commands/generate/models.test.ts b/test/commands/generate/models.test.ts index d6ce9f295b1..911b9ed22b9 100644 --- a/test/commands/generate/models.test.ts +++ b/test/commands/generate/models.test.ts @@ -178,6 +178,18 @@ describe('models', () => { done(); }); + test + .stderr() + .stdout() + .command([...generalOptions, 'csharp', './test/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpSystemJson']) + .it('works when system json flag is passed', (ctx, done) => { + expect(ctx.stderr).toEqual(''); + expect(ctx.stdout).toContain( + 'Successfully generated the following models: ' + ); + done(); + }); + test .stderr() .stdout() From bb5bfa6560bb98e46f8173f99fe5906a494f40c9 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Wed, 24 May 2023 13:28:58 +0200 Subject: [PATCH 18/25] chore(release): v0.44.0 (#588) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a931e6c8e63..d7857b02150 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.43.0", + "version": "0.44.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.43.0", + "version": "0.44.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index 6c9b5a1940a..cec059b596d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.43.0", + "version": "0.44.0", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 0d8cf7e7cc45368d00060bd0321ab4b6c4ebeae1 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 24 May 2023 14:39:58 +0200 Subject: [PATCH 19/25] docs: add meetagrawal09 as a contributor for infra (#582) Co-authored-by: Lukasz Gornicki --- .all-contributorsrc | 9 +++++++++ README.md | 1 + 2 files changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 772bb854318..84715bc5283 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -197,6 +197,15 @@ "contributions": [ "code" ] + }, + { + "login": "meetagrawal09", + "name": "Meet Agrawal", + "avatar_url": "https://avatars.githubusercontent.com/u/73902874?v=4", + "profile": "https://github.com/meetagrawal09", + "contributions": [ + "infra" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index 726b7a203e2..71d70aa4be9 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc Jente Vets
Jente Vets

💻 Rishi
Rishi

💻 Ashish Padhy
Ashish Padhy

💻 + Meet Agrawal
Meet Agrawal

🚇 From c7bef99e62092af686e9ca5505c6e8c6a755b585 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Thu, 25 May 2023 15:08:07 +0200 Subject: [PATCH 20/25] fix: update @asyncapi/modelina to 1.7.0 version (#594) --- package-lock.json | 47 +++++++++++++---------------------------------- package.json | 2 +- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7857b02150..0978b4d4d42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", "@asyncapi/generator": "^1.10.0", - "@asyncapi/modelina": "^1.6.1", + "@asyncapi/modelina": "^1.7.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", "@asyncapi/parser": "^2.0.0", @@ -479,18 +479,20 @@ "link": true }, "node_modules/@asyncapi/modelina": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.1.tgz", - "integrity": "sha512-BF6vIkKU2iMmzm1sHFVnE3sbYwvJ7nAyFekjEWVA9tfo9hPYSTtth42p06hkJQAlL8muqwlKvlU78TnmNZgy5A==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.7.0.tgz", + "integrity": "sha512-fIZ2pQEMubPRdShKYiUB2SN0NcxUQxvr6NEgZ1sfqInkWnkXyPQgung6LMEL5fkVOHIUa5tYBg1w23MISHF5eg==", "dependencies": { "@apidevtools/json-schema-ref-parser": "^9.0.9", "@apidevtools/swagger-parser": "^10.0.3", + "@asyncapi/avro-schema-parser": "^3.0.0", + "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/parser": "^2.0.0", + "@asyncapi/raml-dt-schema-parser": "^4.0.0", "@swc/core": "^1.3.5", "@swc/jest": "^0.2.23", "alterschema": "^1.1.2", "change-case": "^4.1.2", - "conventional-changelog-conventionalcommits": "^5.0.0", "openapi-types": "9.3.0", "typescript-json-schema": "^0.53.0" }, @@ -498,19 +500,6 @@ "node": ">=14" } }, - "node_modules/@asyncapi/modelina/node_modules/conventional-changelog-conventionalcommits": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", - "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", - "dependencies": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@asyncapi/openapi-schema-parser": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-3.0.0.tgz", @@ -23942,32 +23931,22 @@ } }, "@asyncapi/modelina": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.6.1.tgz", - "integrity": "sha512-BF6vIkKU2iMmzm1sHFVnE3sbYwvJ7nAyFekjEWVA9tfo9hPYSTtth42p06hkJQAlL8muqwlKvlU78TnmNZgy5A==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@asyncapi/modelina/-/modelina-1.7.0.tgz", + "integrity": "sha512-fIZ2pQEMubPRdShKYiUB2SN0NcxUQxvr6NEgZ1sfqInkWnkXyPQgung6LMEL5fkVOHIUa5tYBg1w23MISHF5eg==", "requires": { "@apidevtools/json-schema-ref-parser": "^9.0.9", "@apidevtools/swagger-parser": "^10.0.3", + "@asyncapi/avro-schema-parser": "^3.0.0", + "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/parser": "^2.0.0", + "@asyncapi/raml-dt-schema-parser": "^4.0.0", "@swc/core": "^1.3.5", "@swc/jest": "^0.2.23", "alterschema": "^1.1.2", "change-case": "^4.1.2", - "conventional-changelog-conventionalcommits": "^5.0.0", "openapi-types": "9.3.0", "typescript-json-schema": "^0.53.0" - }, - "dependencies": { - "conventional-changelog-conventionalcommits": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", - "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", - "requires": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - } - } } }, "@asyncapi/openapi-schema-parser": { diff --git a/package.json b/package.json index cec059b596d..aac11fa07de 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", "@asyncapi/generator": "^1.10.0", - "@asyncapi/modelina": "^1.6.1", + "@asyncapi/modelina": "^1.7.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", "@asyncapi/parser": "^2.0.0", From cfccec2d0ab5bec545093c9a3d95ff77f423d780 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Thu, 25 May 2023 15:16:33 +0200 Subject: [PATCH 21/25] chore(release): v0.44.1 (#595) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0978b4d4d42..10d6a1cc058 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.44.0", + "version": "0.44.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.44.0", + "version": "0.44.1", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index aac11fa07de..38f8766bd6a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.44.0", + "version": "0.44.1", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From 17f79adb8d6fb5d460633618644b63871e687ef4 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Fri, 26 May 2023 01:11:37 +0200 Subject: [PATCH 22/25] fix: update @asyncapi/generator to 1.10.1 version (#596) --- package-lock.json | 69 +++++++---------------------------------------- package.json | 2 +- 2 files changed, 10 insertions(+), 61 deletions(-) diff --git a/package-lock.json b/package-lock.json index 10d6a1cc058..f292d0d1099 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@asyncapi/bundler": "^0.3.8", "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", - "@asyncapi/generator": "^1.10.0", + "@asyncapi/generator": "^1.10.1", "@asyncapi/modelina": "^1.7.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", @@ -272,9 +272,9 @@ } }, "node_modules/@asyncapi/generator": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.10.0.tgz", - "integrity": "sha512-Tcs4lz4BU5cpuZ/smxm7mmzPSpXL2+yppAnq1FocFl6ObAvCpG4vHqwoH8aZT6licsn7TTv+5VDrgi4N+MdvPQ==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.10.1.tgz", + "integrity": "sha512-jSAX1mQPr/tSUNgxvdfM8G5rwBqGMgTCaQW8hhBViWhjxakzCWD/uRV4V2Tj1d51qvT7Brnj6PEWEX1ytlFV1w==", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", "@asyncapi/generator-react-sdk": "^0.2.23", @@ -282,10 +282,9 @@ "@asyncapi/parser": "^2.0.0", "@asyncapi/raml-dt-schema-parser": "^4.0.0", "@npmcli/arborist": "^2.2.4", - "ajv": "^6.10.2", + "ajv": "^8.12.0", "chokidar": "^3.4.0", "commander": "^6.1.0", - "conventional-changelog-conventionalcommits": "^5.0.0", "filenamify": "^4.1.0", "fs.extra": "^1.3.2", "global-dirs": "^3.0.0", @@ -420,34 +419,6 @@ "node": ">=0.10.0" } }, - "node_modules/@asyncapi/generator/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/@asyncapi/generator/node_modules/conventional-changelog-conventionalcommits": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", - "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", - "dependencies": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@asyncapi/generator/node_modules/simple-git": { "version": "3.17.0", "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.17.0.tgz", @@ -23764,9 +23735,9 @@ } }, "@asyncapi/generator": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.10.0.tgz", - "integrity": "sha512-Tcs4lz4BU5cpuZ/smxm7mmzPSpXL2+yppAnq1FocFl6ObAvCpG4vHqwoH8aZT6licsn7TTv+5VDrgi4N+MdvPQ==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@asyncapi/generator/-/generator-1.10.1.tgz", + "integrity": "sha512-jSAX1mQPr/tSUNgxvdfM8G5rwBqGMgTCaQW8hhBViWhjxakzCWD/uRV4V2Tj1d51qvT7Brnj6PEWEX1ytlFV1w==", "requires": { "@asyncapi/avro-schema-parser": "^3.0.0", "@asyncapi/generator-react-sdk": "^0.2.23", @@ -23774,10 +23745,9 @@ "@asyncapi/parser": "^2.0.0", "@asyncapi/raml-dt-schema-parser": "^4.0.0", "@npmcli/arborist": "^2.2.4", - "ajv": "^6.10.2", + "ajv": "^8.12.0", "chokidar": "^3.4.0", "commander": "^6.1.0", - "conventional-changelog-conventionalcommits": "^5.0.0", "filenamify": "^4.1.0", "fs.extra": "^1.3.2", "global-dirs": "^3.0.0", @@ -23798,27 +23768,6 @@ "typescript": "^4.9.3" }, "dependencies": { - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "conventional-changelog-conventionalcommits": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", - "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", - "requires": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - } - }, "simple-git": { "version": "3.17.0", "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.17.0.tgz", diff --git a/package.json b/package.json index 38f8766bd6a..a34be4bdab7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@asyncapi/bundler": "^0.3.8", "@asyncapi/converter": "^1.2.0", "@asyncapi/diff": "^0.4.1", - "@asyncapi/generator": "^1.10.0", + "@asyncapi/generator": "^1.10.1", "@asyncapi/modelina": "^1.7.0", "@asyncapi/openapi-schema-parser": "^3.0.0", "@asyncapi/optimizer": "^0.1.18", From 4714cc3f23b32b60c992f14ef256ea2d29242e61 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Fri, 26 May 2023 01:21:37 +0200 Subject: [PATCH 23/25] chore(release): v0.44.2 (#597) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f292d0d1099..eeeddf63c00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.44.1", + "version": "0.44.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.44.1", + "version": "0.44.2", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index a34be4bdab7..d44a3b3d25f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.44.1", + "version": "0.44.2", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run" From f345194c3bb8844dff2b0232da4b59c34c60e0a9 Mon Sep 17 00:00:00 2001 From: Viacheslav Turovskyi Date: Mon, 29 May 2023 15:31:20 +0300 Subject: [PATCH 24/25] feat: add `versions` to output versions of AsyncAPI tools used (#361) (#555) --- src/commands/config/versions.ts | 56 +++++++++++++++++++++++++++ test/commands/config/versions.test.ts | 27 +++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/commands/config/versions.ts create mode 100644 test/commands/config/versions.test.ts diff --git a/src/commands/config/versions.ts b/src/commands/config/versions.ts new file mode 100644 index 00000000000..76ce1953328 --- /dev/null +++ b/src/commands/config/versions.ts @@ -0,0 +1,56 @@ +import { Flags } from '@oclif/core'; +import Command from '../../base'; + +export default class Versions extends Command { + static description = 'Show versions of AsyncAPI tools used'; + + static flags = { + help: Flags.help({ char: 'h' }), + }; + + async run() { + const dependencies: string[] = []; + let dependency = ''; + + // Preparation of the array with all dependencies '@asyncapi/*' along with + // their versions. + for (const key in this.config.pjson.dependencies) { + // Making sure with .indexOf() that only package names which START with + // string '@asyncapi' are considered. + if (key.indexOf('@asyncapi', 0) === 0) { + // Avoiding obvious crash on manual removal or alteration of an + // '@asyncapi' package. + try { + // Goofy name `importedPJSON` is chosen to distinguish from name `pjson` + // used in `@oclif` source code. + const importedPJSON = await import(`${key}/package.json`); + dependencies.push(`${key}/${importedPJSON.default.version}`); + } catch (e) { + dependencies.push(`${key}/` + '`package.json` not found'); + } + } + } + + // Showing information available with `--version` flag. + this.log(this.config.userAgent); + + // Iteration through the array containing all dependencies '@asyncapi/*' + // along with their versions. + for (let i = 0; i < dependencies.length; i++) { + // Minimization of the theoretical possibility of a Generic Object + // Injection Sink, at the same time disabling eslint parsing for this + // line since it is actually a false positive. + // https://github.com/eslint-community/eslint-plugin-security/issues/21#issuecomment-530184612 + // https://github.com/eslint-community/eslint-plugin-security/issues/21#issuecomment-1157887653 + // https://web.archive.org/web/20150430062816/https://blog.liftsecurity.io/2015/01/15/the-dangers-of-square-bracket-notation + dependency = dependencies[i]; // eslint-disable-line + if (i !== dependencies.length - 1) { + this.log(` ├${dependency}`); + } else { + this.log(` └${dependency}\n`); + } + } + + this.log(`Repository: ${this.config.pjson.homepage}`); + } +} diff --git a/test/commands/config/versions.test.ts b/test/commands/config/versions.test.ts new file mode 100644 index 00000000000..cf385a4a75e --- /dev/null +++ b/test/commands/config/versions.test.ts @@ -0,0 +1,27 @@ +import { test } from '@oclif/test'; + +describe('versions', () => { + describe('config:versions', () => { + test + .stderr() + .stdout() + .command(['config:versions']) + .it('should show versions of AsyncAPI tools used', (ctx, done) => { + expect(ctx.stdout).toContain('@asyncapi/cli/'); + expect(ctx.stdout).toContain('├@asyncapi/'); + expect(ctx.stdout).toContain('└@asyncapi/'); + expect(ctx.stderr).toEqual(''); + done(); + }); + + test + .stderr() + .stdout() + .command(['config:versions']) + .it('should show address of repository of AsyncAPI CLI', (ctx, done) => { + expect(ctx.stdout).toContain('https://github.com/asyncapi/cli'); + expect(ctx.stderr).toEqual(''); + done(); + }); + }); +}); From 7a82239fbfc3a07adbf70ac814ea3a11e20256f7 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 29 May 2023 14:38:27 +0200 Subject: [PATCH 25/25] chore(release): v0.45.0 (#600) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index eeeddf63c00..c08b1102d67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/cli", - "version": "0.44.2", + "version": "0.45.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@asyncapi/cli", - "version": "0.44.2", + "version": "0.45.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.0", diff --git a/package.json b/package.json index d44a3b3d25f..0ca83adbd02 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/cli", "description": "All in one CLI for all AsyncAPI tools", - "version": "0.44.2", + "version": "0.45.0", "author": "@asyncapi", "bin": { "asyncapi": "./bin/run"