Skip to content

[http-client-csharp] Non-multipart operations place contentType header before body, violating .NET parameter ordering guideline #10344

@ShivangiReja

Description

@ShivangiReja

Per the .NET SDK parameter ordering guideline, the prescribed order is:

  1. Required Path
  2. Required Query/Header
  3. Body
  4. ContentType
  5. Optional Query/Header
  6. Request Context

For multipart operations, the generator correctly produces (path, body, contentType, options). But for non-multipart operations with a @header contentType union, it produces (path, contentType, body, options) — placing contentType before body.

Example:

op UpdateSkillDefaultVersion(
  @path skill_id: string,
  @header contentType: "application/json" | "application/x-www-form-urlencoded",
  @body body: SetDefaultSkillVersionBody,
): SkillResource;

Generated (current — incorrect):

UpdateSkillDefaultVersion(string skillId, string contentType, BinaryContent content, RequestOptions options = null)

Expected (per guideline):

UpdateSkillDefaultVersion(string skillId, BinaryContent content, string contentType, RequestOptions options = null)

The multipart variant already generates the correct order: (skillId, content, contentType, options). The fix should apply the same body-before-contentType ordering to non-multipart operations as well.

For your reference, here's the generated operation for non multipart operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    emitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions