bugraoz93 commented on code in PR #49608:
URL: https://github.com/apache/airflow/pull/49608#discussion_r2056824120


##########
scripts/in_container/run_update_fastapi_api_spec.py:
##########
@@ -74,13 +76,29 @@ def generate_file(app: FastAPI, file_path: Path, prefix: 
str = "", only_ui: bool
         )
 
 
+def validate_openapi_file(file_path: Path) -> bool:
+    with file_path.open() as f:
+        openapi_schema = yaml.safe_load(f)
+    try:
+        validate_spec(openapi_schema)
+    except Exception as e:
+        print(f"[ERROR] OpenAPI validation failed for {file_path}: {e}", 
file=sys.stderr)
+        return False
+    return True
+
+
 # Generate main application openapi spec
 # Set the auth manager as SAM. No need to use another one to generate fastapi 
spec
 os.environ["AIRFLOW__CORE__AUTH_MANAGER"] = (
     
"airflow.api_fastapi.auth.managers.simple.simple_auth_manager.SimpleAuthManager"
 )
 generate_file(app=create_app(), file_path=OPENAPI_SPEC_FILE)
+if not validate_openapi_file(OPENAPI_SPEC_FILE):
+    sys.exit(1)

Review Comment:
   Can we exit once in the method and only call the method for all the spec 
files? 
   ```suggestion
   validate_openapi_file(OPENAPI_SPEC_FILE)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to