[QUESTION] How to provide custom example value for single return
See original GitHub issueFirst 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?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to customized request body "Example Value"? #2352
If your endpoint is returning a model, to set custom example values in the swagger-ui, use the @ApiModelProperty for each field then use ......
Read more >Returning value that was passed into a method - Stack Overflow
string DoSomething(string whatever);. I want to mock this with MOQ, so that it returns whatever was passed in - something like: _mock.Setup( theObject ......
Read more >Returning a Value from a Method (The Java™ Tutorials ...
You declare a method's return type in its method declaration. Within the body of the method, you use the return statement to return...
Read more >Making queries | Django documentation
While it can be customized , by default you refer to a “reverse” relationship in a lookup using the lowercase name of the...
Read more >Recode Values - Qualtrics
Example : You may want to recode the values of a “yes” or “no” question to be 0 and 1, respectively, instead of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, @retnikt !
You can add examples for in field
responses
. See this pagehttps://github.com/tiangolo/fastapi/issues/1007#issuecomment-589029073