fix(openapi): exclude WebSocket routes from /openapi.json - #18
Merged
Merged
Conversation
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.
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.
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.