pierrejeambrun commented on code in PR #42508:
URL: https://github.com/apache/airflow/pull/42508#discussion_r1778307520


##########
airflow/api_fastapi/views/public/dags.py:
##########
@@ -71,16 +72,13 @@ async def get_dags(
 
     dags = session.scalars(dags_query).all()
 
-    try:
-        return DAGCollectionResponse(
-            dags=[DAGResponse.model_validate(dag, from_attributes=True) for 
dag in dags],
-            total_entries=total_entries,
-        )
-    except ValueError as e:
-        raise HTTPException(400, f"DAGCollectionSchema error: {str(e)}")
+    return DAGCollectionResponse(
+        dags=[DAGResponse.model_validate(dag, from_attributes=True) for dag in 
dags],
+        total_entries=total_entries,
+    )
 
 
-@dags_router.patch("/dags/{dag_id}")
+@dags_router.patch("/dags/{dag_id}", 
responses=create_openapi_http_exception_doc([400, 401, 403, 404]))

Review Comment:
   I mean the `responses` field is supported and we can document them, but 
without this utility function that would be a lot of manual and duplicated 
typing.
   
   FastAPI does not automatically detect and document HTTPExceptions, so yes 
definitely missing from FastAPI. This discussions 
https://github.com/fastapi/fastapi/discussions/9124#discussioncomment-8571860 
explains it well I think.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to