[Rust-Axum] Support Server-Sent Events (SSE)
Merged
LI
6mo ago+2199+2199+0123456789012345678901234567890123456789-473-473-012345678901234567890123456789
Support Server-Sent Events (SSE). Relates PR: https://github.com/OpenAPITools/openapi-generator/pull/22095
cc @wing328 @jacob-mink-1996 @sombrerosheep for review. So sorry that I haven't had enough bandwidth for this feature. Hope that my PR still helpful to you.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*.
IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Summary by cubic
Add Server-Sent Events (SSE) support to the Rust axum server generator, enabling streaming responses for text/event-stream. Introduces a models::SSE type and updates templates and samples; non-SSE endpoints are unaffected.
-
New Features
- Detects
text/event-streamand generates SSE-aware response enums and handlers with the correctContent-Type. - Adds
models::SSEalias (pinnedStreamofaxum::response::sse::Event) for handler return types. - Updates
response.mustache,server-operation.mustache, and the Java generator to wire streaming bodies; adds arust-axum-ssesample, test spec, and manual config. - Refactors response building to create the builder inside match arms, preparing for streaming.
- Detects
-
Dependencies
- Adds
futures-util = "0.3"inCargo.mustacheand regenerates samples.
- Adds