Skip to content

docs(api-server): /ws WebSocket endpoint is missing from the OpenAPI/Swagger spec #1164

Description

@Maki-Zeninn

Description

api-server/src/main.rs's ApiDoc (lines 33-61) declares the OpenAPI spec surfaced at /openapi.json and Swagger UI at /docs:

#[derive(OpenApi)]
#[openapi(
    paths(
        crate::handlers::health,
        crate::handlers::simulate,
        crate::handlers::list_routes,
        crate::handlers::get_route,
    ),
    ...
)]
struct ApiDoc;

The router registers five routes (lines 138-142): /health, /simulate, /routes, /routes/:name, and /ws. Only the first four appear in paths(...); websocket::ws_handler (websocket.rs line 23) — the /ws route — has no #[utoipa::path(...)] annotation and is absent from ApiDoc.

Impact

Anyone browsing the generated Swagger UI (/docs) or openapi.json has no indication that a /ws WebSocket endpoint exists at all, let alone how to use it (the SubscribeMessage/{"action":"subscribe","tx_id":...} protocol, or the status_update/subscribed/error message shapes sent back). It's the only route in the server with zero API documentation.

Suggested fix

Add a #[utoipa::path(get, path = "/ws", ...)] annotation on ws_handler describing it as a WebSocket upgrade endpoint (utoipa supports documenting such endpoints as a plain GET for discovery purposes even though the protocol switch itself isn't representable in OpenAPI), include it in ApiDoc's paths(...), and add SubscribeMessage to components(schemas(...)) (note: SubscribeMessage doesn't currently derive ToSchema either — see types.rs lines 170-174 — so that would need adding too) so the subscribe/unsubscribe message shape is documented alongside the endpoint.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions