Skip to content

Commit 7be4b73

Browse files
committed
add asyncapi playground
1 parent f1d5cd7 commit 7be4b73

File tree

2 files changed

+82
-8
lines changed

2 files changed

+82
-8
lines changed
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
---
2-
title: "Websockets Playground"
2+
title: "Playground"
33
description: "Enable users to interact with your websockets"
4+
asyncapi: "/asyncapi.yaml channelOne"
45
---
5-
6-
Autogenerating pages from your AsyncAPI schema will create pages for each channel that display message data that can be sent and received. In the API Playground for websockets, you can connect to websocket servers to send and receive messages.
7-
8-
![](https://picsum.photos/600/400)
9-
(this should be a nice image of messages in the API playground)
10-
11-
The API Playground for websockets is enabled by default, but automatically disabled if security schemes are required in the schema. Learn more about playground settings [here](settings/global#param-playground).

asyncapi.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
asyncapi: 3.0.0
2+
info:
3+
title: Test websocket schema
4+
version: 1.0.0
5+
description: This is a test websocket API.
6+
channels:
7+
channelOne:
8+
title: Test channel
9+
description: >-
10+
This is a websocket channel.
11+
12+
It can have _markdown_ in the description.
13+
14+
* Use the "echo-websocket.hoppscotch.io" server to receive timestamped messages every second.
15+
16+
* Use the "echo.websocket.org" server to send test messages to the websocket. This server will echo back any messages you send to it.
17+
18+
address: /
19+
messages:
20+
TestMessage:
21+
$ref: '#/components/messages/TestMessage'
22+
Timestamp:
23+
$ref: '#/components/messages/Timestamp'
24+
servers:
25+
echo-websocket:
26+
host: echo-websocket.hoppscotch.io
27+
protocol: wss
28+
echo:
29+
host: echo.websocket.org
30+
protocol: wss
31+
operations:
32+
sendTestMessage:
33+
action: receive
34+
channel:
35+
$ref: '#/channels/channelOne'
36+
messages:
37+
- $ref: '#/channels/channelOne/messages/TestMessage'
38+
receiveTestMessage:
39+
action: send
40+
channel:
41+
$ref: '#/channels/channelOne'
42+
messages:
43+
- $ref: '#/channels/channelOne/messages/TestMessage'
44+
receiveTimestamp:
45+
action: send
46+
channel:
47+
$ref: '#/channels/channelOne'
48+
messages:
49+
- $ref: '#/channels/channelOne/messages/Timestamp'
50+
components:
51+
messages:
52+
TestMessage:
53+
title: Test message
54+
description: Test message sent to the echo server
55+
payload:
56+
type: object
57+
properties:
58+
text:
59+
type: string
60+
description: The text of your message
61+
subtext:
62+
type: string
63+
description: Optional second message field
64+
from:
65+
type: string
66+
description: The name of the sender
67+
required:
68+
- text
69+
Timestamp:
70+
title: Timestamp
71+
description: Timestamp message sent from echo hoppscotch server
72+
payload:
73+
schema:
74+
$ref: '#/components/schemas/Timestamp'
75+
schemas:
76+
Timestamp:
77+
type: string
78+
description: Timestamp message sent from echo hoppscotch server
79+
examples:
80+
- '22:02:27 GMT+0000 (Coordinated Universal Time)'

0 commit comments

Comments
 (0)