Add ability to exclude input/context from ValidationErrors
#15047
Unanswered
WilliamDEdwards
asked this question in
Questions
Replies: 2 comments 5 replies
-
|
If your intention is to make schema cleaner - you can customize the openapi schema as it's shown in docs. To decide whether we should add such feature or not we need to understand how often it's needed. I personally think in most cases people will not care about these 2 non-required properties being in |
Beta Was this translation helpful? Give feedback.
4 replies
This comment was marked as spam.
This comment was marked as spam.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
#Description
ValidationErrors containinputandctx.It is valid to NOT return them:
ctxcontains references to the Pydantic documentation, which is an implementation detail irrelevant to API usersinputmight contain confidential data that would end up in response logsPydantic provides a way to exclude them using
ValidationError.errors(include_input=..., include_context=...). FastAPI doesn't, and I do not have access to theValidationErrorraised when FastAPI processes the request/response.I had the following middleware, which was fine:
... but with #10787,
ctxandinputare always added to the API documentation, while I delete them.Therefore, I need a natively supported way to omit both attributes.
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.135.1
Pydantic Version
2.12.5
Python Version
3.13
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions