Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling 204 response codes #1410

Closed
Tracked by #1049
darrelmiller opened this issue Mar 18, 2022 · 1 comment · Fixed by #1457
Closed
Tracked by #1049

Handling 204 response codes #1410

darrelmiller opened this issue Mar 18, 2022 · 1 comment · Fixed by #1457
Assignees
Labels
enhancement New feature or request fixed generator Issues or improvements relater to generation capabilities.

Comments

@darrelmiller
Copy link
Member

darrelmiller commented Mar 18, 2022

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(...);    
@darrelmiller darrelmiller added enhancement New feature or request generator Issues or improvements relater to generation capabilities. labels Mar 18, 2022
@baywet baywet added this to Kiota Mar 18, 2022
@baywet baywet moved this to Todo in Kiota Mar 18, 2022
@baywet baywet added this to the Community Preview milestone Mar 18, 2022
@baywet baywet moved this from Todo to In Progress in Kiota Mar 28, 2022
@baywet baywet added the fixed label Mar 28, 2022
@baywet
Copy link
Member

baywet commented Mar 28, 2022

fixed with #1457 and other pull requests. interestingly enough Java requires you to close the response but not to read it. Dotnet and Go to read and close. JavaScript to read without closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed generator Issues or improvements relater to generation capabilities.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants