From 967a029d54edde4e00042c2c61404b6d2152d49c Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 10 Mar 2023 15:23:42 +0100 Subject: [PATCH] Display raw message bindings Regression: Previously included mapped ui attributes chore: Improve [protocol: string]: any typings Co-authored-by: david.mueller@codecentric.de --- .../channel-main/channel-main.component.html | 2 +- src/app/shared/asyncapi-mapper.service.ts | 19 ++++++++++--------- src/app/shared/models/channel.model.ts | 9 +++++---- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/app/channels/channel-main/channel-main.component.html b/src/app/channels/channel-main/channel-main.component.html index baf1a46..75c0d41 100644 --- a/src/app/channels/channel-main/channel-main.component.html +++ b/src/app/channels/channel-main/channel-main.component.html @@ -80,7 +80,7 @@

- + diff --git a/src/app/shared/asyncapi-mapper.service.ts b/src/app/shared/asyncapi-mapper.service.ts index 2665dc5..0b06251 100644 --- a/src/app/shared/asyncapi-mapper.service.ts +++ b/src/app/shared/asyncapi-mapper.service.ts @@ -26,10 +26,10 @@ interface ServerAsyncApiMessage { description?: string; payload: { $ref: string }; headers: { $ref: string }; - bindings: {[key: string]: ServerAsyncApiMessageBinding}; + bindings: {[protocol: string]: ServerAsyncApiMessageBinding}; } interface ServerAsyncApiMessageBinding { - [key: string]: ServerAsyncApiSchema | string; + [protocol: string]: ServerAsyncApiSchema | string; } interface ServerAsyncApiInfo { @@ -43,7 +43,7 @@ export interface ServerAsyncApi { asyncapi: string; info: ServerAsyncApiInfo; servers: { - [key: string]: { + [server: string]: { url: string; protocol: string; }; @@ -53,11 +53,11 @@ export interface ServerAsyncApi { description?: string; subscribe?: { message: ServerAsyncApiChannelMessage; - bindings?: any; + bindings?: {[protocol: string]: object}; }; publish?: { message: ServerAsyncApiChannelMessage; - bindings?: any; + bindings?: {[protocol: string]: object}; }; }; }; @@ -157,13 +157,14 @@ export class AsyncApiMapperService { name: v.headers.$ref, anchorUrl: AsyncApiMapperService.BASE_URL + v.headers.$ref?.split('/')?.pop() }, - bindings: this.mapServerAsyncApiMessageBindings(v.bindings) + bindings: this.mapServerAsyncApiMessageBindings(v.bindings), + rawBindings: v.bindings, }; }); } private mapServerAsyncApiMessageBindings( - serverMessageBindings?: { [type: string]: ServerAsyncApiMessageBinding } + serverMessageBindings?: { [protocol: string]: ServerAsyncApiMessageBinding } ): Map { const messageBindings = new Map(); if (serverMessageBindings !== undefined) { @@ -190,7 +191,7 @@ export class AsyncApiMapperService { } - private mapOperation(operationType: OperationType, message: Message, bindings?: any): Operation { + private mapOperation(operationType: OperationType, message: Message, bindings?: {[protocol: string]: object}): Operation { return { protocol: this.getProtocol(bindings), operation: operationType, @@ -199,7 +200,7 @@ export class AsyncApiMapperService { }; } - private getProtocol(bindings?: any): string { + private getProtocol(bindings?: {[protocol: string]: object}): string { return Object.keys(bindings)[0]; } diff --git a/src/app/shared/models/channel.model.ts b/src/app/shared/models/channel.model.ts index 61ef230..b88ad03 100644 --- a/src/app/shared/models/channel.model.ts +++ b/src/app/shared/models/channel.model.ts @@ -1,6 +1,6 @@ import {Schema} from './schema.model'; -export const CHANNEL_ANCHOR_PREFIX = "#channel-" +export const CHANNEL_ANCHOR_PREFIX = '#channel-'; export interface Channel { name: string; anchorIdentifier: string; @@ -8,10 +8,10 @@ export interface Channel { operation: Operation; } -export type OperationType = "publish" | "subscribe"; +export type OperationType = 'publish' | 'subscribe'; export interface Operation { message: Message; - bindings?: { [type: string]: any }; + bindings?: { [protocol: string]: any }; protocol: string; operation: OperationType; } @@ -29,8 +29,9 @@ export interface Message { anchorUrl: string; }; bindings?: Map; + rawBindings?: {[protocol: string]: object}; } export interface MessageBinding { - [type: string]: string | Schema; + [protocol: string]: string | Schema; }