Skip to content

[feature]: Support per-request multipart filenames #77

Description

@adriendellagaspera

Use case

The generated client supports typed multipart requests, but callers cannot specify filenames for binary parts.

Some APIs require a filename in the Content-Disposition header. A request may also contain several binary fields with different filenames.

This metadata belongs to the request, not to the shared HttpClient.

Area

Generated HTTP or SSE client

Representative OpenAPI fragment

openapi: 3.1.0
info:
  title: Multipart example
  version: 1.0.0
paths:
  /uploads:
    post:
      operationId: createUpload
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [document]
              properties:
                document:
                  type: string
                  format: binary
                attachment:
                  type: string
                  format: binary
      responses:
        "204":
          description: Uploaded

Desired generated API or behavior

Allow optional, per-request filename overrides for individual binary fields, keyed by their OpenAPI wire names.

The existing generated method should keep its current behavior. An additive method accepting filename overrides would work, but the exact API is open for discussion.

Multiple binary fields should support independent filenames. Concurrent requests should not share mutable filename state, and generated method names must remain collision-safe.

A candidate implementation with a generic fixture is available here:
adriendellagaspera#2

Alternatives considered

Storing filenames on HttpClient introduces shared mutable state for request-specific metadata.

Having callers construct reqwest::multipart::Form manually bypasses the generated typed request API.

Adding filename fields to generated request models is another option, but would mix transport metadata with the request schema. An additive method would leave existing models and calls unchanged.

Compatibility

  • I considered whether this changes existing generated Rust APIs or wire behavior.
  • I searched existing issues and discussions for this request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions