-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AIP-84 Add HTTPException openapi documentation #42508
base: main
Are you sure you want to change the base?
AIP-84 Add HTTPException openapi documentation #42508
Conversation
pierrejeambrun
commented
Sep 26, 2024
•
edited
Loading
edited
cc: @jscheffl This will take care of adding the necessary documentation of possible errors to the openapi spec. |
|
||
|
||
@dags_router.patch("/dags/{dag_id}") | ||
@dags_router.patch("/dags/{dag_id}", responses=create_openapi_http_exception_doc([400, 401, 403, 404])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we tell FastAPI the possible error code returned by the endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that this is not natively supported. Was it that our previous approach was not according to design of FastAPI or is this missin gin the copcepts?
cb5bf69
to
f616187
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some sanity questions (mainly for validation and to double check, not blocking if answered positive) - resulting API spec looks as expected. Thanks.
Wondering though that the exceptions/error response codes are not handled natively.
Also wondering a bit where are the exceptions mapped to error codes?
details: str | dict | ||
|
||
|
||
ValidationError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? A copy&paste leftover?
|
||
|
||
@dags_router.patch("/dags/{dag_id}") | ||
@dags_router.patch("/dags/{dag_id}", responses=create_openapi_http_exception_doc([400, 401, 403, 404])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that this is not natively supported. Was it that our previous approach was not according to design of FastAPI or is this missin gin the copcepts?
dags=[DAGResponse.model_validate(dag, from_attributes=True) for dag in dags], | ||
total_entries=total_entries, | ||
) | ||
except ValueError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ValueError
Handled by FastAPI out-of-the-box and added to api specs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is a serializer needed and where is this used/imported?
Seems to be 100% redundant to airflow.api_fastapi.openapi.exceptions.HTTPExceptionResponse
- could we just import or inherit this?