Issue 1:
I use Depends() to populate model from query parameters. Recently noticed, that dependency resolving somehow ignores pydantic model configuration. According to #1474, it may be the same issue.

Environment

OS: linux

FastAPI Version [e.g. 0.3.0]: 0.61

Python version: 3.8.2

Testcase

from pydantic import BaseModel, Field
from fastapi import Depends, FastAPI

app = FastAPI()

class TestParams(BaseModel):
class Config:
allow_population_by_field_name = True

param: bool = Field(False, alias='alias')

@app.get('/')
async def main(params: TestParams = Depends()):
return params.dict()

Expected results

$ curl "http://127.0.0.1:8000/?param=true"
{"param":true}

$ curl "http://127.0.0.1:8000/?alias=true"
{"param":true}

Actual results

$ curl "http://127.0.0.1:8000/?param=true"
{"param":false}

$ curl "http://127.0.0.1:8000/?alias=true"
{"param":true}

Issue 2:
First check

[ x] I added a very descriptive title to this issue.

[ x] I used the GitHub search to find a similar issue and didn't find it.

[ x] I searched the FastAPI documentation, with the integrated search.

[ x] I already searched in Google "How to X in FastAPI" and didn't find any information.

[ x] I already read and followed all the tutorial in the docs and didn't find an answer.

[ x] I already checked if it is not related to FastAPI but to Pydantic.

[ x] I already checked if it is not related to FastAPI but to Swagger UI.

[ x] I already checked if it is not related to FastAPI but to ReDoc.

[ x] After submitting this, I commit to:

Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.

Or, 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.

Implement a Pull Request for a confirmed bug.

Example

I'm sorry if this is a duplicate or I've missed how to do this. I have scoured the docs and github issues.

Here's a self-contained minimal, reproducible, example with my use case:

# URL request: localhost/api/weather/portland?state=OR&country=US&units=imperial

from fastapi import FastAPI
from pydantic import BaseModel
from typing import Optional
import uvicorn

class Location(BaseModel):
city: str
country: Optional[str] = 'US'
state: Optional[str] = None
units: Optional[str] = 'metric'

app = FastAPI()

# What we have is:
@app.get('/api/weather/{city}')
async def weather(city: str,
country: Optional[str] = None,
state: Optional[str] = None,
units: str = 'metric'):
# work with city, country, etc.
return Location(city=city, country=country, state=state, units=units)

# What I want:
# @app.get('/api/weather_binding/{city}')
# async def weather(loc: Location):
# work with loc.city, loc.country, etc.
# Where the binding inputs to the Pydantic model are basically:
# data = {
# **request.query_params,
# **request.headers,
# **dict(await request.form()), # only if the form dependencies are installed
# **request.path_params
# }
# return loc

uvicorn.run(app)

Description

Open the browser and call the endpoint /api/weather/portland?state=OR&country=US&units=imperial.

It returns a JSON:

{
"city": "portland",
"country": null,
"state": "OR",
"units": "metric"
}

I would like to use model binding just like we have for JSON POST of inbound Pydantic models but combining all these elements.

The solution you would like

Basically, I can do this already with this step:

data = {
**request.query_params,
**request.headers,
**dict(await request.form()),
**request.path_params
}
loc = Location(**data)

But that's a drag and having the framework do this, even with an opt in flag in the route (like bind_all=True) would be fantastic.

Describe alternatives you've considered

I've consider just using the lines of code above more or less on method, but that doesn't seem to fit with the clean automatic nature of the platform.

Environment

OS: macOS

FastAPI Version: 0.61.1

Python version: 3.9

Additional context

None