Skip to content

Commit c28946f

Browse files
committed
feat: add support for reply in python websocket client
1 parent f9eae1d commit c28946f

File tree

5 files changed

+275
-0
lines changed

5 files changed

+275
-0
lines changed

packages/templates/clients/websocket/test/__fixtures__/asyncapi-slack-client.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ components:
108108
messages:
109109
event:
110110
summary: Event message representing different event types
111+
correlationId:
112+
location: $message.payload#/envelope_id
111113
payload:
112114
$ref: '#/components/schemas/event'
113115
examples:
@@ -249,6 +251,8 @@ components:
249251
app_id: A08NKKBFGBD
250252
acknowledge:
251253
summary: Acknowledgement response sent to Server
254+
correlationId:
255+
location: $message.payload#/envelope_id
252256
payload:
253257
$ref: '#/components/schemas/acknowledge'
254258
examples:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
asyncapi: 3.0.0
2+
3+
info:
4+
title: Postman Echo WebSocket Client with Reply (Both Correlation IDs)
5+
version: 1.0.0
6+
description: >
7+
Test fixture for reply handling with correlation IDs on both incoming and reply messages.
8+
Template should extract correlation ID from incoming, pass to handler, and auto-inject into reply.
9+
10+
servers:
11+
echoServer:
12+
host: ws.postman-echo.com
13+
pathname: /raw
14+
protocol: wss
15+
16+
channels:
17+
echo:
18+
description: The main channel where messages are sent and echoed back by the Postman Echo WebSocket server.
19+
address: /
20+
messages:
21+
echoMessage:
22+
$ref: '#/components/messages/echoMessage'
23+
24+
operations:
25+
sendEchoMessage:
26+
summary: Send a message to the Postman Echo server and receive a reply.
27+
action: send
28+
channel:
29+
$ref: '#/channels/echo'
30+
messages:
31+
- $ref: '#/channels/echo/messages/echoMessage'
32+
reply:
33+
channel:
34+
$ref: '#/channels/echo'
35+
messages:
36+
- $ref: '#/channels/echo/messages/echoMessage'
37+
38+
components:
39+
messages:
40+
echoMessage:
41+
summary: A message exchanged with the echo server with correlation ID on both request and reply.
42+
correlationId:
43+
location: $message.payload#/requestId
44+
payload:
45+
type: object
46+
properties:
47+
requestId:
48+
type: string
49+
description: Request identifier (auto-injected into reply)
50+
message:
51+
type: string
52+
description: Message to echo back
53+
timestamp:
54+
type: string
55+
description: Request/reply timestamp
56+
examples:
57+
- name: stringWithId
58+
payload:
59+
requestId: req-12345
60+
message: test
61+
timestamp: '2025-12-23T10:00:00Z'
62+
- name: objectWithId
63+
payload:
64+
requestId: req-67890
65+
message: test text
66+
timestamp: '2025-12-23T10:00:00Z'
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
asyncapi: 3.0.0
2+
3+
info:
4+
title: Postman Echo WebSocket Client with Reply (Incoming Correlation Only)
5+
version: 1.0.0
6+
description: >
7+
Test fixture for reply handling with correlation ID only on incoming message.
8+
Template should extract correlation ID and pass to handler, but not auto-inject into reply.
9+
10+
servers:
11+
echoServer:
12+
host: ws.postman-echo.com
13+
pathname: /raw
14+
protocol: wss
15+
16+
channels:
17+
echo:
18+
description: The main channel where messages are sent and echoed back by the Postman Echo WebSocket server.
19+
address: /
20+
messages:
21+
echoMessage:
22+
$ref: '#/components/messages/echoMessage'
23+
24+
operations:
25+
sendEchoMessage:
26+
summary: Send a message to the Postman Echo server and receive a reply.
27+
action: send
28+
channel:
29+
$ref: '#/channels/echo'
30+
messages:
31+
- $ref: '#/channels/echo/messages/echoMessage'
32+
reply:
33+
channel:
34+
$ref: '#/channels/echo'
35+
messages:
36+
- $ref: '#/channels/echo/messages/echoMessage'
37+
38+
components:
39+
messages:
40+
echoMessage:
41+
summary: A message exchanged with the echo server with correlation ID.
42+
correlationId:
43+
location: $message.payload#/requestId
44+
payload:
45+
type: object
46+
properties:
47+
requestId:
48+
type: string
49+
description: Unique request identifier
50+
message:
51+
type: string
52+
description: Message to echo back
53+
timestamp:
54+
type: string
55+
description: Request timestamp
56+
examples:
57+
- name: stringWithId
58+
payload:
59+
requestId: req-12345
60+
message: test
61+
timestamp: '2025-12-23T10:00:00Z'
62+
- name: objectWithId
63+
payload:
64+
requestId: req-67890
65+
message: test text
66+
timestamp: '2025-12-23T10:00:00Z'
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
asyncapi: 3.0.0
2+
3+
info:
4+
title: Postman Echo WebSocket Client with Reply (No Correlation)
5+
version: 1.0.0
6+
description: >
7+
Test fixture for reply handling without correlation IDs.
8+
Postman Echo server replies to incoming messages without any correlation tracking.
9+
10+
servers:
11+
echoServer:
12+
host: ws.postman-echo.com
13+
pathname: /raw
14+
protocol: wss
15+
16+
channels:
17+
echo:
18+
description: The main channel where messages are sent and echoed back by the Postman Echo WebSocket server.
19+
address: /
20+
messages:
21+
echoMessage:
22+
$ref: '#/components/messages/echoMessage'
23+
24+
operations:
25+
sendEchoMessage:
26+
summary: Send a message to the Postman Echo server and receive a reply.
27+
action: send
28+
channel:
29+
$ref: '#/channels/echo'
30+
messages:
31+
- $ref: '#/channels/echo/messages/echoMessage'
32+
reply:
33+
channel:
34+
$ref: '#/channels/echo'
35+
messages:
36+
- $ref: '#/channels/echo/messages/echoMessage'
37+
38+
components:
39+
messages:
40+
echoMessage:
41+
summary: A message exchanged with the echo server.
42+
payload:
43+
type: object
44+
properties:
45+
message:
46+
type: string
47+
description: Message to echo back
48+
timestamp:
49+
type: string
50+
description: Request timestamp
51+
examples:
52+
- name: string
53+
payload:
54+
message: test
55+
timestamp: '2025-12-23T10:00:00Z'
56+
- name: object
57+
payload:
58+
message: test text
59+
timestamp: '2025-12-23T10:00:00Z'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
asyncapi: 3.0.0
2+
3+
info:
4+
title: Postman Echo WebSocket Client with Reply (Outgoing Correlation Only)
5+
version: 1.0.0
6+
description: >
7+
Test fixture for reply handling with correlation ID only on reply message.
8+
Template should log a warning that correlation cannot be populated from incoming message.
9+
10+
servers:
11+
echoServer:
12+
host: ws.postman-echo.com
13+
pathname: /raw
14+
protocol: wss
15+
16+
channels:
17+
echo:
18+
description: The main channel where messages are sent and echoed back by the Postman Echo WebSocket server.
19+
address: /
20+
messages:
21+
echoRequest:
22+
$ref: '#/components/messages/echoRequest'
23+
echoReply:
24+
$ref: '#/components/messages/echoReply'
25+
26+
operations:
27+
sendEchoMessage:
28+
summary: Send a message to the Postman Echo server and receive a reply.
29+
action: send
30+
channel:
31+
$ref: '#/channels/echo'
32+
messages:
33+
- $ref: '#/channels/echo/messages/echoRequest'
34+
reply:
35+
channel:
36+
$ref: '#/channels/echo'
37+
messages:
38+
- $ref: '#/channels/echo/messages/echoReply'
39+
40+
components:
41+
messages:
42+
echoRequest:
43+
summary: Echo request message without correlation ID.
44+
payload:
45+
type: object
46+
properties:
47+
message:
48+
type: string
49+
description: Message to echo back
50+
timestamp:
51+
type: string
52+
description: Request timestamp
53+
examples:
54+
- name: string
55+
payload:
56+
message: test
57+
timestamp: '2025-12-23T10:00:00Z'
58+
59+
echoReply:
60+
summary: Echo reply message with correlation ID.
61+
correlationId:
62+
location: $message.payload#/responseId
63+
payload:
64+
type: object
65+
properties:
66+
responseId:
67+
type: string
68+
description: Response identifier (cannot be auto-populated)
69+
echo:
70+
type: string
71+
description: Echoed message
72+
processedAt:
73+
type: string
74+
description: Server processing timestamp
75+
examples:
76+
- name: replyWithId
77+
payload:
78+
responseId: resp-67890
79+
echo: test
80+
processedAt: '2025-12-23T10:00:01Z'

0 commit comments

Comments
 (0)