Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pierrejeambrun
Copy link
Member

@pierrejeambrun pierrejeambrun commented Sep 26, 2024

Screenshot 2024-09-26 at 17 59 56

@pierrejeambrun pierrejeambrun self-assigned this Sep 26, 2024
@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Sep 26, 2024
@pierrejeambrun pierrejeambrun added the AIP-84 Modern Rest API label Sep 26, 2024
@pierrejeambrun
Copy link
Member Author

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]))
Copy link
Member Author

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

Copy link
Contributor

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?

Copy link
Contributor

@jscheffl jscheffl left a 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
Copy link
Contributor

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]))
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ValueErrorHandled by FastAPI out-of-the-box and added to api specs?

Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-84 Modern Rest API area:UI Related to UI/UX. For Frontend Developers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants