Repository navigation
fix(event_handler): correct six OpenAPI schema inaccuracies - #8630
SpinachDigital wants to merge 6 commits into
Conversation
Signed-off-by: Abhishek Jha <abhi91temp@gmail.com>
Signed-off-by: Abhishek Jha <abhi91temp@gmail.com>
Signed-off-by: Abhishek Jha <abhi91temp@gmail.com>
Signed-off-by: Abhishek Jha <abhi91temp@gmail.com>
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
…t_openapi_schema to keep ruff complexity limits
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @SpinachDigital, all six are fixed and I checked each one against develop side by side, including a richer Query model with datetime, UUID and Literal fields, which now come out with the right format and enum.
One thing would have failed CI: the loop you added to get_openapi_schema pushes it over our ruff complexity limits (C901, PLR0912). You had already written _validate_openapi_extension_keys in the schema generator, so I pushed a small commit that calls it from there instead. Nothing else changed.
Approving. This goes out in 3.39.0, so it will sit here for a while before I merge it. No rebase needed in the meantime, and you'll be credited in the release notes. I'll flag the x- enforcement and the custom-responses change in the notes since both are visible to people who relied on the old behavior.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #8630 +/- ##
===========================================
- Coverage 96.93% 96.90% -0.04%
===========================================
Files 318 321 +3
Lines 16031 16257 +226
Branches 1423 1456 +33
===========================================
+ Hits 15540 15754 +214
- Misses 349 358 +9
- Partials 142 145 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Follow-up push: the PR fixed six behaviors but only adjusted two existing assertions, so four of the new lines had no test. I added regression tests for each item through the public API, description-only custom responses, Query model field types plus the string fallback, |
leandrodamascena
left a comment
There was a problem hiding this comment.
Re-approving after the test push above.
|



Closes #8583.
Six fixes, all in the OpenAPI lane:
Custom
responseswithoutcontentno longer inherit the handler's return schema for every status code — only the route's own status code gets the return-type content; a description-only 404 stays description-only (_build_custom_response).Pydantic-model
Query()/Header()fields now build schemas withTypeAdapter(annotation).json_schema()—int | Nonerenders as anyOf,list[str]as array, Enums with their values, instead of everything collapsing to{"type": "string"}.ValidationErrorcomponent no longer listsmsginrequired— it is not inproperties(hidden for security) nor in the real 422 body.openapi_extensionsnow enforces thex-prefix at the root (get_openapi) and at the operation level, raising the sameSchemaValidationErrorthatServerandSecuritySchemealready raise.Path(alias=...): validation looks path params up by the template name again (was a 422 missing), and the emitted parameter name matches the path template.decimal_encoderraisesSerializationErrorfor non-finite Decimals (NaN/Infinity) instead of leakingTypeError: '>=' not supported between 'str' and 'int'.Also updates two assertions in
test_openapi_params.pythat pinned the old{"type": "string"}rendering forstr | Nonefields.Verified locally before opening: the issue's repro snippet now passes for all 6 items, and the repo's openapi functional suites pass (including the two updated assertions).
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.