OpenAPITools / OpenAPITools/openapi-generator

[BUG] Rust wasm32-unknown-unknown build is broken with 7.15.0

Open
#21,813 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The new async file stream support for reqwest client breaks the WASM build.

  • supportAsync=true (default) implies vendorExtensions.useAsyncFileStream=true, it will add tokio as a dependency with features incompatible with WASM
  • supportAsync=false, 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 essentially 100% broken on 7.15.0.

openapi-generator version

7.15.0

OpenAPI declaration file content or url
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
Generation Details
java ${JAVA_OPTS} -jar ${CODEGEN} generate -i \"${INPUT_FILE}\" \
        -g ${lang} \
        -o ${TMP_PATH} \
        --additional-properties=packageName=gltf_live_client_sdk \
        --additional-properties=publishRustRegistry=false \
        --additional-properties=library=reqwest \
        --additional-properties=avoidBoxedModels=true
Steps to reproduce
  1. Generate the Rust client code
  2. Attempt to build for wasm32-unknown-unknown
Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/21771

Suggest a fix

useAsyncFileStream should be a Cargo feature

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the generated Rust reqwest client build for wasm32-unknown-unknown using the OpenAPI declaration and generation details in the issue. Review related PR 21771 and the handling of supportAsync and vendorExtensions.useAsyncFileStream; done means the generated client builds for WASM without incompatible tokio or reqwest blocking features, with useAsyncFileStream controlled as a Cargo feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rust, wasm
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.