Could we reject request bodies with misspelt optional fields? #7728
-
First check
DescriptionIs it possible to reject requests with fields that does not map to the request model? The use case is that we want to alert users that they have misspelt an optional field. For example we have something like And do a post like Note misspelled description. Then the response will be Can we configure FastApi and pydantic to reject this instead? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Try adding inside the class definition of |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @dmontagu! This is exactly what I was looking for. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the help here @dmontagu ! 🍰 🙇♂️ Thanks @m-johansson for reporting back and closing the issue 👍 |
Beta Was this translation helpful? Give feedback.
Try adding
inside the class definition of
Item. I think that should make it raise errors if it receives unexpected fields.