[Rust-Axum] Support Server-Sent Events (SSE)

Merged
LI
6mo ago
+2199-473

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:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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-stream and generates SSE-aware response enums and handlers with the correct Content-Type.
    • Adds models::SSE alias (pinned Stream of axum::response::sse::Event) for handler return types.
    • Updates response.mustache, server-operation.mustache, and the Java generator to wire streaming bodies; adds a rust-axum-sse sample, test spec, and manual config.
    • Refactors response building to create the builder inside match arms, preparing for streaming.
  • Dependencies

    • Adds futures-util = "0.3" in Cargo.mustache and regenerates samples.