OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.52k stars 6.51k forks source link

[csharp] Multiple response types not supported #1562

Open scott-lin opened 5 years ago

scott-lin commented 5 years ago
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?

jimschubert commented 5 years ago

@scott-lin sorry for taking so long to triage the issues/PRs. I'm just now finding free time after moving into my first new home.

Would you be able to provide an example of how you'd expect to see such a method with multiple possible return types defined? I have an idea or two, but they'd be borrowed from Scala and may not be ideal for C#.

For the PHP example you've linked, it's a different beast because that's technically a dynamic language, so I unfortunately couldn't model after that approach unless the return type was Object.