Commit Graph

9 Commits

Author SHA1 Message Date
pre-commit-ci-lite[bot] fc420a592d
🎨 Auto format 2025-12-03 21:35:29 +00:00
g7azazlo 2d0161f183 Merge branch 'feat/ast-response-inference' of https://github.com/g7AzaZLO/fastapi into feat/ast-response-inference 2025-12-04 00:29:53 +03:00
g7azazlo bf90082191 Refactor type inference logic in utils for improved clarity
- Simplified the `_infer_type_from_ast` function by consolidating conditional checks for argument annotations, enhancing readability and maintainability.
- Updated test cases in `tests/test_ast_inference.py` to utilize parameterization for better organization and coverage of edge cases in response model inference.
2025-12-04 00:28:00 +03:00
pre-commit-ci-lite[bot] feffe5b824
🎨 Auto format 2025-12-03 21:00:56 +00:00
g7azazlo e03e232c39 Enhance response model inference and add edge case tests
- Updated the `infer_response_model_from_ast` function to use `textwrap.dedent` for cleaner source code handling.
- Added multiple test cases in `tests/test_ast_inference.py` to cover various edge cases for response model inference, including functions with different return types and argument annotations.
- Improved type inference for functions returning lists and nested dictionaries, ensuring better schema generation.
2025-12-03 23:59:58 +03:00
pre-commit-ci-lite[bot] 95d5b080a2
🎨 Auto format 2025-12-03 19:19:46 +00:00
g7azazlo 5246f7c3ad Add new database-related endpoints and enhance schema validation in tests
- Introduced two new endpoints: "/db/direct_return" and "/db/dict_construction" to simulate database interactions.
- Added a FakeDB class to mock database behavior for testing purposes.
- Enhanced test cases to validate the OpenAPI schema for the new endpoints, ensuring correct response structure and types.
2025-12-03 22:15:49 +03:00
g7azazlo 40af1b90c3 Enhance response model inference and improve error handling
- Updated the response model inference logic in "APIRoute" to check for "None" before validating against "BaseModel".
- Refined the "infer_response_model_from_ast" function to handle nested function definitions and invalid dictionary keys, ensuring robust schema generation.
- Added new test cases for edge scenarios to validate the inference behavior.
2025-12-03 22:06:15 +03:00
g7azazlo 72b210209b Implement response model inference from endpoint function source code
- Added "infer_response_model_from_ast" function to analyze endpoint functions and infer Pydantic models from returned dictionary literals or variable assignments.

- Updated "APIRoute" to utilize the new inference method when the specified response model is not a subclass of "BaseModel"
2025-12-03 21:44:57 +03:00