📝 Add OpenAPI warning to "Body - Fields" docs with extra schema extensions (#4846)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Matthew Evans 2022-05-11 22:43:47 +01:00 committed by GitHub
parent 1bbbdb4b7f
commit 4fcdb31947
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -57,6 +57,10 @@ You can declare extra information in `Field`, `Query`, `Body`, etc. And it will
You will learn more about adding extra information later in the docs, when learning to declare examples.
!!! warning
Extra keys passed to `Field` will also be present in the resulting OpenAPI schema for your application.
As these keys may not necessarily be part of the OpenAPI specification, some OpenAPI tools, for example [the OpenAPI validator](https://validator.swagger.io/), may not work with your generated schema.
## Recap
You can use Pydantic's `Field` to declare extra validations and metadata for model attributes.