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 can use a default value for query parameter list

See original GitHub issue

Description I would to set a default value for query parameter list. I tried List[str] = Query(('a', 'b')) but i receive an empty array.

Additional context

I added a simple test case that demonstrate the empty array returned by List[str] = Query(('a', 'b'))

https://github.com/ysavary/fastapi/commit/2bee1fa5e158ca37c5dbc554c07c9711dbd05d29

The 3rd test, ("/query/list_str/default", 200, "foo bar ['a', 'b']") is failing:

E       assert 'foo bar []' == "foo bar ['a', 'b']"
E         - foo bar []
E         + foo bar ['a', 'b']

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ysavarycommented, Jun 1, 2019

@tiangolo @euri10

Thank you for your answers. Awesome framework šŸ‘

0reactions
tiangolocommented, Jun 20, 2019

Iā€™m glad youā€™re liking it @ysavary ! I think the issue is solved now, so Iā€™ll close it. But feel free to add more comments, create new issues, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default values in list query parameter - asp.net core
I am trying to display default values in Swashbuckle. Is there a way to define default values in a query list parameter in...
Read more >
Set Question Defaults with Query Parameters
ConvertCalculator supports setting these default question values by using query parameters. Here's how it works: Go to the question settings you want pre-filledĀ ......
Read more >
Query Parameters and String Validations - FastAPI
As we have to replace the default value None in the function with Query() , we can now set the default value with...
Read more >
How to set default values for parameters - Microsoft Q&A
I want to set the default value of the parameter according to the current time. power-query-not-supported. Comment. Comment
Read more >
Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
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