Commit 810aadc
feat(event_handler): enhance OpenAPI response with headers, links, examples and encoding (#7312)
* feat(event_handler): enhance OpenAPI response with headers, links, examples and encoding
- Add OpenAPIResponseHeader TypedDict with full OpenAPI spec compliance
- Add headers and links fields to OpenAPIResponse TypedDict
- Add examples and encoding fields to content models
- Fix processing logic to preserve examples when using model field
- Maintain 100% backward compatibility with total=False
- Add comprehensive functional tests covering all scenarios
Fixes #4870
* fix: apply ruff formatting to fix import sorting
- Fixed import order in tests/unit/test_shared_functions.py
- Addresses linting issues identified in PR review
* fix: remove unused imports in test file
- Removed unused pytest import
- Removed unused Response import
- Resolves remaining linting errors from make pr
* fix: apply final formatting changes
- Minor whitespace adjustments from ruff formatter
- Ensures consistent code formatting
* fix: resolve mypy TypedDict errors in OpenAPI response handling
- Fixed type handling for OpenAPIResponseContentSchema and OpenAPIResponseContentModel
- Removed variable redefinition in _get_openapi_path method
- Improved type safety for model field processing
- Addresses remaining type checking issues from make pr
* fix: improve code quality for SonarCloud compliance
- Reverted to more maintainable loop-based approach for field copying
- Ensures type safety while addressing SonarCloud code quality concerns
- Maintains functionality for preserving examples when using model field
- Addresses SonarCloud finding identified by dreamorosi
* refactor(tests): consolidate OpenAPI response tests as requested by @leandrodamascena
- Moved all tests from test_openapi_response_fields.py to existing test_openapi_responses.py
- Removed duplicate test file to improve code organization
- All 21 tests pass (12 original + 9 consolidated)
- Addresses reviewer feedback for better test file structure
* refactor(tests): remove duplicate/unnecessary tests as requested by @leandrodamascena
- Removed test_openapi_response_encoding_preserved_with_model (duplicate of examples test)
- Removed test_openapi_response_all_fields_together (unnecessary)
- Removed test_openapi_response_backward_compatibility (unnecessary)
- Removed test_openapi_response_empty_optional_fields (unnecessary)
- Removed test_openapi_response_multiple_content_types_with_fields (unnecessary)
- Removed test_openapi_response_with_router (already covered elsewhere)
- Cleaned up unused Router import
- Kept only essential tests: headers, links, and examples preservation
- All 15 remaining tests pass successfully
---------
Co-authored-by: Leandro Damascena <[email protected]>1 parent 15b54c4 commit 810aadc
File tree
3 files changed
+166
-9
lines changed- aws_lambda_powertools/event_handler
- openapi
- tests/functional/event_handler/_pydantic
3 files changed
+166
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
666 | 664 | | |
667 | 665 | | |
668 | 666 | | |
| 667 | + | |
669 | 668 | | |
670 | 669 | | |
671 | | - | |
| 670 | + | |
672 | 671 | | |
673 | 672 | | |
674 | 673 | | |
675 | 674 | | |
676 | 675 | | |
677 | 676 | | |
678 | | - | |
| 677 | + | |
679 | 678 | | |
680 | 679 | | |
681 | 680 | | |
682 | 681 | | |
683 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
684 | 690 | | |
685 | 691 | | |
686 | 692 | | |
687 | | - | |
| 693 | + | |
688 | 694 | | |
689 | 695 | | |
690 | 696 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
66 | 78 | | |
67 | 79 | | |
| 80 | + | |
| 81 | + | |
68 | 82 | | |
69 | 83 | | |
70 | | - | |
| 84 | + | |
71 | 85 | | |
| 86 | + | |
| 87 | + | |
72 | 88 | | |
73 | 89 | | |
74 | | - | |
75 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
76 | 93 | | |
| 94 | + | |
Lines changed: 134 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
0 commit comments