Skip to content

fix(openapi): exclude WebSocket routes from /openapi.json - #18

Merged
magi8101 merged 1 commit into
mainfrom
fix/websocket-routes-in-openapi-docs
Sep 6, 2026
Merged

magi8101 merged 1 commit into
mainfrom
fix/websocket-routes-in-openapi-docs

Conversation

@magi8101

@magi8101 magi8101 commented Sep 6, 2026

Copy link
Copy Markdown
Member

Found while adding a websocket feature to a real app. The docs handler's router._registered walk (from #10) does setattr(path_item, "websocket", op) for WEBSOCKET-method routes, but PathItem has no "websocket" field — that silently created a dangling attribute to_dict() never serializes, leaving the path in the schema as an empty, spec-invalid {} Path Item Object.

OpenAPI 3.x has no operation concept for WebSocket, so exclusion is the correct fix. Added a regression test. 253/253 tests, mypy clean, ruff clean.

Found while adding a websocket feature to a real app on velocix. The docs
handler's router._registered walk (added in #10) didn't distinguish
WEBSOCKET from HTTP methods, so it did setattr(path_item, "websocket", op)
-- but PathItem has no such field, so that silently created a dangling
attribute to_dict() never serializes. The path stayed in the schema with
an empty, spec-invalid {} Path Item Object instead of being left out.

OpenAPI 3.x has no operation concept for WebSocket at all, so the
correct fix is exclusion, not trying to represent it. Added a regression
test. 253/253 tests, mypy clean, ruff clean.
Copilot AI lite review requested due to automatic review settings September 6, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@magi8101
magi8101 merged commit dfd804e into main Sep 6, 2026
2 checks passed
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.

2 participants