79316599

Date: 2024-12-30 01:18:24
Score: 1
Natty:
Report link

Adding to @ZAR's answer, as of December 2024, the following works (notice examples):

Field(schema_extra={'examples': "A very nice Item"})

From the FastAPI documentation:

OpenAPI 3.1.0 (used since FastAPI 0.99.0) added support for "examples", which is part of the JSON Schema standard. Before that, it only supported the keyword "example" with a single example. That is still supported by OpenAPI 3.1.0, but is deprecated and is not part of the JSON Schema standard. So you are encouraged to migrate example to "examples". 🤓

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @ZAR's
  • Low reputation (1):
Posted by: Alexandre Potvin