Skip to content

Commit f72325b

Browse files
committed
Present kafka group id if available
1 parent fa2ac12 commit f72325b

File tree

6 files changed

+122
-53
lines changed

6 files changed

+122
-53
lines changed

springwolf-ui/src/app/channels/channel-main/channel-main.component.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ textarea {
1212
button {
1313
margin-top: 8px;
1414
}
15+
16+
.property-badge {
17+
background-color: #C5CAE9;
18+
border-radius: 4px;
19+
padding: 6px;
20+
font-size: small;
21+
font-weight: bold;
22+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<section>
2+
<div *ngIf="kafkaBinding.groupId" fxLayout fxLayoutAlign="flex-start center" fxLayoutGap="12px">
3+
<div class="property-badge">Group ID</div>
4+
<h4>{{ kafkaBinding.groupId }}</h4>
5+
</div>
26
<mat-tab-group animationDuration="0ms">
37
<mat-tab label="Schema">
48
<app-schema *ngIf="schema" [schema]="schema"></app-schema>

springwolf-ui/src/app/channels/channel-main/channel-main.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AsyncApiService } from 'src/app/shared/asyncapi.service';
33
import { Example } from 'src/app/shared/models/example.model';
44
import { PublisherService } from 'src/app/shared/publisher.service';
55
import { MatSnackBar } from '@angular/material/snack-bar';
6+
import { Operation } from 'src/app/shared/models/channel.model';
67

78
@Component({
89
selector: 'app-channel-main',
@@ -12,11 +13,13 @@ import { MatSnackBar } from '@angular/material/snack-bar';
1213
export class ChannelMainComponent implements OnInit {
1314

1415
@Input() channelName: string;
15-
@Input() payload: string;
16+
@Input() operation: Operation;
1617
defaultExample: Example;
1718
exampleTextAreaLineCount: number;
1819
schema: any;
1920

21+
kafkaBinding?: { groupId?: string }
22+
2023
constructor(
2124
private asyncApiService: AsyncApiService,
2225
private publisherService: PublisherService,
@@ -26,11 +29,15 @@ export class ChannelMainComponent implements OnInit {
2629
ngOnInit(): void {
2730
this.asyncApiService.getAsyncApi().subscribe(
2831
asyncapi => {
29-
this.schema = asyncapi.components.schemas.get(this.payload);
32+
this.schema = asyncapi.components.schemas.get(this.operation.message.title);
3033
this.defaultExample = this.schema.example;
3134
this.exampleTextAreaLineCount = this.defaultExample.lineCount;
3235
}
3336
);
37+
38+
if ("kafka" in this.operation.bindings) {
39+
this.kafkaBinding = { groupId: this.operation.bindings.kafka.groupId.enum[0] }
40+
}
3441
}
3542

3643
recalculateLineCount(text): void {

springwolf-ui/src/app/channels/channels.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ <h4>{{ channel.value.operation.message.title }}</h4>
1010
<div class="payload-name">{{ channel.value.operation.message.name }}</div>
1111
</mat-panel-title>
1212
</mat-expansion-panel-header>
13-
<app-channel-main [channelName]="channel.key" [payload]="channel.value.operation.message.title"></app-channel-main>
13+
<app-channel-main [channelName]="channel.key" [operation]="channel.value.operation"></app-channel-main>
1414
</mat-expansion-panel>
1515
</mat-accordion>
Lines changed: 98 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,106 @@
11
{
2-
"asyncapi": "2.0.0",
3-
"info": {
4-
"title": "swagger4kafka example project",
5-
"description": "This is a mock description.",
6-
"version": "1.0.0"
7-
},
8-
"servers": {
9-
"kafka": {
10-
"url": "kafka:29092",
11-
"protocol": "kafka"
12-
}
13-
},
14-
"channels": {
15-
"example-topic": {
16-
"subscribe": {
17-
"message": {
18-
"name": "io.github.stavshamir.swagger4kafka.example.dtos.ExamplePayloadDto",
19-
"title": "ExamplePayloadDto",
20-
"payload": {
21-
"$ref": "#/components/schemas/ExamplePayloadDto"
22-
}
23-
}
2+
"asyncapi": "2.0.0",
3+
"info": {
4+
"title": "Springwolf example project",
5+
"description": "Mock data",
6+
"version": "1.0.0"
7+
},
8+
"servers": {
9+
"kafka": {
10+
"url": "kafka:29092",
11+
"protocol": "kafka"
12+
}
13+
},
14+
"channels": {
15+
"another-topic": {
16+
"subscribe": {
17+
"bindings": {
18+
"kafka": {
19+
"groupId": {
20+
"type": "string",
21+
"enum": [
22+
"example-group-id"
23+
]
2424
}
25+
}
26+
},
27+
"message": {
28+
"name": "io.github.stavshamir.springwolf.example.dtos.AnotherPayloadDto",
29+
"title": "AnotherPayloadDto",
30+
"payload": {
31+
"$ref": "#/components/schemas/AnotherPayloadDto"
32+
}
2533
}
34+
}
2635
},
27-
"components": {
28-
"schemas": {
29-
"ExamplePayloadDto": {
30-
"type": "object",
31-
"properties": {
32-
"someString": {
33-
"type": "string"
34-
},
35-
"someLong": {
36-
"type": "integer",
37-
"format": "int64"
38-
},
39-
"someEnum": {
40-
"type": "string",
41-
"enum": [
42-
"FOO1",
43-
"FOO2",
44-
"FOO3"
45-
]
46-
}
47-
},
48-
"example": {
49-
"someString": "string",
50-
"someLong": 0,
51-
"someEnum": "FOO1"
52-
}
36+
"example-topic": {
37+
"subscribe": {
38+
"bindings": {
39+
"kafka": {
40+
"groupId": {
41+
"type": "string",
42+
"enum": [
43+
""
44+
]
5345
}
46+
}
47+
},
48+
"message": {
49+
"name": "io.github.stavshamir.springwolf.example.dtos.ExamplePayloadDto",
50+
"title": "ExamplePayloadDto",
51+
"payload": {
52+
"$ref": "#/components/schemas/ExamplePayloadDto"
53+
}
54+
}
55+
}
56+
}
57+
},
58+
"components": {
59+
"schemas": {
60+
"ExamplePayloadDto": {
61+
"type": "object",
62+
"properties": {
63+
"someString": {
64+
"type": "string"
65+
},
66+
"someLong": {
67+
"type": "integer",
68+
"format": "int64"
69+
},
70+
"someEnum": {
71+
"type": "string",
72+
"enum": [
73+
"FOO1",
74+
"FOO2",
75+
"FOO3"
76+
]
77+
}
78+
},
79+
"example": {
80+
"someString": "string",
81+
"someLong": 0,
82+
"someEnum": "FOO1"
83+
}
84+
},
85+
"AnotherPayloadDto": {
86+
"type": "object",
87+
"properties": {
88+
"foo": {
89+
"type": "string"
90+
},
91+
"example": {
92+
"$ref": "#/components/schemas/ExamplePayloadDto"
93+
}
94+
},
95+
"example": {
96+
"foo": "string",
97+
"example": {
98+
"someString": "string",
99+
"someLong": 0,
100+
"someEnum": "FOO1"
101+
}
54102
}
103+
}
55104
}
105+
}
56106
}

springwolf-ui/src/app/shared/models/channel.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export interface Channel {
66
export interface Operation {
77
type: "SUBSCRIBE" | "PUBLISH";
88
message: Message;
9-
bindings?: any;
9+
bindings?: { [type: string]: any };
1010
}
1111

1212
export interface Message {
1313
name: string;
1414
title: string;
15-
payload: { $ref: string};
15+
payload: { $ref: string };
1616
}

0 commit comments

Comments
 (0)