Skip to content

[feature]: Expose multiple response representations and live binary streams #78

Description

@adriendellagaspera

Use case

An OpenAPI operation can declare several successful response media types, such as JSON, SSE and binary.

The generated HTTP client selects a preferred representation, so other declared representations may not be accessible through the generated operation.

Binary responses also need two consumption modes: buffered and live streaming.

Area

Generated HTTP or SSE client

Representative OpenAPI fragment

openapi: 3.1.0
info:
  title: Response representations example
  version: 1.0.0
paths:
  /render:
    post:
      operationId: render
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
            text/event-stream:
              schema:
                type: string
            application/octet-stream:
              schema:
                type: string
                format: binary

Desired generated API or behavior

Expose the supported response representations through distinct generated call shapes.

Preserve existing buffered methods and the current SSE transport. Add live binary streaming without buffering the full successful response body.

Generated methods should share the same source operation identity and parameter planning, while keeping response representation identity independent of Rust method names.

The exact generated API and streaming return types are open for discussion.

Alternatives considered

Keeping only the preferred representation leaves other declared response modes inaccessible through the generated client.

Always buffering binary responses prevents incremental consumption of large downloads.

Reconstructing requests manually duplicates generated authentication, parameter serialization and error handling.

Replacing the existing SSE transport with a raw byte stream would lose its event parsing and reconnection behavior. This proposal should build on that transport, not replace it.

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