elysiajs / elysia-swagger

A plugin for Elysia to auto-generate Swagger page
MIT License
84 stars 45 forks source link

how to add documentation for websocket routes #22

Open enesflow opened 1 year ago

enesflow commented 1 year ago

app.ws() doesnt seem to have the detail property and all the websocket routes are generated as if they are a GET route

MeowningMaster commented 8 months ago

because it's a get request which upgrades to websocket connection. OpenApi specification doesn't support websockets

you can use separate AsyncApi spec

jonasfroeller commented 5 months ago

.ws routes do not even end up in the documentation at all in my app. I am using elysiajs 1.0.13 and @elysiajs/swagger 1.0.3.

This is what ends up in the path property of the openapi config:

/v1/chat/{monitor-id}: {
$internalws: {
operationId: "$internalwsV1ChatByMonitor-id",
parameters: [
{
schema: {
type: "string"
},
in: "path",
name: "monitor-id",
required: true
}
],
responses: {
200: { }
}
}
},
marclave commented 5 months ago

hey @jonasfroeller OpenAPI is specific for REST based APIs

https://www.asyncapi.com/en

AsyncAPI is event driven APIs! I wonder if we should do an additional integration for AsyncAPI? and merge the two documents somehow. Honestly, something I've been thinking a lot about is having @scalar support both AsyncAPI + OpenAPI in one interface 🤔 maybe we should make this a higher priority!