docs(api-server): add /ws WebSocket endpoint + SubscribeMessage to OpenAPI (#1164) - #1240
Open
gebibd00-jpg wants to merge 1 commit into
Open
docs(api-server): add /ws WebSocket endpoint + SubscribeMessage to OpenAPI (#1164)#1240gebibd00-jpg wants to merge 1 commit into
gebibd00-jpg wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonand the Swagger UI at/docs.websocket::ws_handlerhad no#[utoipa::path(...)]annotation, andSubscribeMessage(the JSON shape clients send to subscribe to atx_idon/ws) did not deriveToSchema. Anyone browsing the generated docs has no indication that/wsexists, let alone how to use it.Fix
ws_handlergains a#[utoipa::path(get, path = "/ws", ...)]annotation documenting the upgrade (utoipa represents protocol upgrades as a plainGETfor discovery).SubscribeMessage(types.rs) now derivesToSchemaand gets per-field doc comments explaining theaction("subscribe"/"unsubscribe") andtx_idfields.ApiDoc(main.rs) listscrate::websocket::ws_handlerinpaths(...)andcrate::types::SubscribeMessageincomponents(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 testmyself, but the diff is annotation-only andToSchemaderive on a simpleClone + Serialize + Deserializestruct — please run the test suite on a Soroban environment before merging.Closes
#1164