Eason09053360 opened a new pull request, #61061:
URL: https://github.com/apache/airflow/pull/61061

   ## Migrate FAB provider API from connexion to FastAPI
   
   This PR migrates the Flask-AppBuilder (FAB) provider's API layer from 
`connexion` to `FastAPI`, creating a new `api_fastapi` module while maintaining 
backward compatibility with existing error handling and response formats.
   
   ### Changes
   
   #### New Module: `api_fastapi/`
   Created a new FastAPI-compatible module structure under 
`providers/fab/src/airflow/providers/fab/www/api_fastapi/` with the following 
components:
   
   1. **constants.py** - Centralized HTTP status code to documentation URL 
mappings
      - Maintains `EXCEPTIONS_LINK_MAP` for RFC 7807 Problem Details `type` 
field
   
   2. **exceptions.py** - FastAPI exception classes
      - Migrated from `connexion.ProblemException` to `fastapi.HTTPException`
      - Implemented `common_error_handler` using 
`fastapi.responses.JSONResponse`
      - Preserves RFC 7807 Problem Details format (`type`, `title`, `status`, 
`detail`)
      - Exception classes: `NotFound`, `BadRequest`, `Unauthenticated`, 
`PermissionDenied`, `Conflict`, `AlreadyExists`, `Unknown`
   
   3. **parameters.py** - Parameter validation and formatting
      - Converted Flask/connexion decorators to FastAPI `Query` parameters
      - Validation functions: `validate_istimezone()`, `check_limit()`
      - Type aliases: `LimitQueryParam`, `OffsetQueryParam`
   
   4. **types.py** - Response type definitions
      - Defined `APIResponse` type for FastAPI responses
      - Maintained `UpdateMask` type for PATCH operations
   
   5. **security.py** - Authentication dependencies
      - Converted Flask decorators to FastAPI `Depends` pattern
      - Functions: `check_authentication()`, `requires_access_custom_view()`
      - Type alias: `AuthenticatedRequest`
   
   #### Modified Files
   - **init_views.py** - Updated import path from `api_connexion.exceptions` to 
`api_fastapi.exceptions`
   
   
   
   ### Testing
   
   - [x] All new files include Apache License 2.0 headers
   - [x] Code follows FastAPI best practices (dependency injection, type hints)
   - [x] Maintains existing error response format (RFC 7807)
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   <!--
   Generated-by: GitHub Copilot following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->


-- 
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