<h3 dir="auto">Example</h3>
<p dir="auto">Set up a brand new FastAPI venv:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="virtualenv venv
source venv/bin/activate
pip install fastapi[all] pytest"><pre class="notranslate"><code class="notranslate">virtualenv venv
source venv/bin/activate
pip install fastapi[all] pytest
</code></pre></div>
<p dir="auto">Copy/paste example from the testing docs at <a href="https://fastapi.tiangolo.com/tutorial/testing/" rel="nofollow">https://fastapi.tiangolo.com/tutorial/testing/</a>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from fastapi import FastAPI
from fastapi.testclient import TestClient

app = FastAPI()


@app.get(&quot;/&quot;)
async def read_main():
    return {&quot;msg&quot;: &quot;Hello World&quot;}


client = TestClient(app)


def test_read_main():
    response = client.get(&quot;/&quot;)
    assert response.status_code == 200
    assert response.json() == {&quot;msg&quot;: &quot;Hello World&quot;}"><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">fastapi</span>.<span class="pl-s1">testclient</span> <span class="pl-k">import</span> <span class="pl-v">TestClient</span>

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


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">get</span>(<span class="pl-s">"/"</span>)</span>
<span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">read_main</span>():
    <span class="pl-k">return</span> {<span class="pl-s">"msg"</span>: <span class="pl-s">"Hello World"</span>}


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


<span class="pl-k">def</span> <span class="pl-en">test_read_main</span>():
    <span class="pl-s1">response</span> <span class="pl-c1">=</span> <span class="pl-s1">client</span>.<span class="pl-en">get</span>(<span class="pl-s">"/"</span>)
    <span class="pl-k">assert</span> <span class="pl-s1">response</span>.<span class="pl-s1">status_code</span> <span class="pl-c1">==</span> <span class="pl-c1">200</span>
    <span class="pl-k">assert</span> <span class="pl-s1">response</span>.<span class="pl-en">json</span>() <span class="pl-c1">==</span> {<span class="pl-s">"msg"</span>: <span class="pl-s">"Hello World"</span>}</pre></div>
<p dir="auto">Observe that the tests take 30s to run. If you add another .get call, they take 60s.</p>
<h3 dir="auto">Description</h3>
<p dir="auto">On Mac with new install of FastAPI, every call to <code class="notranslate">TestClient.get()</code> takes exactly 30s to complete. The response is correct.</p>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>
<p dir="auto">OS: macOS</p>
</li>
<li>
<p dir="auto">FastAPI Version: 0.56.1</p>
</li>
<li>
<p dir="auto">Python version:</p>
</li>
<li>
<p dir="auto">Python version: 3.6</p>
</li>
</ul>
<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 👆</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 APIRouter, FastAPI, Request
from fastapi.responses import JSONResponse

app = FastAPI()
router = APIRouter(tags=[&quot;items&quot;, &quot;items&quot;])

@router.get(&quot;/items/&quot;)
def read_items(request: Request):
    return JSONResponse({&quot;hello&quot;: &quot;world&quot;})

app.include_router(router)

# or just simply
@app.get('/test/', tags=[&quot;test&quot;, &quot;test&quot;])
def read_test():
    return &quot;test&quot;"><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">APIRouter</span>, <span class="pl-v">FastAPI</span>, <span class="pl-v">Request</span>
<span class="pl-k">from</span> <span class="pl-s1">fastapi</span>.<span class="pl-s1">responses</span> <span class="pl-k">import</span> <span class="pl-v">JSONResponse</span>

<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">FastAPI</span>()
<span class="pl-s1">router</span> <span class="pl-c1">=</span> <span class="pl-v">APIRouter</span>(<span class="pl-s1">tags</span><span class="pl-c1">=</span>[<span class="pl-s">"items"</span>, <span class="pl-s">"items"</span>])

<span class="pl-en">@<span class="pl-s1">router</span>.<span class="pl-en">get</span>(<span class="pl-s">"/items/"</span>)</span>
<span class="pl-k">def</span> <span class="pl-en">read_items</span>(<span class="pl-s1">request</span>: <span class="pl-v">Request</span>):
    <span class="pl-k">return</span> <span class="pl-v">JSONResponse</span>({<span class="pl-s">"hello"</span>: <span class="pl-s">"world"</span>})

<span class="pl-s1">app</span>.<span class="pl-en">include_router</span>(<span class="pl-s1">router</span>)

<span class="pl-c"># or just simply</span>
<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">get</span>(<span class="pl-s">'/test/'</span>, <span class="pl-s1">tags</span><span class="pl-c1">=</span>[<span class="pl-s">"test"</span>, <span class="pl-s">"test"</span>])</span>
<span class="pl-k">def</span> <span class="pl-en">read_test</span>():
    <span class="pl-k">return</span> <span class="pl-s">"test"</span></pre></div>
<h3 dir="auto">Description</h3>
<ul dir="auto">
<li>Open the browser and call endpoint '/redoc'</li>
<li>Observe duplicate entries for /items and /test:</li>
</ul>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/58346970/197496996-4aba111c-8438-4d6e-b0c5-e27b1977f7b5.png"><img src="https://user-images.githubusercontent.com/58346970/197496996-4aba111c-8438-4d6e-b0c5-e27b1977f7b5.png" alt="Screenshot 2022-10-24 at 11 23 31" style="max-width: 100%;"></a></p>
<p dir="auto">This is caused by treating tags as a List of strings or enum inside APIRouter.<br>
The root cause is duplicate tags ending up in openapi.json:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/58346970/197497176-b4201979-7b44-4459-aeec-287a855fd913.png"><img src="https://user-images.githubusercontent.com/58346970/197497176-b4201979-7b44-4459-aeec-287a855fd913.png" alt="Screenshot 2022-10-24 at 11 22 35" style="max-width: 100%;"></a></p>
<p dir="auto">Using Class Based Views in fastapi-utils trigger this bug (external package).</p>
<p dir="auto">Added a fix for the issue in PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1420525091" data-permission-text="Title is private" data-url="https://github.com/tiangolo/fastapi/issues/5533" data-hovercard-type="pull_request" data-hovercard-url="/tiangolo/fastapi/pull/5533/hovercard" href="https://github.com/tiangolo/fastapi/pull/5533">#5533</a> (with test)</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">macOS</p>
<h3 dir="auto">Operating System Details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">FastAPI Version</h3>
<p dir="auto">0.85.1</p>
<h3 dir="auto">Python Version</h3>
<p dir="auto">Python 3.10.8</p>
<h3 dir="auto">Additional Context</h3>
<p dir="auto"><em>No response</em></p>