From 9021e5d2233763a5bc09e102b23a3841d930f24d Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Fri, 29 Sep 2023 13:50:29 +0200 Subject: [PATCH 1/6] enable html and markdown templates --- src/commands/generate/fromTemplate.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/commands/generate/fromTemplate.ts b/src/commands/generate/fromTemplate.ts index 81624dc5cb3..e53ea665cb2 100644 --- a/src/commands/generate/fromTemplate.ts +++ b/src/commands/generate/fromTemplate.ts @@ -32,7 +32,6 @@ interface ParsedFlags { const templatesNotSupportingV3: Record = { '@asyncapi/minimaltemplate': 'some link', // For testing purpose - '@asyncapi/html-template': 'https://github.com/asyncapi/html-template/issues/430', '@asyncapi/dotnet-nats-template': 'https://github.com/asyncapi/dotnet-nats-template/issues/384', '@asyncapi/ts-nats-template': 'https://github.com/asyncapi/ts-nats-template/issues/545', '@asyncapi/python-paho-template': 'https://github.com/asyncapi/python-paho-template/issues/189', @@ -40,7 +39,6 @@ const templatesNotSupportingV3: Record = { '@asyncapi/java-spring-cloud-stream-template': 'https://github.com/asyncapi/java-spring-cloud-stream-template/issues/336', '@asyncapi/go-watermill-template': 'https://github.com/asyncapi/go-watermill-template/issues/243', '@asyncapi/java-spring-template': 'https://github.com/asyncapi/java-spring-template/issues/308', - '@asyncapi/markdown-template': 'https://github.com/asyncapi/markdown-template/issues/341', '@asyncapi/nodejs-template': 'https://github.com/asyncapi/nodejs-template/issues/215', '@asyncapi/java-template': 'https://github.com/asyncapi/java-template/issues/118', '@asyncapi/php-template': 'https://github.com/asyncapi/php-template/issues/191' From 6dee0d4b8d450b376adfb0ab19ea770dbec93860 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Mon, 9 Oct 2023 11:42:52 +0200 Subject: [PATCH 2/6] add tests --- package-lock.json | 62 +++++++++++++++++++ .../integration/generate/fromTemplate.test.ts | 31 ++++++++++ 2 files changed, 93 insertions(+) diff --git a/package-lock.json b/package-lock.json index b434e244ecb..f06e0da6776 100644 --- a/package-lock.json +++ b/package-lock.json @@ -747,6 +747,19 @@ "semver": "bin/semver" } }, + "node_modules/@asyncapi/generator/node_modules/@smoya/multi-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@smoya/multi-parser/-/multi-parser-4.0.0.tgz", + "integrity": "sha512-NgPxSaB3YqwrIVe7AtQ/wh9I2J0BHR4lP0PdqirYYrc0XXRwdDjIRrywEc2jjECWsL7tuGU/QtGMGIVaJe6ZYA==", + "dependencies": { + "@asyncapi/avro-schema-parser": "^3.0.3", + "@asyncapi/openapi-schema-parser": "^3.0.4", + "@asyncapi/protobuf-schema-parser": "^3.0.0", + "@asyncapi/raml-dt-schema-parser": "^4.0.4", + "parserv2": "npm:@asyncapi/parser@^2.1.0", + "parserv3": "npm:@asyncapi/parser@^3.0.0-next-major-spec.3" + } + }, "node_modules/@asyncapi/generator/node_modules/argparse": { "version": "1.0.10", "license": "MIT", @@ -797,6 +810,55 @@ } } }, + "node_modules/@asyncapi/generator/node_modules/parserv3": { + "name": "@asyncapi/parser", + "version": "3.0.0-next-major-spec.5", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.0-next-major-spec.5.tgz", + "integrity": "sha512-+Da9ZPToTcEVIYtR2wlgeQOkd3+iwMf0Ah+uKA1rDyLj7UZ9UtEANnD1tmi4ONymqGwhneVOwBAu6K/dO36Vmw==", + "dependencies": { + "@asyncapi/specs": "^6.0.0-next-major-spec.6", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "node_modules/@asyncapi/generator/node_modules/parserv3/node_modules/@asyncapi/specs": { + "version": "6.0.0-next-major-spec.9", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.9.tgz", + "integrity": "sha512-fmOITQoYMw3I2Vai7u/vT0q4yHMBkeXTPByHhrqCaxnwX59Yb2vsMmukHjq478qqCP/U/TmzVvGpEy0JBMaelw==", + "dependencies": { + "@types/json-schema": "^7.0.11" + } + }, + "node_modules/@asyncapi/generator/node_modules/parserv3/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/@asyncapi/generator/node_modules/parserv3/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@asyncapi/generator/node_modules/react": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", diff --git a/test/integration/generate/fromTemplate.test.ts b/test/integration/generate/fromTemplate.test.ts index c4265d201bb..8bb079c7beb 100644 --- a/test/integration/generate/fromTemplate.test.ts +++ b/test/integration/generate/fromTemplate.test.ts @@ -45,6 +45,37 @@ describe('template', () => { done(); }); }); + + test + .stderr() + .stdout() + .command([ + 'generate:fromTemplate', + asyncapiv3, + '@asyncapi/markdown-template', '--output=./test/docs/v3/markdown-template', '--force-write']) + .it('should be able to use AsyncAPI v3 with markdown', (ctx, done) => { + expect(ctx.stdout).toContain( + 'Check out your shiny new generated files at ./test/docs/v3/markdown-template.\n\n' + ); + cleanup('./test/docs/v3/markdown-template'); + done(); + }); + + test + .stderr() + .stdout() + .command([ + 'generate:fromTemplate', + asyncapiv3, + '@asyncapi/html-template', '--output=./test/docs/v3/html-template', '--force-write']) + .it('should be able to use AsyncAPI v3 with markdown', (ctx, done) => { + expect(ctx.stdout).toContain( + 'Check out your shiny new generated files at ./test/docs/v3/html-template.\n\n' + ); + cleanup('./test/docs/v3/html-template'); + done(); + }); + describe('git clash', () => { const pathToOutput = './test/docs/2'; before(() => { From 8bc7f1a8a4fa550c8cfe9aa0321eed64af7c5025 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Mon, 9 Oct 2023 12:02:52 +0200 Subject: [PATCH 3/6] fix test --- test/integration/generate/fromTemplate.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/generate/fromTemplate.test.ts b/test/integration/generate/fromTemplate.test.ts index 8bb079c7beb..c7243a7b424 100644 --- a/test/integration/generate/fromTemplate.test.ts +++ b/test/integration/generate/fromTemplate.test.ts @@ -54,7 +54,7 @@ describe('template', () => { asyncapiv3, '@asyncapi/markdown-template', '--output=./test/docs/v3/markdown-template', '--force-write']) .it('should be able to use AsyncAPI v3 with markdown', (ctx, done) => { - expect(ctx.stdout).toContain( + expect(ctx.stdout).to.contain( 'Check out your shiny new generated files at ./test/docs/v3/markdown-template.\n\n' ); cleanup('./test/docs/v3/markdown-template'); @@ -69,7 +69,7 @@ describe('template', () => { asyncapiv3, '@asyncapi/html-template', '--output=./test/docs/v3/html-template', '--force-write']) .it('should be able to use AsyncAPI v3 with markdown', (ctx, done) => { - expect(ctx.stdout).toContain( + expect(ctx.stdout).to.contain( 'Check out your shiny new generated files at ./test/docs/v3/html-template.\n\n' ); cleanup('./test/docs/v3/html-template'); From 9c3cf3d68da8ffcf85f8bf6a8ae147a2fb7541e5 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Mon, 9 Oct 2023 17:31:40 +0200 Subject: [PATCH 4/6] remove tests --- test/fixtures/specification-v3.yml | 11 ----- .../integration/generate/fromTemplate.test.ts | 47 +------------------ 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/test/fixtures/specification-v3.yml b/test/fixtures/specification-v3.yml index 93cdabbb181..b636d86d731 100644 --- a/test/fixtures/specification-v3.yml +++ b/test/fixtures/specification-v3.yml @@ -43,11 +43,6 @@ servers: 'read:pets': read your pets scopes: - 'write:pets' - - type: openIdConnect - openIdConnectUrl: openIdConnectUrl - scopes: - - 'some:scope:1' - - 'some:scope:2' production: host: 'api.streetlights.smartylighting.com:{port}' pathname: /some/path @@ -102,8 +97,6 @@ channels: subscribe.message.2: payload: type: object - subscribe.message.3: - $ref: 'https://example.com/message' servers: - $ref: '#/servers/default' - $ref: '#/servers/production' @@ -154,7 +147,6 @@ operations: #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on/messages/customMessageId - $ref: >- #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on/messages/subscribe.message.2 - - $ref: 'https://example.com/message' turnOnOff: action: send channel: @@ -242,9 +234,6 @@ components: availableScopes: 'write:pets': modify pets in your account 'read:pets': read your pets - openIdConnect: - type: openIdConnect - openIdConnectUrl: openIdConnectUrl unusedFlows: type: oauth2 flows: diff --git a/test/integration/generate/fromTemplate.test.ts b/test/integration/generate/fromTemplate.test.ts index c7243a7b424..d3cfa8bc65e 100644 --- a/test/integration/generate/fromTemplate.test.ts +++ b/test/integration/generate/fromTemplate.test.ts @@ -23,7 +23,7 @@ describe('template', () => { test .stdout() .command([...generalOptions, '--output=./test/docs/1', '--force-write']) - .it('should generate minimal tempalte', (ctx, done) => { + .it('should generate minimal template', (ctx, done) => { expect(ctx.stdout).to.contain( 'Check out your shiny new generated files at ./test/docs/1.\n\n' ); @@ -31,51 +31,6 @@ describe('template', () => { done(); }); - describe('should handle AsyncAPI v3 document correctly', () => { - test - .stderr() - .stdout() - .command([ - 'generate:fromTemplate', - asyncapiv3, - '@asyncapi/minimaltemplate']) - .it('give error', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: @asyncapi/minimaltemplate template does not support AsyncAPI v3 documents, please checkout some link\n'); - expect(ctx.stdout).to.equal(''); - done(); - }); - }); - - test - .stderr() - .stdout() - .command([ - 'generate:fromTemplate', - asyncapiv3, - '@asyncapi/markdown-template', '--output=./test/docs/v3/markdown-template', '--force-write']) - .it('should be able to use AsyncAPI v3 with markdown', (ctx, done) => { - expect(ctx.stdout).to.contain( - 'Check out your shiny new generated files at ./test/docs/v3/markdown-template.\n\n' - ); - cleanup('./test/docs/v3/markdown-template'); - done(); - }); - - test - .stderr() - .stdout() - .command([ - 'generate:fromTemplate', - asyncapiv3, - '@asyncapi/html-template', '--output=./test/docs/v3/html-template', '--force-write']) - .it('should be able to use AsyncAPI v3 with markdown', (ctx, done) => { - expect(ctx.stdout).to.contain( - 'Check out your shiny new generated files at ./test/docs/v3/html-template.\n\n' - ); - cleanup('./test/docs/v3/html-template'); - done(); - }); - describe('git clash', () => { const pathToOutput = './test/docs/2'; before(() => { From 5d9da3a56a7ef6b73e0db4fbb9599ae008dd1405 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Mon, 9 Oct 2023 17:32:30 +0200 Subject: [PATCH 5/6] remove tests --- test/fixtures/specification-v3.yml | 3 +++ test/integration/generate/fromTemplate.test.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/test/fixtures/specification-v3.yml b/test/fixtures/specification-v3.yml index b636d86d731..6943c0aa14d 100644 --- a/test/fixtures/specification-v3.yml +++ b/test/fixtures/specification-v3.yml @@ -234,6 +234,9 @@ components: availableScopes: 'write:pets': modify pets in your account 'read:pets': read your pets + openIdConnect: + type: openIdConnect + openIdConnectUrl: openIdConnectUrl unusedFlows: type: oauth2 flows: diff --git a/test/integration/generate/fromTemplate.test.ts b/test/integration/generate/fromTemplate.test.ts index d3cfa8bc65e..742aaa32b76 100644 --- a/test/integration/generate/fromTemplate.test.ts +++ b/test/integration/generate/fromTemplate.test.ts @@ -31,6 +31,21 @@ describe('template', () => { done(); }); + describe('should handle AsyncAPI v3 document correctly', () => { + test + .stderr() + .stdout() + .command([ + 'generate:fromTemplate', + asyncapiv3, + '@asyncapi/minimaltemplate']) + .it('give error on disabled template', (ctx, done) => { + expect(ctx.stderr).to.equal('Error: @asyncapi/minimaltemplate template does not support AsyncAPI v3 documents, please checkout some link\n'); + expect(ctx.stdout).to.equal(''); + done(); + }); + }).timeout(200000); + describe('git clash', () => { const pathToOutput = './test/docs/2'; before(() => { From 8729ff58869dabee79f554ef6fcb94db4d9a3866 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Tue, 10 Oct 2023 12:44:26 +0200 Subject: [PATCH 6/6] readd docs --- test/fixtures/specification-v3.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/fixtures/specification-v3.yml b/test/fixtures/specification-v3.yml index 6943c0aa14d..05cc8a0d556 100644 --- a/test/fixtures/specification-v3.yml +++ b/test/fixtures/specification-v3.yml @@ -43,6 +43,11 @@ servers: 'read:pets': read your pets scopes: - 'write:pets' + - type: openIdConnect + openIdConnectUrl: https://example.com/api + scopes: + - 'some:scope:1' + - 'some:scope:2' production: host: 'api.streetlights.smartylighting.com:{port}' pathname: /some/path @@ -235,8 +240,10 @@ components: 'write:pets': modify pets in your account 'read:pets': read your pets openIdConnect: - type: openIdConnect - openIdConnectUrl: openIdConnectUrl + openIdConnectUrl: https://example.com/api + scopes: + - 'some:scope:1' + - 'some:scope:2' unusedFlows: type: oauth2 flows: