Skip to content

Implement smarter media type selection for request content #386

@fredbi

Description

@fredbi

Source Location

File: client/runtime.go
Line: 535
Function: func (r *Runtime) Submit(operation *ClientOperation) (any, *http.Response, error)

Context

This is in the request submission logic. Currently it picks the first non-empty media type from operation.ConsumesMediaTypes, falling back to DefaultMediaType.

Analysis

The current selection is simplistic - it just takes the first available. A smarter approach would:

  • Consider content negotiation based on what's being sent
  • Match producer capabilities with declared media types
  • Potentially prefer certain types (e.g., JSON over XML) when multiple are available
  • Consider the payload type to pick the most appropriate serialization

Original Comment

// TODO: pick appropriate media type

This issue was created to track a TODO comment in the codebase.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions