Issue 1:
First check

I added a very descriptive title to this issue.

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

I searched the FastAPI documentation, with the integrated search.

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

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

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

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

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

After submitting this, I commit to one of:

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

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

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

from pydantic import BaseModel
from typing import Set
from fastapi import FastAPI

app = FastAPI()

class Request(BaseModel):
request_id: str

def __hash__(self):
return hash(self.request_id)

class Requests(BaseModel):
request_ids: Set[Request]

@app.post("/test", response_model=Requests)
def read_root(data: Requests):
return data

Description

Thanks to the Set feature, the deduplication step works ok for data IN. however it fails for data OUT:

curl -X 'POST' 'http://127.0.0.1:8000/test' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{

"request_ids": [
{
"request_id": "c04ca7ee-f62c-4372-b667-73ace53c69c2"
}
]
}'

File "pydantic/main.py", line 504, in pydantic.main.BaseModel.dict

File "pydantic/main.py", line 869, in _iter
File "pydantic/main.py", line 810, in pydantic.main.BaseModel._get_value
TypeError: unhashable type: 'dict'

Environment

OS: Ubuntu 20.04.2 LTS

FastAPI Version [e.g. 0.3.0]: 0.63.0

Python Version: 3.8.5

Issue 2:
I'm developing a public api where we'll probably want to nest routes at least a couple of levels deep, using the initial route to determine the 'app' that the rest of the content belongs to.

our target url structure is along the lines of

/api/v1/apps/{shortcode}

/api/v1/apps/{shortcode}/people/

/api/v1/apps/{shortcode}/people/{id}

etc. etc...

I'd really like to take advantage of the APIRouter classes to do this as we're likely to have a lot of endpoints and models but I can't find a way to ensure the 'shortcode' parameter here is passed to child routers, is there any way to do that?

currently I'm doing stuff like this:

app.py

from app.people.routes import router as people_router
from app.routes import router as main_router

app = FastAPI()
app.debug = settings.DEBUG

main_router.include_router(people_router, prefix='/{shortcode}/people')
app.include_router(main_router, prefix='/apps')

This works ok, but the {shortcode} parameter is not included in the auto-generated documentation ( though it is available in the view functions ). I'd rather not have to define every view function individually with prefixed like @router.route('/{shortcode}/people/{id}) ... if I can avoid it somehow?