<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 FastAPI

from pydantic import BaseModel

app = FastAPI()


class TypicalResponse(BaseModel):
    msg: str
    data: int


@app.get(&quot;/add/{x}/{y}&quot;)
async def add(x: int, y: int) -&gt; TypicalResponse:
    return TypicalResponse(msg=&quot;Done!&quot;, data=x + y)"><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">TypicalResponse</span>(<span class="pl-v">BaseModel</span>):
    <span class="pl-s1">msg</span>: <span class="pl-s1">str</span>
    <span class="pl-s1">data</span>: <span class="pl-s1">int</span>


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">get</span>(<span class="pl-s">"/add/{x}/{y}"</span>)</span>
<span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">add</span>(<span class="pl-s1">x</span>: <span class="pl-s1">int</span>, <span class="pl-s1">y</span>: <span class="pl-s1">int</span>) <span class="pl-c1">-&gt;</span> <span class="pl-v">TypicalResponse</span>:
    <span class="pl-k">return</span> <span class="pl-v">TypicalResponse</span>(<span class="pl-s1">msg</span><span class="pl-c1">=</span><span class="pl-s">"Done!"</span>, <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">x</span> <span class="pl-c1">+</span> <span class="pl-s1">y</span>)</pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">Open the automatic doc on this handler<br>
See no output schema defined<br>
I would like to use typing "-&gt; <em>Type</em>" for annotate response model.<br>
This is good for simple handlers.</p>
<h3 dir="auto">Wanted Solution</h3>
<p dir="auto">I would like to autodoc parse this typing same as "response_model=TypicalResponse"</p>
<h3 dir="auto">Wanted 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()

# Same
class TypicalResponse(BaseModel):
    msg: str
    data: int


@app.get(&quot;/add/{x}/{y}&quot;)
async def add(x: int, y: int) -&gt; TypicalResponse:
    return TypicalResponse(msg=&quot;Done!&quot;, data=x + y)"><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-c"># Same</span>
<span class="pl-k">class</span> <span class="pl-v">TypicalResponse</span>(<span class="pl-v">BaseModel</span>):
    <span class="pl-s1">msg</span>: <span class="pl-s1">str</span>
    <span class="pl-s1">data</span>: <span class="pl-s1">int</span>


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">get</span>(<span class="pl-s">"/add/{x}/{y}"</span>)</span>
<span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">add</span>(<span class="pl-s1">x</span>: <span class="pl-s1">int</span>, <span class="pl-s1">y</span>: <span class="pl-s1">int</span>) <span class="pl-c1">-&gt;</span> <span class="pl-v">TypicalResponse</span>:
    <span class="pl-k">return</span> <span class="pl-v">TypicalResponse</span>(<span class="pl-s1">msg</span><span class="pl-c1">=</span><span class="pl-s">"Done!"</span>, <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">x</span> <span class="pl-c1">+</span> <span class="pl-s1">y</span>)</pre></div>
<h3 dir="auto">Alternatives</h3>
<p dir="auto">I use kwarg "response_model" as single alternative<br>
But typing already defines the output model, necessary duplicate as result.</p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Linux</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.79.0</p>
<h3 dir="auto">Python Version</h3>
<p dir="auto">Python 3.9.0</p>
<h3 dir="auto">Additional Context</h3>
<p dir="auto">Without patch:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/109909821/182039698-0e3a5a77-eed4-4840-ab16-85c9333a7aef.png"><img src="https://user-images.githubusercontent.com/109909821/182039698-0e3a5a77-eed4-4840-ab16-85c9333a7aef.png" alt="изображение" style="max-width: 100%;"></a></p>
<p dir="auto">With patch:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/109909821/182039688-d23be71c-5e9c-4e2c-a0f6-1b35319936e7.png"><img src="https://user-images.githubusercontent.com/109909821/182039688-d23be71c-5e9c-4e2c-a0f6-1b35319936e7.png" alt="изображение" style="max-width: 100%;"></a></p>
<p dir="auto">I think second is better by avoid information duplication</p>
<p dir="auto">Meanwhile, solution is quite simple.<br>
One of the ways to implement (don't judge too much, that's first idea):</p>
<ol dir="auto">
<li>Open APIRouter class</li>
<li>Modify <code class="notranslate">self.add_api_route</code> by adding<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/109909821/182039543-ef289246-4ae4-49d3-bbc3-bb4947ffb239.png"><img src="https://user-images.githubusercontent.com/109909821/182039543-ef289246-4ae4-49d3-bbc3-bb4947ffb239.png" alt="изображение" style="max-width: 100%;"></a></li>
</ol>
<p dir="auto">May be dirty, so welcome to search another ways.</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"> 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"> 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"> 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"> I already checked if it is not related to FastAPI but to <a href="https://github.com/Redocly/redoc">ReDoc</a>.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> After submitting this, I commit to one of:
<ul dir="auto">
<li>Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.</li>
<li>I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.</li>
<li>Implement a Pull Request for a confirmed bug.</li>
</ul>
</li>
</ul>

<h3 dir="auto">Example</h3>
<p dir="auto">Here's a self-contained, <a href="https://stackoverflow.com/help/minimal-reproducible-example" rel="nofollow">minimal, reproducible, example</a> with my use case:</p>

<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, constr

app = FastAPI()

class CategoryBase(BaseModel):
  title: constr(min_length=4, max_length=30, regex=&quot;^[a-zA-Z0-9 _-]+$&quot;)  # type: ignore
  description: Optional[str]


class CategoryCreate(CategoryBase):
  pass


class CategoryPublic(CategoryBase):
  pass


@app.post(&quot;/&quot;, response_model=CategoryPublic, name=&quot;create-category&quot;, status_code=status.HTTP_201_CREATED)
async def create_category(
  new_category: CategoryCreate = Body(..., embed=True),
) -&gt; CategoryPublic:
  &quot;&quot;&quot;I'm the culprit of weird documentation.&quot;&quot;&quot;
  # some code ...


@app.post(&quot;/&quot;, response_model=CategoryPublic, name=&quot;create-category&quot;, status_code=status.HTTP_201_CREATED)
async def create_category(
  new_category: CategoryCreate = Body(..., embed=False),
) -&gt; CategoryPublic:
  &quot;&quot;&quot;I'm not.&quot;&quot;&quot;
  # some code ..."><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">constr</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">CategoryBase</span>(<span class="pl-v">BaseModel</span>):
  <span class="pl-s1">title</span>: <span class="pl-en">constr</span>(<span class="pl-s1">min_length</span><span class="pl-c1">=</span><span class="pl-c1">4</span>, <span class="pl-s1">max_length</span><span class="pl-c1">=</span><span class="pl-c1">30</span>, <span class="pl-s1">regex</span><span class="pl-c1">=</span><span class="pl-s">"^[a-zA-Z0-9 _-]+$"</span>)  <span class="pl-c"># type: ignore</span>
  <span class="pl-s1">description</span>: <span class="pl-v">Optional</span>[<span class="pl-s1">str</span>]


<span class="pl-k">class</span> <span class="pl-v">CategoryCreate</span>(<span class="pl-v">CategoryBase</span>):
  <span class="pl-k">pass</span>


<span class="pl-k">class</span> <span class="pl-v">CategoryPublic</span>(<span class="pl-v">CategoryBase</span>):
  <span class="pl-k">pass</span>


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">post</span>(<span class="pl-s">"/"</span>, <span class="pl-s1">response_model</span><span class="pl-c1">=</span><span class="pl-v">CategoryPublic</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"create-category"</span>, <span class="pl-s1">status_code</span><span class="pl-c1">=</span><span class="pl-s1">status</span>.<span class="pl-v">HTTP_201_CREATED</span>)</span>
<span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">create_category</span>(
  <span class="pl-s1">new_category</span>: <span class="pl-v">CategoryCreate</span> <span class="pl-c1">=</span> <span class="pl-v">Body</span>(..., <span class="pl-s1">embed</span><span class="pl-c1">=</span><span class="pl-c1">True</span>),
) <span class="pl-c1">-&gt;</span> <span class="pl-v">CategoryPublic</span>:
  <span class="pl-s">"""I'm the culprit of weird documentation."""</span>
  <span class="pl-c"># some code ...</span>


<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">post</span>(<span class="pl-s">"/"</span>, <span class="pl-s1">response_model</span><span class="pl-c1">=</span><span class="pl-v">CategoryPublic</span>, <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s">"create-category"</span>, <span class="pl-s1">status_code</span><span class="pl-c1">=</span><span class="pl-s1">status</span>.<span class="pl-v">HTTP_201_CREATED</span>)</span>
<span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">create_category</span>(
  <span class="pl-s1">new_category</span>: <span class="pl-v">CategoryCreate</span> <span class="pl-c1">=</span> <span class="pl-v">Body</span>(..., <span class="pl-s1">embed</span><span class="pl-c1">=</span><span class="pl-c1">False</span>),
) <span class="pl-c1">-&gt;</span> <span class="pl-v">CategoryPublic</span>:
  <span class="pl-s">"""I'm not."""</span>
  <span class="pl-c"># some code ...</span></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto"><em>TLDR:</em><br>
How to have a nice documentation with the Body(..., embed=True)</p>
<p dir="auto">I'm trying to have a nice documentation for the api I'm creating, and I noticed that when using embed=True for the Body parameter, a new schema is created. This not only create two schemas (one for the Pydantic model, and one for the Body), but the name used are not very readable.</p>
<p dir="auto">I tried to look in the documentation, but I did not see anything about changing the name, or (better) simply preventing the documentation of a somewhat duplicate schema</p>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>
<p dir="auto">OS: Docker image of python:3.8</p>
</li>
<li>
<p dir="auto">FastAPI Version: 0.63.0</p>
</li>
</ul>
<h3 dir="auto">Additional context</h3>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/25052677/115381628-a7c3eb80-a1cb-11eb-8d72-0530a4f59c5d.png"><img src="https://user-images.githubusercontent.com/25052677/115381628-a7c3eb80-a1cb-11eb-8d72-0530a4f59c5d.png" alt="fastapi" style="max-width: 100%;"></a></p>