Skip to content

docs(api-server): add /ws WebSocket endpoint + SubscribeMessage to OpenAPI (#1164) - #1240

Open
gebibd00-jpg wants to merge 1 commit into
Maki-Zeninn:mainfrom
gebibd00-jpg:docs/add-ws-to-openapi
Open

docs(api-server): add /ws WebSocket endpoint + SubscribeMessage to OpenAPI (#1164)#1240
gebibd00-jpg wants to merge 1 commit into
Maki-Zeninn:mainfrom
gebibd00-jpg:docs/add-ws-to-openapi

Conversation

@gebibd00-jpg

Copy link
Copy Markdown
Contributor

Summary

The router registers five routes (/health, /simulate, /routes, /routes/:name, /ws), but only the first four appear in the utoipa-derived OpenAPI spec surfaced at /openapi.json and the Swagger UI at /docs. websocket::ws_handler had no #[utoipa::path(...)] annotation, and SubscribeMessage (the JSON shape clients send to subscribe to a tx_id on /ws) did not derive ToSchema. Anyone browsing the generated docs has no indication that /ws exists, let alone how to use it.

Fix

  • ws_handler gains a #[utoipa::path(get, path = "/ws", ...)] annotation documenting the upgrade (utoipa represents protocol upgrades as a plain GET for discovery).
  • SubscribeMessage (types.rs) now derives ToSchema and gets per-field doc comments explaining the action ("subscribe" / "unsubscribe") and tx_id fields.
  • ApiDoc (main.rs) lists crate::websocket::ws_handler in paths(...) and crate::types::SubscribeMessage in components(schemas(...)).

No behavior change. The handler and protocol are unchanged; the change is purely about surfacing them in the generated spec.

I do not have a local Rust toolchain on this machine, so I could not run cargo test myself, but the diff is annotation-only and ToSchema derive on a simple Clone + Serialize + Deserialize struct — please run the test suite on a Soroban environment before merging.

Closes

#1164

…enAPI (Maki-Zeninn#1164)

The router registers five routes (`/health`, `/simulate`, `/routes`,
`/routes/:name`, `/ws`), but only the first four appear in the
utoipa-derived OpenAPI spec surfaced at `/openapi.json` and the
Swagger UI at `/docs`. `websocket::ws_handler` had no
`#[utoipa::path(...)]` annotation, and `SubscribeMessage` (the
JSON shape clients send to subscribe to a `tx_id` on `/ws`) did
not derive `ToSchema`. Anyone browsing the generated docs has no
indication that `/ws` exists, let alone how to use it.

Fix:

- `ws_handler` gains a `#[utoipa::path(get, path = "/ws", ...)]`
  annotation documenting the upgrade (utoipa represents protocol
  upgrades as a plain `GET` for discovery).
- `SubscribeMessage` (types.rs) now derives `ToSchema` and gets
  per-field doc comments explaining the `action` (`"subscribe"`
  / `"unsubscribe"`) and `tx_id` fields.
- `ApiDoc` (main.rs) lists `crate::websocket::ws_handler` in
  `paths(...)` and `crate::types::SubscribeMessage` in
  `components(schemas(...))`.

No behavior change. The handler and protocol are unchanged; the
change is purely about surfacing them in the generated spec.

I do not have a local Rust toolchain on this machine, so I could
not run `cargo test` myself, but the diff is annotation-only and
`ToSchema` derive on a simple `Clone + Serialize + Deserialize`
struct — please run the test suite on a Soroban environment
before merging.

Closes Maki-Zeninn#1164.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant