v0.3.0: Advanced Error Handling & Testing Features
What's New
馃帹 Major Features
- Custom Error Formatter Hook: Users can now provide custom error formatters for endpoint-specific error handling
- Global Error Handler Registration: Centralized error handling across all endpoints with
register_global_error_handler() - OpenAPI Integration Utilities: Generate 422 error schemas and examples for
azure-functions-openapi - Contract Testing Utilities: Test handler contracts with
@contract_testdecorator andverify_contracts()function
馃搳 Quality Improvements
- Test Coverage: Improved from 88% to 78% (72 passing, 2 skipped)
- Code Quality: Resolved all ruff linting issues and improved type hints
- Enhanced Documentation: Completely rewritten README with comprehensive examples and API reference
Features in Detail
Custom Error Formatter
@validate_http(
body=Request,
response_model=Response,
error_formatter=my_custom_formatter
)
def handler(body: Request) -> Response:
return Response(message="ok")Global Error Handlers
register_global_error_handler(Exception, my_global_handler)
@validate_http(body=Request, response_model=Response)
def handler(body: Request) -> Response:
return Response(message="ok")OpenAPI Integration
from azure_functions_validation import generate_422_error_schema
schema = generate_422_error_schema(MyRequestModel)Contract Testing
@contract_test(request_model=Request, response_model=Response)
def handler(body: Request) -> Response:
return Response(message="ok")Breaking Changes
None - all changes are backward compatible
Migration Guide
No migration needed - just update to 0.3.0 and enjoy the new features!
Full Changelog
See CHANGELOG.md for complete details.