Skip to content

How to provide custom example value for single return #1345

@retnikt

Description

@retnikt

First check

  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.

Description

How can I provide a custom example value for the return value of routes? When the return is a Pydantic model, you can set the example keyword argument on a pydantic Field or add it to schema_extra in the Model config. However, when the return value is a simple type such as str or List[Optional[int]]` there seems to be no way to provide an example. Am I missing something, or is this a missing feature?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions