<p dir="auto">How do we add additional responses (e.g. 401, 403, 500, etc..) to the documentation other than the default 200 response and the 422 validation error response?</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 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>
</ul>
<h3 dir="auto">Description</h3>
<p dir="auto">I have a database pool with which I have to define two exact method except for the <code class="notranslate">@asynccontextmanager</code> decorator.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class Pool:
    async def get_con(self):
        con = await self.pool.acquire()
        try:
            yield con
        finally:
            await self.pool.release(con)

    @asynccontextmanager
    async def __call__(self):
        con = await self.pool.acquire()
        try:
            yield con
        finally:
            await self.pool.release(con)

pool = Pool()"><pre class="notranslate"><code class="notranslate">class Pool:
    async def get_con(self):
        con = await self.pool.acquire()
        try:
            yield con
        finally:
            await self.pool.release(con)

    @asynccontextmanager
    async def __call__(self):
        con = await self.pool.acquire()
        try:
            yield con
        finally:
            await self.pool.release(con)

pool = Pool()
</code></pre></div>
<p dir="auto">One is used in my internal code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="async with pool() as con:
    con.fetch()"><pre class="notranslate"><code class="notranslate">async with pool() as con:
    con.fetch()
</code></pre></div>
<p dir="auto">And the other with the <code class="notranslate">Depends</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@router.get(&quot;/item/{id}&quot;)
async def get(id: UUID, db: Connection = Depends(pool.get_con)):"><pre class="notranslate"><code class="notranslate">@router.get("/item/{id}")
async def get(id: UUID, db: Connection = Depends(pool.get_con)):
</code></pre></div>
<p dir="auto">In the documentation there is a line which states</p>
<blockquote>
<p dir="auto">But you don't have to use the decorators for FastAPI dependencies (and you shouldn't).</p>
</blockquote>
<p dir="auto">If you try:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@router.get(&quot;/item/{id}&quot;)
async def get(id: UUID, db: Connection = Depends(pool)):"><pre class="notranslate"><code class="notranslate">@router.get("/item/{id}")
async def get(id: UUID, db: Connection = Depends(pool)):
</code></pre></div>
<p dir="auto">I actually get an <code class="notranslate">AttributeError</code>. I'm assuming <code class="notranslate">pool</code> is yieled instead of <code class="notranslate">pool.__call__</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="AttributeError: '_AsyncGeneratorContextManager' object has no attribute 'fetchrow'"><pre class="notranslate"><code class="notranslate">AttributeError: '_AsyncGeneratorContextManager' object has no attribute 'fetchrow'
</code></pre></div>
<p dir="auto">Which makes it pretty clear that I cannot use a contextmanager in a <code class="notranslate">Depends</code>, but this creates duplicate and non consistent code when getting a db connection.</p>
<p dir="auto">Is this the way it is? Can <code class="notranslate">Depends</code> work with both regular yields and contextmanagers directly?</p>