title: FastAPI return Dictionary
body: <p>I'm trying to return a dictionary in FastAPI.  I've scoured their site and can't find anything that works. Maybe I'm going about this completely wrong but I would imagine I could pass it a dictionary of results and it would return them as structured in the dictionary? The end goal is to pull this information out of a database but for simplicity and testing I've narrowed it down to this.</p>
  <pre class="lang-py prettyprint-override"><code>from typing import List, Optional
     
  from fastapi import FastAPI
  from pydantic import BaseModel
      
  app = FastAPI()
      
  class Item(BaseModel):
      name: str
      description: Optional[str] = None
      price: float
      tax: float = 10.5
      tags: List[str] = []
      
  class Items(BaseModel):
      items: List[Item]
      
  itemslist = {
      &quot;foo&quot;: {&quot;name&quot;: &quot;Foo&quot;, &quot;price&quot;: 50.2},
      &quot;bar&quot;: {&quot;name&quot;: &quot;Bar&quot;, &quot;description&quot;: &quot;The bartenders&quot;, &quot;price&quot;: 62, &quot;tax&quot;: 20.2},
      &quot;baz&quot;: {&quot;name&quot;: &quot;Baz&quot;, &quot;description&quot;: None, &quot;price&quot;: 50.2, &quot;tax&quot;: 10.5, &quot;tags&quot;: []},
  }
     
  @app.get(&quot;/items&quot;, response_model=Items, response_model_exclude_unset=True)
  async def read_item(Items: dict):
      return Items(items=itemslist)
  </code></pre>
  <p>When I open the page I get</p>
  <pre class="lang-json prettyprint-override"><code>{
  &quot;detail&quot;: [
    {
      &quot;loc&quot;: [
        &quot;body&quot;
      ],
      &quot;msg&quot;: &quot;field required&quot;,
      &quot;type&quot;: &quot;value_error.missing&quot;
      }
    ]
  }
  </code></pre>
  <p>In the console log I see</p>
  <pre class="lang-none prettyprint-override"><code>127.0.0.1:53845 - &quot;GET /items HTTP/1.1&quot; 422 Unprocessable Entity
  </code></pre>