📝 Add OpenAPI warning to "Body - Fields" docs with extra schema extensions#4846
Conversation
Adds a warning about generating invalid OpenAPI schemas (see fastapi#3745) when using additional keys in pydantic `Field` specifications.
Codecov Report
@@ Coverage Diff @@
## master #4846 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 531 531
Lines 13627 13629 +2
=========================================
+ Hits 13627 13629 +2
Continue to review full report at Codecov.
|
|
📝 Docs preview for commit c8182fb at: https://626e94c817e90a569d91b459--fastapi.netlify.app |
|
📝 Docs preview for commit 1d9b364 at: https://627c2d135aa774107ddd9516--fastapi.netlify.app |
|
Thanks @ml-evs! I updated the tip/warning a bit to avoid mentioning |
…sions (fastapi#4846) Co-authored-by: Sebastián Ramírez <[email protected]>
This PR adds a warning in the docs about generating invalid OpenAPI schemas (see #3745) when using additional keys in pydantic
Fieldspecifications. This warning only effects versionsfastapi>=0.66, which could be added to the note if helpful.I would have liked to include a workaround for those who want to keep generating valid schemas, but is currently non-trivial and either involves overriding a whole chain of field info classes, or writing a custom OpenAPI schema method, to undo the effect of
extra = "allow"in thefastapi.openapi.models.Schemaclass.It is a bit of a shame this hasn't been acknowledged as an issue in #3745 but I hope that this warning will be helpful for those who are trying to use generic OpenAPI tools with FastAPI.