Skip to content

Handling 204 response codes #1410

Closed
@darrelmiller

Description

Where an OpenAPI operation only includes 204 in its successful responses, the generated method should be declared to effectively return void.

'/DoTheThing':
    POST:
      responses:
        '204':
          description: An empty response
      x-csharp: Task DoTheThing.PostAsync(...);    

If at runtime, the server returns a different 2XX with a body, then we should read the body and then discard it. Failing to read the body will hang the server.

When a operation is expected to return a value, but instead returns a 204 at runtime (whether described or not), the returned value should be null.

'/nullableSimpleObject':
    get:
      responses:
        '200':
          description: A response with an object type response
          content: { "application/json": { schema: { $ref: "#/components/schemas/simpleObject" }}}
        '204':
          description: A response with an object type but with null value
      x-csharp: Task<SimpleObject> GetAsync(...);    

Metadata

Assignees

Labels

enhancementNew feature or requestfixedgeneratorIssues or improvements relater to generation capabilities.

Type

No type

Projects

  • Status

    Done ✔️

Relationships

None yet

Development

No branches or pull requests

Issue actions