This is an automated email from the ASF dual-hosted git repository.
potiuk 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 90dbd241f0e Make sure all openapi schemes have distinct names (#49290)
90dbd241f0e is described below
commit 90dbd241f0efb06ba535b0df8a9ef51b45538042
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue Apr 15 15:30:16 2025 +0200
Make sure all openapi schemes have distinct names (#49290)
When redoc includes, rather than embeds the openapi schemes, it
loads them from the same folder. If the files have the same names
they will be overwritten.
This PR changes the openapi schemes to all have distinct, unique
names.
---
.pre-commit-config.yaml | 8 ++++----
.rat-excludes | 2 +-
airflow-core/docs/conf.py | 4 ++--
...1-generated.yaml => v1-simple-auth-manager-generated.yaml} | 0
.../airflow/api_fastapi/auth/managers/simple/ui/package.json | 2 +-
.../openapi/{v1-generated.yaml => v1-rest-api-generated.yaml} | 0
airflow-core/src/airflow/ui/package.json | 2 +-
contributing-docs/16_adding_api_endpoints.rst | 2 +-
dev/breeze/src/airflow_breeze/utils/selective_checks.py | 2 +-
dev/breeze/tests/test_selective_checks.py | 2 +-
devel-common/src/docs/provider_conf.py | 6 ++++--
.../{v1-generated.yaml => v1-fab-auth-manager-generated.yaml} | 0
.../airflow/providers/fab/auth_manager/fab_auth_manager.py | 2 +-
.../fab/auth_manager/openapi/{v1.yaml => v1-flask-api.yaml} | 0
scripts/in_container/run_update_fastapi_api_spec.py | 11 ++++++-----
15 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9a2f02b7e4f..989abaf4bc0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -125,7 +125,7 @@ repos:
- --fuzzy-match-generates-todo
- id: insert-license
name: Add license for all YAML files except Helm templates
- exclude:
^\.github/.*$|^chart/templates/.*|.*reproducible_build\.yaml$|^.*/v1-generated\.yaml$|^.*/pnpm-lock\.yaml$
+ exclude:
^\.github/.*$|^chart/templates/.*|.*reproducible_build\.yaml$|^.*/v1.*\.yaml$|^.*/pnpm-lock\.yaml$
types: [yaml]
files: \.ya?ml$
args:
@@ -281,7 +281,7 @@ repos:
^.*airflow\.template\.yaml$|
^.*init_git_sync\.template\.yaml$|
^chart/(?:templates|files)/.*\.yaml$|
- .*/v1-generated\.yaml$|
+ .*/v1.*\.yaml$|
^.*openapi.*\.yaml$|
^\.pre-commit-config\.yaml$|
^.*reproducible_build\.yaml$|
@@ -1322,9 +1322,9 @@ repos:
files: |
(?x)
^airflow-core/src/airflow/ui/|
-
^airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated\.yaml$|
+ ^airflow-core/src/airflow/api_fastapi/core_api/openapi/v1.*\.yaml$|
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/|
-
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1-generated\.yaml$
+
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1.*\.yaml$
entry: ./scripts/ci/pre_commit/compile_lint_ui.py
additional_dependencies: ['[email protected]']
pass_filenames: false
diff --git a/.rat-excludes b/.rat-excludes
index d9bc6ac0e0a..c22d1e227ba 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -160,7 +160,7 @@ PKG-INFO
# Openapi files
.openapi-generator-ignore
version.txt
-v1-generated.yaml
+v1*.yaml
# Front end generated files
api-generated.ts
diff --git a/airflow-core/docs/conf.py b/airflow-core/docs/conf.py
index 1e470587b99..43026bb39f2 100644
--- a/airflow-core/docs/conf.py
+++ b/airflow-core/docs/conf.py
@@ -343,8 +343,8 @@ spelling_ignore_importable_modules = True
graphviz_output_format = "svg"
-main_openapi_path =
Path(main_openapi_file).parent.joinpath("v1-generated.yaml")
-sam_openapi_path = Path(sam_openapi_file).parent.joinpath("v1-generated.yaml")
+main_openapi_path =
Path(main_openapi_file).parent.joinpath("v1-rest-api-generated.yaml")
+sam_openapi_path =
Path(sam_openapi_file).parent.joinpath("v1-simple-auth-manager-generated.yaml")
redoc = [
{
"name": "Simple auth manager token API",
diff --git
a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1-generated.yaml
b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1-simple-auth-manager-generated.yaml
similarity index 100%
rename from
airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1-generated.yaml
rename to
airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1-simple-auth-manager-generated.yaml
diff --git
a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/package.json
b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/package.json
index 717547853b9..6c3a49a18a6 100644
--- a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/package.json
+++ b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/package.json
@@ -10,7 +10,7 @@
"lint:fix": "eslint --fix && tsc --p tsconfig.app.json",
"format": "pnpm prettier --write .",
"preview": "vite preview",
- "codegen": "openapi-rq -i \"../openapi/v1-generated.yaml\" -c axios
--format prettier -o openapi-gen --operationId",
+ "codegen": "openapi-rq -i
\"../openapi/v1-simple-auth-manager-generated.yaml\" -c axios --format prettier
-o openapi-gen --operationId",
"test": "vitest run",
"coverage": "vitest run --coverage"
},
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated.yaml
b/airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-rest-api-generated.yaml
similarity index 100%
rename from
airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated.yaml
rename to
airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-rest-api-generated.yaml
diff --git a/airflow-core/src/airflow/ui/package.json
b/airflow-core/src/airflow/ui/package.json
index b3b45cf276e..29df4f460ea 100644
--- a/airflow-core/src/airflow/ui/package.json
+++ b/airflow-core/src/airflow/ui/package.json
@@ -11,7 +11,7 @@
"lint:fix": "eslint --fix && tsc --p tsconfig.app.json",
"format": "pnpm prettier --write .",
"preview": "vite preview",
- "codegen": "openapi-rq -i
\"../api_fastapi/core_api/openapi/v1-generated.yaml\" -c axios --format
prettier -o openapi-gen --operationId",
+ "codegen": "openapi-rq -i
\"../api_fastapi/core_api/openapi/v1-rest-api-generated.yaml\" -c axios
--format prettier -o openapi-gen --operationId",
"test": "vitest run",
"coverage": "vitest run --coverage"
},
diff --git a/contributing-docs/16_adding_api_endpoints.rst
b/contributing-docs/16_adding_api_endpoints.rst
index 891bd822411..02d2940b418 100644
--- a/contributing-docs/16_adding_api_endpoints.rst
+++ b/contributing-docs/16_adding_api_endpoints.rst
@@ -74,7 +74,7 @@ Step 4: Run Pre-commit Hooks
-----------------------------
1. Ensure all code meets the project's quality standards by running pre-commit
hooks.
2. Pre-commit hooks include static code checks, formatting, and other
validations.
-3. Persisted openapi spec is located in ``v1-generated.yaml`` and a hook will
take care of updating it based on your new endpoint, you just need to add and
commit the change.
+3. Persisted openapi spec is located in ``v1-rest-api-generated.yaml` and a
hook will take care of updating it based on your new endpoint, you just need to
add and commit the change.
4. Run the following command to execute all pre-commit hooks:
.. code-block:: bash
diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
index 5eb9973729f..45c80b23b48 100644
--- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
+++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
@@ -170,7 +170,7 @@ CI_FILE_GROUP_MATCHES = HashableDict(
r"^airflow-core/tests/unit/api_fastapi/",
],
FileGroupForCi.API_CODEGEN_FILES: [
-
r"^airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated\.yaml",
+
r"^airflow-core/src/airflow/api_fastapi/core_api/openapi/.*generated\.yaml",
r"^clients/gen",
],
FileGroupForCi.HELM_FILES: [
diff --git a/dev/breeze/tests/test_selective_checks.py
b/dev/breeze/tests/test_selective_checks.py
index 90ffdd65a7f..6cb31923a0d 100644
--- a/dev/breeze/tests/test_selective_checks.py
+++ b/dev/breeze/tests/test_selective_checks.py
@@ -1879,7 +1879,7 @@ def test_expected_output_push(
id="Tests for all airflow core types except providers should run
if model file changed",
),
pytest.param(
-
("airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated.yaml",),
+
("airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-rest-api-generated.yaml",),
{
"selected-providers-list-as-string": "",
"all-python-versions": "['3.9']",
diff --git a/devel-common/src/docs/provider_conf.py
b/devel-common/src/docs/provider_conf.py
index 82e1423dfe9..ceb97760081 100644
--- a/devel-common/src/docs/provider_conf.py
+++ b/devel-common/src/docs/provider_conf.py
@@ -364,9 +364,11 @@ if PACKAGE_NAME in PROVIDER_PACKAGES_WITH_REDOC:
)
from airflow.providers.fab.auth_manager.openapi import __file__ as
fab_auth_manager_flask_api_file
- fab_auth_manager_flask_api_path =
Path(fab_auth_manager_flask_api_file).parent.joinpath("v1.yaml")
+ fab_auth_manager_flask_api_path =
Path(fab_auth_manager_flask_api_file).parent.joinpath(
+ "v1-flask-api.yaml"
+ )
fab_auth_manager_fastapi_api_path =
Path(fab_auth_manager_fastapi_api_file).parent.joinpath(
- "v1-generated.yaml"
+ "v1-fab-auth-manager-generated.yaml"
)
redoc = [
{
diff --git
a/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/openapi/v1-generated.yaml
b/providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/openapi/v1-fab-auth-manager-generated.yaml
similarity index 100%
rename from
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/openapi/v1-generated.yaml
rename to
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/openapi/v1-fab-auth-manager-generated.yaml
diff --git
a/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
b/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
index 009e9ed9d6d..18d0513892b 100644
--- a/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
+++ b/providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py
@@ -233,7 +233,7 @@ class FabAuthManager(BaseAuthManager[User]):
def get_api_endpoints(self) -> None | Blueprint:
folder = Path(__file__).parents[0].resolve() # this is
airflow/auth/managers/fab/
- with folder.joinpath("openapi", "v1.yaml").open() as f:
+ with folder.joinpath("openapi", "v1-flask-api.yaml").open() as f:
specification = safe_load(f)
return FlaskApi(
specification=specification,
diff --git
a/providers/fab/src/airflow/providers/fab/auth_manager/openapi/v1.yaml
b/providers/fab/src/airflow/providers/fab/auth_manager/openapi/v1-flask-api.yaml
similarity index 100%
rename from providers/fab/src/airflow/providers/fab/auth_manager/openapi/v1.yaml
rename to
providers/fab/src/airflow/providers/fab/auth_manager/openapi/v1-flask-api.yaml
diff --git a/scripts/in_container/run_update_fastapi_api_spec.py
b/scripts/in_container/run_update_fastapi_api_spec.py
old mode 100644
new mode 100755
index d0bc695decd..fb1352bc38a
--- a/scripts/in_container/run_update_fastapi_api_spec.py
+++ b/scripts/in_container/run_update_fastapi_api_spec.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -32,12 +33,12 @@ from airflow.providers.fab.auth_manager.fab_auth_manager
import FabAuthManager
if TYPE_CHECKING:
from fastapi import FastAPI
-OPENAPI_SPEC_FILE = Path(CORE_API_PATH).parent.joinpath("openapi",
"v1-generated.yaml")
-SIMPLE_AUTH_MANAGER_OPENAPI_SPEC_FILE =
Path(SIMPLE_AUTH_MANAGER_PATH).parent.joinpath(
- "openapi", "v1-generated.yaml"
+OPENAPI_SPEC_FILE = Path(CORE_API_PATH).parent / "openapi" /
"v1-rest-api-generated.yaml"
+SIMPLE_AUTH_MANAGER_OPENAPI_SPEC_FILE = (
+ Path(SIMPLE_AUTH_MANAGER_PATH).parent / "openapi" /
"v1-simple-auth-manager-generated.yaml"
)
-FAB_AUTH_MANAGER_OPENAPI_SPEC_FILE =
Path(FAB_AUTH_MANAGER_API_PATH).parent.joinpath(
- "openapi", "v1-generated.yaml"
+FAB_AUTH_MANAGER_OPENAPI_SPEC_FILE = (
+ Path(FAB_AUTH_MANAGER_API_PATH).parent / "openapi" /
"v1-fab-auth-manager-generated.yaml"
)