Skip to content
Advertisement

What is the best way to document websocket messages in Aiohttp/Python?

I use aiohttp-swagger to create useful documentation of my http endpoints, but I also have websocket which can send/receive several types of messages (all json for the project), what is the best way to document these messages?

Advertisement

Answer

AsyncAPI is the analog of the OpenAPI Specification (fka Swagger Specification) for WebSockets.

As of November 2021 there are the Asynction and Python AsyncAPI projects that let you use AsyncAPI in Python.

You can also write an AsyncAPI definition (YAML or JSON file) for your WebSocket messages manually and display this documentation using one of the doc renderers.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement