File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
src/fastapi_problem_details Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ def init_app(
1717 validation_error_detail : str = "Request validation failed" ,
1818 include_exc_info_in_response : bool = False ,
1919) -> FastAPI :
20- app .router .responses .setdefault ("default" , {"model" : Problem })
20+ app .router .responses .setdefault (
21+ "default" ,
22+ {
23+ "description" : "Problem" ,
24+ "content" : {
25+ "application/problem+json" : {"schema" : Problem .model_json_schema ()}
26+ },
27+ },
28+ )
2129
2230 @app .exception_handler (RequestValidationError )
2331 async def handle_validation_error (
Original file line number Diff line number Diff line change @@ -56,7 +56,15 @@ def test_init_app_register_problem_details_as_default_response() -> None:
5656 # When
5757 problem .init_app (app )
5858 # Then
59- assert ("default" , {"model" : Problem }) in app .router .responses .items ()
59+ assert (
60+ "default" ,
61+ {
62+ "description" : "Problem" ,
63+ "content" : {
64+ "application/problem+json" : {"schema" : Problem .model_json_schema ()}
65+ },
66+ },
67+ ) in app .router .responses .items ()
6068
6169
6270class TestValidationError :
You can’t perform that action at this time.
0 commit comments