From 7db197c7c2f36bf67f7b2210059ef1bc1d95fc38 Mon Sep 17 00:00:00 2001 From: Mohammed Mehdi <96487647+catosaurusrex2003@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:12:14 +0530 Subject: [PATCH 1/8] feat: fix of make @asyncapi/react component with vs asyncapi preview (#1082) --- library/src/helpers/parser.ts | 90 +++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/library/src/helpers/parser.ts b/library/src/helpers/parser.ts index 0ecb3cc28..83da10b6b 100644 --- a/library/src/helpers/parser.ts +++ b/library/src/helpers/parser.ts @@ -1,4 +1,9 @@ -import { Parser as AsyncapiParser, fromURL } from '@asyncapi/parser'; +import { + Parser as AsyncapiParser, + Diagnostic, + DiagnosticSeverity, + fromURL, +} from '@asyncapi/parser'; import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser'; import { ProtoBuffSchemaParser } from '@asyncapi/protobuf-schema-parser'; import { AvroSchemaParser } from '@asyncapi/avro-schema-parser'; @@ -26,41 +31,18 @@ export class Parser { parserOptions?: any, ): Promise { try { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - const parseResult = await asyncapiParser.parse(content, parserOptions); - - const error: { - title: string | undefined; - validationErrors: ValidationError[] | undefined; - } = { - title: 'There are errors in your Asyncapi document', - validationErrors: [], - }; + const { document, diagnostics } = await asyncapiParser.parse( + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + content, + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + parserOptions, + ); - if (parseResult.document === undefined) { - parseResult.diagnostics.forEach((diagnostic) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison - if (diagnostic.severity == 0) { - const tempObj: ValidationError = { - title: diagnostic.message, - location: { - jsonPointer: '/' + diagnostic.path.join('/'), - startLine: diagnostic.range.start.line, - startColumn: diagnostic.range.start.character, - // as of @asyncapi/parser 3.3.0 offset of 1 correctly shows the error line - startOffset: 1, - endLine: diagnostic.range.end.line, - endColumn: diagnostic.range.end.character, - endOffset: 0, - }, - }; - error.validationErrors?.push(tempObj); - } - }); - throw error; + if (document === undefined) { + throw this.convertDiagnosticToErrorObject(diagnostics, [0]); } - return { asyncapi: parseResult.document }; + return { asyncapi: document }; } catch (err) { return this.handleError(err as ErrorObject); } @@ -79,13 +61,51 @@ export class Parser { arg.requestOptions as any, ); // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - const { document } = await fromResult.parse(parserOptions); - return { asyncapi: document }; + const { document, diagnostics } = await fromResult.parse(parserOptions); + + if (document == undefined) { + // this means there are errors in the document. + // so we gather all the severity 0 diagnostics and throw them as errors + throw this.convertDiagnosticToErrorObject(diagnostics, [0]); + } + + return { asyncapi: document, error: undefined }; } catch (err) { return this.handleError(err as ErrorObject); } } + static readonly convertDiagnosticToErrorObject = ( + diagnostics: Diagnostic[], + severities: DiagnosticSeverity[], + ): ErrorObject => { + const error: ErrorObject = { + title: 'There are errors in your Asyncapi document', + type: 'VALIDATION_ERRORS_TYPE', + validationErrors: [], + }; + diagnostics.forEach((diagnostic) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison + if (severities.includes(diagnostic.severity)) { + const tempObj: ValidationError = { + title: diagnostic.message, + location: { + jsonPointer: '/' + diagnostic.path.join('/'), + startLine: diagnostic.range.start.line, + startColumn: diagnostic.range.start.character, + // as of @asyncapi/parser 3.3.0 offset of 1 correctly shows the error line + startOffset: 1, + endLine: diagnostic.range.end.line, + endColumn: diagnostic.range.end.character, + endOffset: 0, + }, + }; + error.validationErrors?.push(tempObj); + } + }); + return error; + }; + private static handleError = (err: ErrorObject): ParserReturn => { if (err.type === VALIDATION_ERRORS_TYPE) { return { From 2c031c92ff460a5e2d6720209152449ab91589a4 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 14 Oct 2024 15:00:00 +0200 Subject: [PATCH 2/8] chore(release): v2.3.0 (#1085) --- library/package.json | 2 +- package-lock.json | 6 +++--- web-component/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/package.json b/library/package.json index f54e7a9db..eb5cc3b90 100644 --- a/library/package.json +++ b/library/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/react-component", - "version": "2.2.5", + "version": "2.3.0", "private": false, "description": "A React component for AsyncAPI specification.", "repository": { diff --git a/package-lock.json b/package-lock.json index 408108221..135fdf53a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ }, "library": { "name": "@asyncapi/react-component", - "version": "2.2.5", + "version": "2.3.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.24", @@ -27671,10 +27671,10 @@ }, "web-component": { "name": "@asyncapi/web-component", - "version": "2.2.5", + "version": "2.3.0", "license": "Apache-2.0", "dependencies": { - "@asyncapi/react-component": "^2.2.5", + "@asyncapi/react-component": "^2.3.0", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" diff --git a/web-component/package.json b/web-component/package.json index 6d40ded27..cec992edc 100644 --- a/web-component/package.json +++ b/web-component/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/web-component", - "version": "2.2.5", + "version": "2.3.0", "private": false, "description": "A web component for AsyncAPI specification. Based on @asyncapi/react-component.", "repository": { @@ -44,7 +44,7 @@ "install:reactcomp": "chmod +x ./bump-react-comp.sh && ./bump-react-comp.sh" }, "dependencies": { - "@asyncapi/react-component": "^2.2.5", + "@asyncapi/react-component": "^2.3.0", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" From 9b7eb7635bd5e7c811ed7943465fd38eebb37eb5 Mon Sep 17 00:00:00 2001 From: Aryan Raj <116114086+Aryan4884@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:48:33 +0530 Subject: [PATCH 3/8] fix: changed dommy to dummy (#1081) Co-authored-by: Cody's Dad <40604284+AceTheCreator@users.noreply.github.com> --- playground/specs/dummy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/specs/dummy.ts b/playground/specs/dummy.ts index e83f47be9..2ae74ebf5 100644 --- a/playground/specs/dummy.ts +++ b/playground/specs/dummy.ts @@ -58,7 +58,7 @@ servers: - '5672' security: - user-password: [] - dommy-kafka: + dummy-kafka: url: http://localhost:{port} protocol: kafka description: dummy Kafka broker From d4bc82e195cd69abaef5afbfecf75f24428e43d0 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 14 Oct 2024 15:34:33 +0200 Subject: [PATCH 4/8] chore(release): v2.3.1 (#1086) --- library/package.json | 2 +- package-lock.json | 6 +++--- web-component/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/package.json b/library/package.json index eb5cc3b90..bf0a29ba9 100644 --- a/library/package.json +++ b/library/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/react-component", - "version": "2.3.0", + "version": "2.3.1", "private": false, "description": "A React component for AsyncAPI specification.", "repository": { diff --git a/package-lock.json b/package-lock.json index 135fdf53a..93837294b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ }, "library": { "name": "@asyncapi/react-component", - "version": "2.3.0", + "version": "2.3.1", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.24", @@ -27671,10 +27671,10 @@ }, "web-component": { "name": "@asyncapi/web-component", - "version": "2.3.0", + "version": "2.3.1", "license": "Apache-2.0", "dependencies": { - "@asyncapi/react-component": "^2.3.0", + "@asyncapi/react-component": "^2.3.1", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" diff --git a/web-component/package.json b/web-component/package.json index cec992edc..e8e076177 100644 --- a/web-component/package.json +++ b/web-component/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/web-component", - "version": "2.3.0", + "version": "2.3.1", "private": false, "description": "A web component for AsyncAPI specification. Based on @asyncapi/react-component.", "repository": { @@ -44,7 +44,7 @@ "install:reactcomp": "chmod +x ./bump-react-comp.sh && ./bump-react-comp.sh" }, "dependencies": { - "@asyncapi/react-component": "^2.3.0", + "@asyncapi/react-component": "^2.3.1", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" From 8f3212df0f66a5d73d0d333ca86be40e5b84d290 Mon Sep 17 00:00:00 2001 From: Mohan Kumar <121867882+ItshMoh@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:18:44 +0530 Subject: [PATCH 5/8] fix: added semantic markup, strong instead of font-weight (#1062) Co-authored-by: Cody's Dad <40604284+AceTheCreator@users.noreply.github.com> --- library/src/components/Bindings.tsx | 4 +- library/src/components/Schema.tsx | 26 ++++++------ library/src/containers/Info/Info.tsx | 8 ++-- library/src/containers/Messages/Message.tsx | 2 +- .../src/containers/Operations/Operation.tsx | 2 +- library/src/containers/Servers/Security.tsx | 40 +++++++++---------- library/src/containers/Servers/Server.tsx | 8 ++-- library/src/containers/Sidebar/Sidebar.tsx | 6 +-- .../Sidebar/__tests__/SideBar.test.tsx | 6 +-- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/library/src/components/Bindings.tsx b/library/src/components/Bindings.tsx index f40deb37f..a6c8fcc39 100644 --- a/library/src/components/Bindings.tsx +++ b/library/src/components/Bindings.tsx @@ -25,9 +25,9 @@ export const Bindings: React.FunctionComponent = ({ const schemaName = (
{name} - + {protocol} - +
); return ( diff --git a/library/src/components/Schema.tsx b/library/src/components/Schema.tsx index 0ccb5bb0d..61dd88ac8 100644 --- a/library/src/components/Schema.tsx +++ b/library/src/components/Schema.tsx @@ -160,37 +160,37 @@ export const Schema: React.FunctionComponent = ({
{schema.format() && ( - + format: {schema.format()} - + )} {/* related to string */} {schema.pattern() !== undefined && ( - + must match: {schema.pattern()} - + )} {schema.contentMediaType() !== undefined && ( - + media type: {schema.contentMediaType()} - + )} {schema.contentEncoding() !== undefined && ( - + encoding: {schema.contentEncoding()} - + )} {/* constraints */} {!!constraints.length && constraints.map((c) => ( - {c} - + ))} {uid && !uid.startsWith(' = ({
)} {externalDocs && ( - + Documentation - + )} {schema.examples() && (
    diff --git a/library/src/containers/Info/Info.tsx b/library/src/containers/Info/Info.tsx index 49a4d40d7..790c78b9a 100644 --- a/library/src/containers/Info/Info.tsx +++ b/library/src/containers/Info/Info.tsx @@ -46,9 +46,9 @@ export const Info: React.FunctionComponent = () => { {license.name()} ) : ( - + {license.name()} - + )} )} @@ -108,9 +108,9 @@ export const Info: React.FunctionComponent = () => { )} {specId && (
  • - + ID: {specId} - +
  • )}
diff --git a/library/src/containers/Messages/Message.tsx b/library/src/containers/Messages/Message.tsx index 4d5c5fbf3..759faaa45 100644 --- a/library/src/containers/Messages/Message.tsx +++ b/library/src/containers/Messages/Message.tsx @@ -55,7 +55,7 @@ export const Message: React.FunctionComponent = ({
{index !== undefined && ( - #{index} + #{index} )} {title && {title}} diff --git a/library/src/containers/Operations/Operation.tsx b/library/src/containers/Operations/Operation.tsx index 26dc958d7..af98dd6c7 100644 --- a/library/src/containers/Operations/Operation.tsx +++ b/library/src/containers/Operations/Operation.tsx @@ -262,7 +262,7 @@ export const OperationReplyInfo: React.FunctionComponent = (props) => { : 'bg-blue-600 border-blue-600' } text-sm rounded-t h-8 px-4 border text-white flex items-center`} > - REPLY INFORMATION + REPLY INFORMATION
= ({
{securityProtocol && (
- + security.protocol: - - + + {securityProtocol} - +
)} {saslMechanism && (
- + sasl.mechanism: - - + + {saslMechanism} - +
)}
@@ -179,19 +179,19 @@ const SecurityItem: React.FunctionComponent = ({ key={flowName} >
- + Flow: - - + + {ServerHelpers.flowName(flowName)} - +
{authorizationUrl && (
- + Auth URL: - + {authorizationUrl} @@ -199,9 +199,9 @@ const SecurityItem: React.FunctionComponent = ({ )} {tokenUrl && (
- + Token URL: - + {tokenUrl} @@ -209,9 +209,9 @@ const SecurityItem: React.FunctionComponent = ({ )} {refreshUrl && (
- + Refresh URL: - + {refreshUrl} @@ -219,9 +219,9 @@ const SecurityItem: React.FunctionComponent = ({ )} {scopes && (
- + Scopes: - +
    {scopes && Object.entries(scopes).map(([scopeName, scopeDesc]) => ( diff --git a/library/src/containers/Servers/Server.tsx b/library/src/containers/Servers/Server.tsx index 560444ee1..233efdf9c 100644 --- a/library/src/containers/Servers/Server.tsx +++ b/library/src/containers/Servers/Server.tsx @@ -34,14 +34,14 @@ export const Server: React.FunctionComponent = ({
    {server.url()} - + {protocolVersion ? `${server.protocol()} ${protocolVersion}` : server.protocol()} - - + + {serverName} - +
    {server.hasDescription() && ( diff --git a/library/src/containers/Sidebar/Sidebar.tsx b/library/src/containers/Sidebar/Sidebar.tsx index a834a2b40..fe313624e 100644 --- a/library/src/containers/Sidebar/Sidebar.tsx +++ b/library/src/containers/Sidebar/Sidebar.tsx @@ -356,12 +356,12 @@ const OperationItem: React.FunctionComponent = ({ href={`#${operationHrefId}`} onClick={() => setShowSidebar(false)} > - {typeLabel} - + {label} diff --git a/library/src/containers/Sidebar/__tests__/SideBar.test.tsx b/library/src/containers/Sidebar/__tests__/SideBar.test.tsx index 4701a0006..6568f57e7 100644 --- a/library/src/containers/Sidebar/__tests__/SideBar.test.tsx +++ b/library/src/containers/Sidebar/__tests__/SideBar.test.tsx @@ -121,10 +121,10 @@ describe('Sidebar component', () => { 'smartylighting.streetlights.1.0.action.{streetlightId}.dim', ]; for (let i = 0; i < operations.length; i++) { + const description = operations[i].querySelector('span'); + // eslint-disable-next-line jest/no-standalone-expect - expect(operations[i].querySelectorAll('span')[1].textContent).toBe( - expectedOperationDescriptions[i], - ); + expect(description?.textContent).toBe(expectedOperationDescriptions[i]); } }); }); From 0615595525c98a51e6e1a51690eb502b3590ef95 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 14 Oct 2024 16:05:01 +0200 Subject: [PATCH 6/8] chore(release): v2.3.2 (#1087) --- library/package.json | 2 +- package-lock.json | 6 +++--- web-component/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/package.json b/library/package.json index bf0a29ba9..7f020f1de 100644 --- a/library/package.json +++ b/library/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/react-component", - "version": "2.3.1", + "version": "2.3.2", "private": false, "description": "A React component for AsyncAPI specification.", "repository": { diff --git a/package-lock.json b/package-lock.json index 93837294b..188ff5201 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ }, "library": { "name": "@asyncapi/react-component", - "version": "2.3.1", + "version": "2.3.2", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.24", @@ -27671,10 +27671,10 @@ }, "web-component": { "name": "@asyncapi/web-component", - "version": "2.3.1", + "version": "2.3.2", "license": "Apache-2.0", "dependencies": { - "@asyncapi/react-component": "^2.3.1", + "@asyncapi/react-component": "^2.3.2", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" diff --git a/web-component/package.json b/web-component/package.json index e8e076177..6430dd5ca 100644 --- a/web-component/package.json +++ b/web-component/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/web-component", - "version": "2.3.1", + "version": "2.3.2", "private": false, "description": "A web component for AsyncAPI specification. Based on @asyncapi/react-component.", "repository": { @@ -44,7 +44,7 @@ "install:reactcomp": "chmod +x ./bump-react-comp.sh && ./bump-react-comp.sh" }, "dependencies": { - "@asyncapi/react-component": "^2.3.1", + "@asyncapi/react-component": "^2.3.2", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" From 69429526c96d5e89a3247f6c432b932839916222 Mon Sep 17 00:00:00 2001 From: Manikanta Mandala <77623256+ManikantaMandala@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:44:37 +0530 Subject: [PATCH 7/8] fix: removed redundant MessageId (#1061) Co-authored-by: Cody's Dad <40604284+AceTheCreator@users.noreply.github.com> --- library/src/containers/Messages/Message.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/library/src/containers/Messages/Message.tsx b/library/src/containers/Messages/Message.tsx index 759faaa45..2b30b435b 100644 --- a/library/src/containers/Messages/Message.tsx +++ b/library/src/containers/Messages/Message.tsx @@ -58,9 +58,6 @@ export const Message: React.FunctionComponent = ({ #{index} )} {title && {title}} - - {messageId} -
    {summary &&

    {summary}

    } From 934677040b1b929f8b2a290592425455ecde3897 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Mon, 14 Oct 2024 16:30:58 +0200 Subject: [PATCH 8/8] chore(release): v2.3.3 (#1088) --- library/package.json | 2 +- package-lock.json | 6 +++--- web-component/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/package.json b/library/package.json index 7f020f1de..cb6227d68 100644 --- a/library/package.json +++ b/library/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/react-component", - "version": "2.3.2", + "version": "2.3.3", "private": false, "description": "A React component for AsyncAPI specification.", "repository": { diff --git a/package-lock.json b/package-lock.json index 188ff5201..a974ab968 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ }, "library": { "name": "@asyncapi/react-component", - "version": "2.3.2", + "version": "2.3.3", "license": "Apache-2.0", "dependencies": { "@asyncapi/avro-schema-parser": "^3.0.24", @@ -27671,10 +27671,10 @@ }, "web-component": { "name": "@asyncapi/web-component", - "version": "2.3.2", + "version": "2.3.3", "license": "Apache-2.0", "dependencies": { - "@asyncapi/react-component": "^2.3.2", + "@asyncapi/react-component": "^2.3.3", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2" diff --git a/web-component/package.json b/web-component/package.json index 6430dd5ca..cfd89549e 100644 --- a/web-component/package.json +++ b/web-component/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/web-component", - "version": "2.3.2", + "version": "2.3.3", "private": false, "description": "A web component for AsyncAPI specification. Based on @asyncapi/react-component.", "repository": { @@ -44,7 +44,7 @@ "install:reactcomp": "chmod +x ./bump-react-comp.sh && ./bump-react-comp.sh" }, "dependencies": { - "@asyncapi/react-component": "^2.3.2", + "@asyncapi/react-component": "^2.3.3", "react": "^18.2.0", "react-dom": "^18.2.0", "web-react-components": "^1.4.2"