Skip to content

bug: preserve and use OpenAPI request body media types #19

@samzong

Description

@samzong

Problem

OpenAPI 3 request bodies that are not application/json lose their media type during parsing, and runtime request execution still sends file or set bodies as JSON. That makes generated commands incorrect for text/plain, application/xml, and other non-JSON request bodies.

Evidence

  • internal/codegen/backends/openapi3/backend.go sets RequestBody.MediaType only for application/json.
  • In the non-JSON branch, it sorts content types and keeps the schema but does not store the chosen media type.
  • The existing request-body-non-json golden fixture shows a text/plain / application/xml OpenAPI input producing a RequestBody with no MediaType.
  • pkg/runtime/client.go sets Content-Type: application/json for raw []byte bodies, which is what --file and --set currently produce.

Expected behavior

Codegen should preserve the selected request body media type in CommandSpec.RequestBody.MediaType, and runtime should send that as Content-Type. If a media type is unsupported by the current body builders, command execution should fail clearly instead of silently sending JSON.

Verification

make test currently passes; the existing golden fixture documents the current lossy behavior rather than rejecting it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions