Skip to content

Commit

Permalink
Switch UI codegen to fastAPI spec (apache#42222)
Browse files Browse the repository at this point in the history
* Switch Ui codegen to fastAPI spec

* Rebase

* read access control from config

---------

Co-authored-by: pierrejeambrun <[email protected]>
  • Loading branch information
bbovenzi and pierrejeambrun authored Sep 20, 2024
1 parent a083930 commit 178503a
Show file tree
Hide file tree
Showing 13 changed files with 511 additions and 23,008 deletions.
16 changes: 16 additions & 0 deletions airflow/api_fastapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from airflow.www.extensions.init_dagbag import get_dag_bag

Expand All @@ -33,6 +34,8 @@ def init_dag_bag(app: FastAPI) -> None:


def create_app() -> FastAPI:
from airflow.configuration import conf

app = FastAPI(
description="Airflow API. All endpoints located under ``/public`` can be used safely, are stable and backward compatible. "
"Endpoints located under ``/ui`` are dedicated to the UI and are subject to breaking change "
Expand All @@ -43,6 +46,19 @@ def create_app() -> FastAPI:

init_views(app)

allow_origins = conf.getlist("api", "access_control_allow_origins")
allow_methods = conf.getlist("api", "access_control_allow_methods")
allow_headers = conf.getlist("api", "access_control_allow_headers")

if allow_origins or allow_methods or allow_headers:
app.add_middleware(
CORSMiddleware,
allow_origins=allow_origins,
allow_credentials=True,
allow_methods=allow_methods,
allow_headers=allow_headers,
)

return app


Expand Down
Loading

0 comments on commit 178503a

Please sign in to comment.