Unexpected TypeError When Using Pydantic Models with FastAPI and Nested Data Structures
I'm integrating two systems and I'm working on a FastAPI application using Pydantic for data validation... I have defined a model with nested data structures, but I'm running into a `TypeError` when trying to validate the input data. Here's my Pydantic model: ```python from pydantic import BaseModel, conlist class Item(BaseModel): id: int name: str class Order(BaseModel): items: conlist(Item) total: float ``` When I send a POST request to my FastAPI endpoint with the following JSON payload: ```json { "items": [ {"id": 1, "name": "Widget"}, {"id": 2, "name": "Gadget"} ], "total": 45.0 } ``` I receive this behavior: ``` TypeError: 'Item' object is not subscriptable ``` I've tried updating Pydantic to the latest version (1.10.0) and made sure that I'm using Python 3.9. I've also checked that the input data structure matches what the model expects, but the behavior continues. I've seen similar issues online, but they usually relate to directly accessing attributes of a model instance, which isn't the case here. Could this be related to how FastAPI is interpreting the request body? I've tried serializing the data before sending it and confirming that my FastAPI route is correctly set up: ```python from fastapi import FastAPI app = FastAPI() @app.post("/orders/") async def create_order(order: Order): return order ``` I would appreciate any insights into what might be causing this `TypeError` and how to resolve it. Thanks! Could someone point me to the right documentation?