title: Query parameters from pydantic model
body: <p>Is there a way to convert a pydantic model to query parameters in fastapi? </p>
  
  <p>Some of my endpoints pass parameters via the body, but some others pass them directly in the query. All this endpoints share the same data model, for example: </p>
  
  <pre class="lang-py prettyprint-override"><code>class Model(BaseModel):
      x: str
      y: str
  </code></pre>
  
  <p>I would like to avoid duplicating my definition of this model in the definition of my "query-parameters endpoints", like for example <code>test_query</code> in this code:</p>
  
  <pre class="lang-py prettyprint-override"><code>class Model(BaseModel):
      x: str
      y: str
  
  @app.post("/test-body")
  def test_body(model: Model): pass
  
  @app.post("/test-query-params")
  def test_query(x: str, y: str): pass
  </code></pre>
  
  <p>What's the cleanest way of doing this?</p>