question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] How to provide custom example value for single return

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nkhitrovcommented, May 1, 2020

Hi, @retnikt !

You can add examples for in field responses. See this page

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found