Get the list of missed responses
Is it possible to get a list of missed responses for my app? I don't want to automatically add responses. I want to just to see the list of missed ones
@app.get("/{item_id}")
def get_item(item_id: str):
if not item_exist(item_id):
raise HTTPException(404, "Item not found")
return 42
Output:
Missing responses:
@app.get("/{item_id}")
- 404, Item not found
I don't want to automatically add responses. I want to just to see the list of missed ones
Hmm I see, that's a cool use case. How about on cli, I do something like:
richapi output src.app:app --router "items/{item_id}" Or even router name;
richapi output src.app:app get_item
Hey @theonlykingpin
Can you check that PR and lmk if that solves your use case?
If you want to limit the search of exceptions to specific functions, you can pass the list of functions to the find_exceptions_in_api_functions function.
from richapi import find_exceptions_in_api_functions, BaseHTTPException
from fastapi import FastAPI
app = FastAPI()
class NotFoundException(BaseHTTPException):
status_code = 404
detail: str = "Item not found"
@app.get("/items/{item_id}")
async def read_item(item_id: int):
if item_id != 42:
raise NotFoundException()
return {"item_id": item_id}
exceptions = find_exceptions_in_api_functions(funcs=[read_item], fastapi_app=app)
print(exceptions) # {NotFoundException}
I could of also do the comparsion, but i developed a more general use case function so that would leave it to developer how they want to use the output of this function.