Skip to content

[Bug]: Generated .NET client methods do not compile when using @convenientAPI(foo, false) with operations that have enum query parameters #8919

@joseharriaga

Description

@joseharriaga

Describe the bug

Generated .NET client methods do not compile when using @convenientAPI(foo, false) with operations that have enum query parameters. The problem is that the corresponding protocol method is generated with an enum parameter, but the enum itself is not generated. I suspect other non-body parameter might have a similar issue.

Reproduction

I have the following TypeSpec. The important detail here is the include query parameter, which is an enum.

op getConversationItem(
  @path
  conversation_id: string,

  @path
  item_id: string,

  @query(#{ explode: true })
  include?: IncludeEnum[],
): ItemResource;

Here is the IncludeEnum definition:

enum IncludeEnum {
  `file_search_call.results`,
  `web_search_call.results`,
  `web_search_call.action.sources`,
  `message.input_image.image_url`,
  `computer_call_output.output.image_url`,
  `code_interpreter_call.outputs`,
  `reasoning.encrypted_content`,
  `message.output_text.logprobs`,
}

If I then use @@convenientAPI(getConversationItem, false); in client.tsp, the following C# method is generated:

public virtual ClientResult GetConversationItem(
    string conversationId,
    string itemId,
    IEnumerable<IncludeEnum> include = null,
    RequestOptions options = null);

This looks correct to me. However, the issue is that the IncludeEnum type is not generated (i.e., it does not exist), so the above fails to compile.

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingemitter: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