OpenAPITools / OpenAPITools/openapi-generator

[csharp] Multiple response types not supported

Open
#1,562 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When multiple responses are present in a v3 OpenAPI document with differing types, only the first one is respected when C# client SDK is generated.

openapi-generator version

3.3.3

OpenAPI declaration file content or url
  /my/api/path:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
                  format: byte
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.OpenApi.Services.AutoRestService.ServiceFault'
Command line used for generation

openapi-generator generate -g csharp -i .\openapi.json -o .\output

Related issues/PRs

I see similar issues for other languages, but perhaps C# isn't enhanced yet?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI declaration and the openapi-generator generate -g csharp command, then trace how the C# generator handles multiple response schemas. Done means the generated client represents both the 200 array response and the 202 ServiceFault response instead of respecting only the first response.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.