Commit Graph

5 Commits

Author SHA1 Message Date
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