Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
Display raw message bindings
Browse files Browse the repository at this point in the history
Regression: Previously included mapped ui attributes
chore: Improve [protocol: string]: any typings

Co-authored-by: [email protected]
  • Loading branch information
timonback authored and sam0r040 committed Mar 10, 2023
1 parent 92d8bf1 commit 967a029
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/channels/channel-main/channel-main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h4>
<app-json [data]="operation.bindings[protocolName]"></app-json>
</mat-tab>
<mat-tab label="Message Bindings">
<app-json [data]="operation.message.bindings.get(protocolName)"></app-json>
<app-json [data]="operation.message.rawBindings[protocolName]"></app-json>
</mat-tab>
</mat-tab-group>
</section>
19 changes: 10 additions & 9 deletions src/app/shared/asyncapi-mapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -43,7 +43,7 @@ export interface ServerAsyncApi {
asyncapi: string;
info: ServerAsyncApiInfo;
servers: {
[key: string]: {
[server: string]: {
url: string;
protocol: string;
};
Expand All @@ -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};
};
};
};
Expand Down Expand Up @@ -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<string, MessageBinding> {
const messageBindings = new Map<string, MessageBinding>();
if (serverMessageBindings !== undefined) {
Expand All @@ -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,
Expand All @@ -199,7 +200,7 @@ export class AsyncApiMapperService {
};
}

private getProtocol(bindings?: any): string {
private getProtocol(bindings?: {[protocol: string]: object}): string {
return Object.keys(bindings)[0];
}

Expand Down
9 changes: 5 additions & 4 deletions src/app/shared/models/channel.model.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {Schema} from './schema.model';

export const CHANNEL_ANCHOR_PREFIX = "#channel-"
export const CHANNEL_ANCHOR_PREFIX = '#channel-';
export interface Channel {
name: string;
anchorIdentifier: string;
description?: string;
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;
}
Expand All @@ -29,8 +29,9 @@ export interface Message {
anchorUrl: string;
};
bindings?: Map<string, MessageBinding>;
rawBindings?: {[protocol: string]: object};
}

export interface MessageBinding {
[type: string]: string | Schema;
[protocol: string]: string | Schema;
}

0 comments on commit 967a029

Please sign in to comment.