通过 websocket 为聊天服务器大摇大摆?

Swagger for a chat server over a websocket?

我想编写一个具有聊天服务器组件的网络应用程序。我将在我的主要 REST API 中使用 swagger,但我也想在 websocket 上对聊天服务器使用类似的东西。我真的在寻找 serialisation/deserialisation 消息、消息验证、传输等。即所有无聊的东西。

是否可以为此使用 swagger,或者人们可以提出其他可能对我有帮助的建议吗?目前聊天服务器是基于 redis 自制的,但我 可能 切换到 ejabberd 或其他东西,如果我能找到满足我需要的东西的话。

答案是否定的。 Swagger 为您提供了一个约定,用于记录您的 API 未实现它。

根据官方文档:

The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.

这意味着 swagger 本身用于构建和可视化 API 文档。

然而,您要找的不是 API 文档工具。您可以使用 Smack 等 XMPP 协议库来实现您的目标。看这里:http://www.igniterealtime.org/projects/smack/