-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
MRE
@depends
def with_test():
pass
@app.get("/test", status_code=status.HTTP_204_NO_CONTENT)
@with_test
async def test() -> None:
passError:
File ".venv\Lib\site-packages\fastapi\routing.py", line 757, in __init__
assert is_body_allowed_for_status_code(status_code), (
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
AssertionError: Status code 204 must not have a response body
adding a print statement just before this assertion shows,
print(self, self.response_model)APIRoute(path='/test', name='test', methods=['GET']) <class 'NoneType'>
Expected
APIRoute(path='/test', name='test', methods=['GET']) None
Concerned Code:
fastapi-decorators/fastapi_decorators/decorators.py
Lines 83 to 86 in fc37cb7
| new_signature = original_signature.replace( | |
| parameters=tuple(all_params.values()), | |
| return_annotation=hints.get("return", original_signature.return_annotation), | |
| ) |
Possible Fix
new_signature = original_signature.replace(
parameters=tuple(all_params.values()),
return_annotation=original_signature.return_annotation,
)
Workaround
@depends
def with_test():
pass
@router.get("/test", status_code=status.HTTP_204_NO_CONTENT, response_model=None)
@with_test
async def test() -> None:
passor
@depends
def with_test():
pass
@router.get("/test", status_code=status.HTTP_204_NO_CONTENT)
@with_test
async def test():
pass
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels