<p dir="auto"><strong>Description</strong></p>
<p dir="auto">I need to support several query parameters with same name in GET route. Typical request looks like this:<br>
<a href="http://localhost/item?num=1&amp;num=2" rel="nofollow">http://localhost/item?num=1&amp;num=2</a></p>
<p dir="auto">I configured a route</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@app.get(&quot;/item&quot;, content_type=UJSONResponse)
async def get_part(num: list):
    found = False
    for i in num:
         if i in some_data:
             found = True
             break
    return {&quot;found&quot;: found}"><pre class="notranslate"><code class="notranslate">@app.get("/item", content_type=UJSONResponse)
async def get_part(num: list):
    found = False
    for i in num:
         if i in some_data:
             found = True
             break
    return {"found": found}
</code></pre></div>
<p dir="auto">The idea is, that I can pass several numbers to check, if they exist in some_data. In my opinion, it is not a good idea to get numbers from body here, because it is a simple GET request, but in current version application expects argument "num" in body, so on my request (written above) I receive a response</p>
<p dir="auto"><code class="notranslate">{"detail":[{"loc":["body","num"],"msg":"field required","type":"value_error.missing"}]}</code></p>
<p dir="auto">As I know, it is not restricted to pass several query parameters with the same name in an HTTP request by any specifications, so I would like to ask, is it possible to configure a route in FastAPI, which will be able to parse several query parameters with the same name?</p>
<h3 dir="auto">First Check</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I added a very descriptive title to this issue.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I used the GitHub search to find a similar issue and didn't find it.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I searched the FastAPI documentation, with the integrated search.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I already searched in Google "How to X in FastAPI" and didn't find any information.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I already read and followed all the tutorial in the docs and didn't find an answer.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I already checked if it is not related to FastAPI but to <a href="https://github.com/samuelcolvin/pydantic">Pydantic</a>.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I already checked if it is not related to FastAPI but to <a href="https://github.com/swagger-api/swagger-ui">Swagger UI</a>.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I already checked if it is not related to FastAPI but to <a href="https://github.com/Redocly/redoc">ReDoc</a>.</li>
</ul>
<h3 dir="auto">Commit to Help</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I commit to help with one of those options <g-emoji class="g-emoji" alias="point_up_2" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f446.png">👆</g-emoji></li>
</ul>
<h3 dir="auto">Example Code</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class ModelNoneWithUncommonDefaults(BaseModel):
    x: Optional[str] = ...
    y: Optional[str] = &quot;y&quot;


@app.get(
    &quot;/exclude_none_with_uncommon_defaults&quot;,
    response_model=ModelNoneWithUncommonDefaults,
    response_model_exclude_none=True,
)
def get_exclude_none_with_uncommon_defaults() -&gt; ModelNoneWithUncommonDefaults:
    return ModelNoneWithUncommonDefaults(x=None, y=None)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">fastapi</span> <span class="pl-k">import</span> <span class="pl-v">FastAPI</span>
<span class="pl-k">from</span> <span class="pl-s1">pydantic</span> <span class="pl-k">import</span> <span class="pl-v">BaseModel</span>

<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">FastAPI</span>()


<span class="pl-k">class</span> <span class="pl-v">ModelNoneWithUncommonDefaults</span>(<span class="pl-v">BaseModel</span>):
    <span class="pl-s1">x</span>: <span class="pl-v">Optional</span>[<span class="pl-s1">str</span>] <span class="pl-c1">=</span> ...
    <span class="pl-s1">y</span>: <span class="pl-v">Optional</span>[<span class="pl-s1">str</span>] <span class="pl-c1">=</span> <span class="pl-s">"y"</span>


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">get</span>(</span>
<span class="pl-en">    <span class="pl-s">"/exclude_none_with_uncommon_defaults"</span>,</span>
<span class="pl-en">    <span class="pl-s1">response_model</span><span class="pl-c1">=</span><span class="pl-v">ModelNoneWithUncommonDefaults</span>,</span>
<span class="pl-en">    <span class="pl-s1">response_model_exclude_none</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,</span>
<span class="pl-en">)</span>
<span class="pl-k">def</span> <span class="pl-en">get_exclude_none_with_uncommon_defaults</span>() <span class="pl-c1">-&gt;</span> <span class="pl-v">ModelNoneWithUncommonDefaults</span>:
    <span class="pl-k">return</span> <span class="pl-v">ModelNoneWithUncommonDefaults</span>(<span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">y</span><span class="pl-c1">=</span><span class="pl-c1">None</span>)</pre></div>
<h3 dir="auto">Description</h3>
<ul dir="auto">
<li>This should return <code class="notranslate">{}</code></li>
<li>Actually will raise a ValidationError</li>
<li>If no error would have been thrown it would return <code class="notranslate">{"y": "y"}</code> although <code class="notranslate">y</code> was set to <code class="notranslate">None</code></li>
</ul>
<p dir="auto">See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1159432960" data-permission-text="Title is private" data-url="https://github.com/tiangolo/fastapi/issues/4647" data-hovercard-type="pull_request" data-hovercard-url="/tiangolo/fastapi/pull/4647/hovercard" href="https://github.com/tiangolo/fastapi/pull/4647">#4647</a> for a fix.</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">macOS</p>
<h3 dir="auto">Operating System Details</h3>
<p dir="auto">Current Monterey with M1 Pro chip - OS should not have any impact.</p>
<h3 dir="auto">FastAPI Version</h3>
<p dir="auto">0.74.1 (git master)</p>
<h3 dir="auto">Python Version</h3>
<p dir="auto">3.9.10</p>
<h3 dir="auto">Additional Context</h3>
<p dir="auto">I already created a PR for this, but was not sure if this is enough. If this now is a duplicate, sorry I will do this another way the next time around.</p>
<p dir="auto">The problem occurs as FastAPI will use <code class="notranslate">exclude_none</code> twice and by this manipulate the result data. Actually the current code only works for <code class="notranslate">Optional[...]</code> field types with a default value of <code class="notranslate">None</code>.</p>