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

No support for 204 responses #274

Open
kornysietsma opened this issue Feb 27, 2024 · 0 comments
Open

No support for 204 responses #274

kornysietsma opened this issue Feb 27, 2024 · 0 comments

Comments

@kornysietsma
Copy link

204 response types are not exposed in the generated API, even if they are in the OpenAPI schema. This is surprising as 4xx errors are clearly exposed - at minimum it'd be good for the generated client to give some indication to users that they should handle 204 as a possible response type.

Also a 204 without content is handled a bit ungracefully - we get an AxiosError: maxContentLength size of -1 exceeded error - (actually this might be an Axios bug - axios/axios#5286 )

UPDATE: half way through writing this I found ecyrbe/zodios#307 marked as 'wontfix' :(

This might be a showstopper for us - we have quite a few existing services that return 204 responses, rightly or wrongly!

So possibly the only fix might be to add this to the README to save people time who have this need. (and we will try typed-openapi and an alternative fetcher )

Minimal reproduction

openapi: 3.0.1
info:
  title: sample
  version: '1.0'
paths:
  /api/FooBar:
    get:
      parameters:
        - name: thingy
          in: query
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  fooId:
                    type: string
                additionalProperties: false
        '204':
          description: No Content

Expected behavior
A client which might return 204 would return an .optional() schema so it was clear to developers that they need to handle 204 responses (though we'd also need a way to identify that the response was not a 200)
(also this might not work still due to axios/axios#5286 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant