Skip to content

[Rust ]Add async file stream support for reqwest client#21771

Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom
andershausding:master
Aug 22, 2025
Merged

[Rust ]Add async file stream support for reqwest client#21771
wing328 merged 1 commit intoOpenAPITools:masterfrom
andershausding:master

Conversation

@andershausding
Copy link
Contributor

This PR adds the missing capability for single file inputstreams in the request body, for example used by the /libpod/volumes/{name}/import API from Podman. Ive added a sample and a minimal yaml below for an api using this feature.

swagger: "2.0"
info:
  title: File Streaming Test API
  version: 1.0.0

paths:
    /upload:
      post:
        consumes:
            - application/octet-stream
        description: Upload a file from the local filesystem
        operationId: uploadFile
        parameters:
          - description: A test file
            in: body
            name: inputStream
            schema:
              format: binary
              type: string
        responses:
          '200':
            description: Success

@frol @farcaller @richardwhiuk @paladinzh @jacob-pro @dsteeley @wing328

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • 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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Aug 22, 2025

thanks for the pr

tested locally to confirm the issue and the fix

$ cargo build
    Updating crates.io index
     Locking 5 packages to latest compatible versions
      Adding futures-io v0.3.31
      Adding futures-macro v0.3.31
      Adding futures-sink v0.3.31
      Adding tokio-util v0.7.16
      Adding wasm-streams v0.4.2
  Downloaded futures-io v0.3.31
  Downloaded futures-sink v0.3.31
  Downloaded futures-macro v0.3.31
  Downloaded slab v0.4.11
  Downloaded tokio-util v0.7.16
  Downloaded 5 crates (170.6KiB) in 0.51s
   Compiling tokio v1.47.1
   Compiling futures-sink v0.3.31
   Compiling hyper v1.7.0
   Compiling tower v0.5.2
   Compiling tokio-util v0.7.16
   Compiling tower-http v0.6.6
   Compiling hyper-util v0.1.16
   Compiling reqwest v0.12.23
   Compiling openapi v1.0.0 (C:\Users\wing3\AppData\Local\Temp\rustasync)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 9.12s

@wing328 wing328 merged commit 2569321 into OpenAPITools:master Aug 22, 2025
20 checks passed
@wing328
Copy link
Member

wing328 commented Aug 22, 2025

PR merged

will add a test or 2 to cover this issue moving forward in another PR

@wing328 wing328 added this to the 7.15.0 milestone Aug 22, 2025
@JMLX42
Copy link
Contributor

JMLX42 commented Aug 25, 2025

@andershausding The new supportAsync option:

  • when turned on (default), it will add tokio as a dependency with features incompatible with WASM
  • when turned off, it will enable the blocking feature of reqwest, which does not build for WASM
error: Only features sync,macros,io-util,rt,time are supported on wasm.
   --> /home/jmlx/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.47.1/src/lib.rs:475:1
    |
475 | compile_error!("Only features sync,macros,io-util,rt,time are supported on wasm.");
    |

So IMHO, essentially, the WASM build is broken on 7.15.

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.

3 participants