fastapi_client icon indicating copy to clipboard operation
fastapi_client copied to clipboard

Missing status code 204 support.

Open myheartsgoon opened this issue 3 years ago • 0 comments

There is no 204 status code support in api_client.py, which will cause issue when status code is 204 like set_assignee api etc.

Current Code

async def send(self, request: Request, type_: Type[T]) -> T:
  response = await self.middleware(request, self.send_inner)
  if response.status_code in [200, 201]:
      try:
          return parse_obj_as(type_, response.json())
      except ValidationError as e:
          raise ResponseHandlingException(e)
  raise UnexpectedResponse.for_response(response)

Issue:

Exception raised when 204 returned.

Unexpected Response: 204 (Unrecognized Status Code)

Current resolution:

We manually added 204 support as below to avoid exception.

if response.status_code == 204:
    return response

myheartsgoon avatar Jun 29 '21 01:06 myheartsgoon