Open Phanabani opened 2 years ago
I'm planning to change the implementation by the end of August.
Thanks for reporting this. 🙏
That sounds great, thank you! 😊
Here is a minimal example in case it can help you in the future:
from fastapi import FastAPI, HTTPException, status
from fastapi_responses import custom_openapi
app = FastAPI(title="Test fastapi_responses with status constants")
app.openapi = custom_openapi(app)
@app.get("/uses_int")
def uses_int():
if True:
raise HTTPException(404, "ERROR MESSAGE HERE")
return "Hi there"
@app.get("/uses_status_constant")
def uses_status_constant():
if True:
raise HTTPException(status.HTTP_404_NOT_FOUND, "ERROR MESSAGE HERE")
return "Hi there"
Hi there!
Thanks for this library, it looks like exactly what I need!
In my project, I'm using
fastapi.status
constants to make it clearer what the status codes are doing. Unfortunately, this library doesn't recognize those constants, onlyint
literals.It looks like @prawalgangwar started work on this in #10, and this could potentially be fixed by the proposed AST migration in #8, but I figured I'd make an issue here to make it known that this would be helpful!