List as query param
See original GitHub issueHere I’m creating operation , and I want to pass to it multiple query parameters like
/test?query=1&query=2&query=3
this is my code:
from typing import List
from fastapi import FastAPI, Query, Body
app = FastAPI(debug=True)
@app.get("/test")
def check(query: List[int]):
return query
Expected behavior
in docs I should see this param if I call it should accept GET params
Screenshots
No parameters in docs:
when I try to call it - got an error that body is not supplied:
Environment
- OS:macOS
- FastAPI 0.54.1
- Python 3.7.4
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Spring — Passing list and array of values as URL parameters
Let's see how to send a list of query parameters, and receive them in array/arraylist in Spring. Sending via URL: List of values...
Read more >REST API Best practice: How to accept list of parameter ...
The standard way to pass a list of values as URL parameters is to repeat them: http://our.api.com/Product?id=101404&id=7267261.
Read more >Query Parameters and String Validations - FastAPI
To declare a query parameter with a type of list , like in the example above, you need to explicitly use Query ,...
Read more >REST API query parameters for collection resources - IBM
Query parameters for collection resources ; fields, A comma-separated list of property names. This parameter filters the properties that are returned. Property ...
Read more >Build api URL using list of query params - OutSystems
You cannot directly do what you propose, as the Platform will encode the "filters" parameter, so the = and & will be encoded...
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
This works:
All the best 😃
Yes, it works, but my guess is - either FastAPI should raise some validation error or it should treat default params as Query (like it does for string, int annotations)