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

Commit 967a029

Browse files
timonbacksam0r040
authored andcommitted
Display raw message bindings
Regression: Previously included mapped ui attributes chore: Improve [protocol: string]: any typings Co-authored-by: david.mueller@codecentric.de
1 parent 92d8bf1 commit 967a029

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/app/channels/channel-main/channel-main.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h4>
8080
<app-json [data]="operation.bindings[protocolName]"></app-json>
8181
</mat-tab>
8282
<mat-tab label="Message Bindings">
83-
<app-json [data]="operation.message.bindings.get(protocolName)"></app-json>
83+
<app-json [data]="operation.message.rawBindings[protocolName]"></app-json>
8484
</mat-tab>
8585
</mat-tab-group>
8686
</section>

src/app/shared/asyncapi-mapper.service.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ interface ServerAsyncApiMessage {
2626
description?: string;
2727
payload: { $ref: string };
2828
headers: { $ref: string };
29-
bindings: {[key: string]: ServerAsyncApiMessageBinding};
29+
bindings: {[protocol: string]: ServerAsyncApiMessageBinding};
3030
}
3131
interface ServerAsyncApiMessageBinding {
32-
[key: string]: ServerAsyncApiSchema | string;
32+
[protocol: string]: ServerAsyncApiSchema | string;
3333
}
3434

3535
interface ServerAsyncApiInfo {
@@ -43,7 +43,7 @@ export interface ServerAsyncApi {
4343
asyncapi: string;
4444
info: ServerAsyncApiInfo;
4545
servers: {
46-
[key: string]: {
46+
[server: string]: {
4747
url: string;
4848
protocol: string;
4949
};
@@ -53,11 +53,11 @@ export interface ServerAsyncApi {
5353
description?: string;
5454
subscribe?: {
5555
message: ServerAsyncApiChannelMessage;
56-
bindings?: any;
56+
bindings?: {[protocol: string]: object};
5757
};
5858
publish?: {
5959
message: ServerAsyncApiChannelMessage;
60-
bindings?: any;
60+
bindings?: {[protocol: string]: object};
6161
};
6262
};
6363
};
@@ -157,13 +157,14 @@ export class AsyncApiMapperService {
157157
name: v.headers.$ref,
158158
anchorUrl: AsyncApiMapperService.BASE_URL + v.headers.$ref?.split('/')?.pop()
159159
},
160-
bindings: this.mapServerAsyncApiMessageBindings(v.bindings)
160+
bindings: this.mapServerAsyncApiMessageBindings(v.bindings),
161+
rawBindings: v.bindings,
161162
};
162163
});
163164
}
164165

165166
private mapServerAsyncApiMessageBindings(
166-
serverMessageBindings?: { [type: string]: ServerAsyncApiMessageBinding }
167+
serverMessageBindings?: { [protocol: string]: ServerAsyncApiMessageBinding }
167168
): Map<string, MessageBinding> {
168169
const messageBindings = new Map<string, MessageBinding>();
169170
if (serverMessageBindings !== undefined) {
@@ -190,7 +191,7 @@ export class AsyncApiMapperService {
190191
}
191192

192193

193-
private mapOperation(operationType: OperationType, message: Message, bindings?: any): Operation {
194+
private mapOperation(operationType: OperationType, message: Message, bindings?: {[protocol: string]: object}): Operation {
194195
return {
195196
protocol: this.getProtocol(bindings),
196197
operation: operationType,
@@ -199,7 +200,7 @@ export class AsyncApiMapperService {
199200
};
200201
}
201202

202-
private getProtocol(bindings?: any): string {
203+
private getProtocol(bindings?: {[protocol: string]: object}): string {
203204
return Object.keys(bindings)[0];
204205
}
205206

src/app/shared/models/channel.model.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {Schema} from './schema.model';
22

3-
export const CHANNEL_ANCHOR_PREFIX = "#channel-"
3+
export const CHANNEL_ANCHOR_PREFIX = '#channel-';
44
export interface Channel {
55
name: string;
66
anchorIdentifier: string;
77
description?: string;
88
operation: Operation;
99
}
1010

11-
export type OperationType = "publish" | "subscribe";
11+
export type OperationType = 'publish' | 'subscribe';
1212
export interface Operation {
1313
message: Message;
14-
bindings?: { [type: string]: any };
14+
bindings?: { [protocol: string]: any };
1515
protocol: string;
1616
operation: OperationType;
1717
}
@@ -29,8 +29,9 @@ export interface Message {
2929
anchorUrl: string;
3030
};
3131
bindings?: Map<string, MessageBinding>;
32+
rawBindings?: {[protocol: string]: object};
3233
}
3334

3435
export interface MessageBinding {
35-
[type: string]: string | Schema;
36+
[protocol: string]: string | Schema;
3637
}

0 commit comments

Comments
 (0)