Refactor V3 CRUD: Extract schema introspection logic.

- Created app/lib_schema_v3.py to isolate database and Pydantic model introspection.
- Updated app/routers/api_crud_v3.py to use get_object_schema_info(), completing the modularization.
- Finalized refactoring plan documentation in documentation/REFACTOR_API_CRUD_V3.md.
This commit is contained in:
Scott Idem
2026-01-09 16:29:10 -05:00
parent 812181acb5
commit 3885cc6aba
3 changed files with 77 additions and 47 deletions

View File

@@ -14,15 +14,15 @@
1. **Create `app/routers/api_crud_v3_nested.py`**: DONE
2. **Update `app/routers/api_crud_v3.py`**: DONE (Included via `router.include_router`)
## Phase 3: Schema Introspection - PLANNED
## Phase 3: Schema Introspection - COMPLETED
**Objective:** Isolate database introspection logic.
1. **Create `app/lib_schema_v3.py` (or similar)**:
* Move the logic inside `get_obj_schema` (SQL `DESCRIBE` parsing, Pydantic introspection) to a helper function.
1. **Create `app/lib_schema_v3.py`**: DONE
2. **Update `app/routers/api_crud_v3.py`**: DONE
## Execution Strategy
We will execute **Phase 1** first as it provides immediate value (removing code duplication for sanitization) with minimal risk to routing logic.
### Testing
After each move:
1. Run `tests/test_v3_router_filtering.py` (requires update to import from new location if we test the lib directly).
2. Verify application startup.
## Refactoring Summary
The V3 CRUD system is now modularized into:
- `app/routers/api_crud_v3.py`: Top-level object routes.
- `app/routers/api_crud_v3_nested.py`: Relational/child object routes.
- `app/lib_api_crud_v3.py`: Shared security, filtering, and sanitization logic.
- `app/lib_schema_v3.py`: Database and model introspection logic.