This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7d69f2e782c Move enable_swagger_ui config to api (#50896)
7d69f2e782c is described below
commit 7d69f2e782c273ccd0085eae417f3ba7a8436365
Author: Pierre Jeambrun <[email protected]>
AuthorDate: Wed May 21 18:53:14 2025 +0200
Move enable_swagger_ui config to api (#50896)
* Move enable_swagger_ui config to api
* Fix CI
---
.../src/airflow/api_fastapi/core_api/routes/ui/config.py | 8 ++------
airflow-core/src/airflow/cli/commands/config_command.py | 4 ++++
airflow-core/src/airflow/config_templates/config.yml | 14 +++++++-------
airflow-core/src/airflow/configuration.py | 1 +
.../unit/api_fastapi/core_api/routes/ui/test_config.py | 2 +-
providers/fab/src/airflow/providers/fab/www/constants.py | 2 +-
providers/fab/www-hash.txt | 2 +-
7 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/config.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/config.py
index 442f4faa197..4abfe067cb0 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/config.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/config.py
@@ -30,11 +30,9 @@ from airflow.utils.log.log_reader import TaskLogReader
config_router = AirflowRouter(tags=["Config"])
-WEBSERVER_CONFIG_KEYS = [
- "enable_swagger_ui",
-]
API_CONFIG_KEYS = [
+ "enable_swagger_ui",
"hide_paused_dags_by_default",
"page_size",
"default_wrap",
@@ -50,9 +48,7 @@ API_CONFIG_KEYS = [
)
def get_configs() -> ConfigResponse:
"""Get configs for UI."""
- config = {key: conf.get("webserver", key) for key in WEBSERVER_CONFIG_KEYS}
-
- config.update({key: conf.get("api", key) for key in API_CONFIG_KEYS})
+ config = {key: conf.get("api", key) for key in API_CONFIG_KEYS}
task_log_reader = TaskLogReader()
additional_config: dict[str, Any] = {
diff --git a/airflow-core/src/airflow/cli/commands/config_command.py
b/airflow-core/src/airflow/cli/commands/config_command.py
index 77ef371ff12..41f1fe0a7c1 100644
--- a/airflow-core/src/airflow/cli/commands/config_command.py
+++ b/airflow-core/src/airflow/cli/commands/config_command.py
@@ -446,6 +446,10 @@ CONFIGS_CHANGES = [
config=ConfigParameter("webserver", "grid_view_sorting_order"),
renamed_to=ConfigParameter("api", "grid_view_sorting_order"),
),
+ ConfigChange(
+ config=ConfigParameter("webserver", "enable_swagger_ui"),
+ renamed_to=ConfigParameter("api", "enable_swagger_ui"),
+ ),
ConfigChange(
config=ConfigParameter("webserver", "error_logfile"),
was_deprecated=False,
diff --git a/airflow-core/src/airflow/config_templates/config.yml
b/airflow-core/src/airflow/config_templates/config.yml
index 02137117bb6..8adac57d179 100644
--- a/airflow-core/src/airflow/config_templates/config.yml
+++ b/airflow-core/src/airflow/config_templates/config.yml
@@ -1284,6 +1284,13 @@ secrets:
api:
description: ~
options:
+ enable_swagger_ui:
+ description: |
+ Boolean for running SwaggerUI in the webserver.
+ version_added: 2.6.0
+ type: boolean
+ example: ~
+ default: "True"
secret_key:
description: |
Secret key used to run your api server. It should be as random as
possible. However, when running
@@ -1787,13 +1794,6 @@ webserver:
type: string
example: "dagrun_cleared,failed"
default: ~
- enable_swagger_ui:
- description: |
- Boolean for running SwaggerUI in the webserver.
- version_added: 2.6.0
- type: boolean
- example: ~
- default: "True"
email:
description: |
Configuration email backend and whether to
diff --git a/airflow-core/src/airflow/configuration.py
b/airflow-core/src/airflow/configuration.py
index 5ec5bf770a1..bdf642338f5 100644
--- a/airflow-core/src/airflow/configuration.py
+++ b/airflow-core/src/airflow/configuration.py
@@ -363,6 +363,7 @@ class AirflowConfigParser(ConfigParser):
("fab", "navbar_hover_color"): ("webserver", "navbar_hover_color",
"3.0.2"),
("fab", "navbar_text_hover_color"): ("webserver",
"navbar_text_hover_color", "3.0.2"),
("api", "secret_key"): ("webserver", "secret_key", "3.0.2"),
+ ("api", "enable_swagger_ui"): ("webserver", "enable_swagger_ui",
"3.0.2"),
("api", "grid_view_sorting_order"): ("webserver",
"grid_view_sorting_order", "3.1.0"),
("api", "log_fetch_timeout_sec"): ("webserver",
"log_fetch_timeout_sec", "3.1.0"),
("api", "hide_paused_dags_by_default"): ("webserver",
"hide_paused_dags_by_default", "3.1.0"),
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_config.py
b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_config.py
index 622ed577ff0..c2f92e3ca44 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_config.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_config.py
@@ -47,7 +47,7 @@ def mock_config_data():
with conf_vars(
{
("webserver", "instance_name"): "Airflow",
- ("webserver", "enable_swagger_ui"): "true",
+ ("api", "enable_swagger_ui"): "true",
("api", "hide_paused_dags_by_default"): "true",
("api", "page_size"): "100",
("api", "default_wrap"): "false",
diff --git a/providers/fab/src/airflow/providers/fab/www/constants.py
b/providers/fab/src/airflow/providers/fab/www/constants.py
index 263caf1576c..69e1a1965bf 100644
--- a/providers/fab/src/airflow/providers/fab/www/constants.py
+++ b/providers/fab/src/airflow/providers/fab/www/constants.py
@@ -24,5 +24,5 @@ WWW = Path(__file__).resolve().parent
# There is a difference with configuring Swagger in Connexion 2.x and
Connexion 3.x
# Connexion 2:
https://connexion.readthedocs.io/en/2.14.2/quickstart.html#the-swagger-ui-console
# Connexion 3:
https://connexion.readthedocs.io/en/stable/swagger_ui.html#configuring-the-swagger-ui
-SWAGGER_ENABLED = conf.getboolean("webserver", "enable_swagger_ui",
fallback=True)
+SWAGGER_ENABLED = conf.getboolean("api", "enable_swagger_ui", fallback=True)
SWAGGER_BUNDLE = WWW.joinpath("static", "dist", "swagger-ui")
diff --git a/providers/fab/www-hash.txt b/providers/fab/www-hash.txt
index 5ba1e80f4b5..dc232df01d2 100644
--- a/providers/fab/www-hash.txt
+++ b/providers/fab/www-hash.txt
@@ -1 +1 @@
-e6d566ed6f8c2b19eda800f6bb53b2bf7b3ede110978d3628e55f1e63f201704
+c721979395879c5bc6be835a168a3fd354e99de9f11515580d04c402373fbc0f