<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@app.on_event(&quot;startup&quot;)
async def startup_event(background_tasks: BackgroundTasks):
    send_notification(background_tasks)"><pre class="notranslate"><code class="notranslate">@app.on_event("startup")
async def startup_event(background_tasks: BackgroundTasks):
    send_notification(background_tasks)
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2021-05-12 15:31:40,350 - MainThread - ERROR - Traceback (most recent call last):
  File &quot;F:\douyin_spider_fast_api\venv\lib\site-packages\starlette\routing.py&quot;, line 540, in lifespan
    async for item in self.lifespan_context(app):
  File &quot;F:\douyin_spider_fast_api\venv\lib\site-packages\starlette\routing.py&quot;, line 481, in default_lifespan
    await self.startup()
  File &quot;F:\douyin_spider_fast_api\venv\lib\site-packages\starlette\routing.py&quot;, line 516, in startup
    await handler()
TypeError: startup_event() missing 1 required positional argument: 'background_tasks'"><pre class="notranslate"><code class="notranslate">2021-05-12 15:31:40,350 - MainThread - ERROR - Traceback (most recent call last):
  File "F:\douyin_spider_fast_api\venv\lib\site-packages\starlette\routing.py", line 540, in lifespan
    async for item in self.lifespan_context(app):
  File "F:\douyin_spider_fast_api\venv\lib\site-packages\starlette\routing.py", line 481, in default_lifespan
    await self.startup()
  File "F:\douyin_spider_fast_api\venv\lib\site-packages\starlette\routing.py", line 516, in startup
    await handler()
TypeError: startup_event() missing 1 required positional argument: 'background_tasks'
</code></pre></div>
<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 typing import Union
from fastapi import FastAPI

app = FastAPI(openapi_tags=[{'name': 'items', 'description': 'items1'}, {'name': 'items', 'description': 'items2'}])

@app.get(&quot;/items&quot;, tags=[&quot;items&quot;])
def read_item(q: Union[str, None] = None):
    return {&quot;q&quot;: q}"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">typing</span> <span class="pl-k">import</span> <span class="pl-v">Union</span>
<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-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">FastAPI</span>(<span class="pl-s1">openapi_tags</span><span class="pl-c1">=</span>[{<span class="pl-s">'name'</span>: <span class="pl-s">'items'</span>, <span class="pl-s">'description'</span>: <span class="pl-s">'items1'</span>}, {<span class="pl-s">'name'</span>: <span class="pl-s">'items'</span>, <span class="pl-s">'description'</span>: <span class="pl-s">'items2'</span>}])

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">get</span>(<span class="pl-s">"/items"</span>, <span class="pl-s1">tags</span><span class="pl-c1">=</span>[<span class="pl-s">"items"</span>])</span>
<span class="pl-k">def</span> <span class="pl-en">read_item</span>(<span class="pl-s1">q</span>: <span class="pl-v">Union</span>[<span class="pl-s1">str</span>, <span class="pl-c1">None</span>] <span class="pl-c1">=</span> <span class="pl-c1">None</span>):
    <span class="pl-k">return</span> {<span class="pl-s">"q"</span>: <span class="pl-s1">q</span>}</pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">The OpenAPI <a href="https://swagger.io/specification/#openapi-object" rel="nofollow">specification</a> states that "Each tag name in the list MUST be unique." for the OpenAPI object.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -s http://localhost:8000/openapi.json | jq .tags
[
  {
    &quot;name&quot;: &quot;items&quot;,
    &quot;description&quot;: &quot;items1&quot;
  },
  {
    &quot;name&quot;: &quot;items&quot;,
    &quot;description&quot;: &quot;items2&quot;
  }
]"><pre class="notranslate">$ curl -s http://localhost:8000/openapi.json <span class="pl-k">|</span> jq .tags
[
  {
    <span class="pl-s"><span class="pl-pds">"</span>name<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>items<span class="pl-pds">"</span></span>,
    <span class="pl-s"><span class="pl-pds">"</span>description<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>items1<span class="pl-pds">"</span></span>
  },
  {
    <span class="pl-s"><span class="pl-pds">"</span>name<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>items<span class="pl-pds">"</span></span>,
    <span class="pl-s"><span class="pl-pds">"</span>description<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>items2<span class="pl-pds">"</span></span>
  }
]</pre></div>
<p dir="auto">Also Swagger shows the items operation to be with <code class="notranslate">items1</code> tag, while ReDoc shows <code class="notranslate">items2</code>.</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>