Replies: 4 comments
-
This is more of a pydantic question. Have you tried |
Beta Was this translation helpful? Give feedback.
-
@phy25
|
Beta Was this translation helpful? Give feedback.
-
from fastapi import FastAPI
from pydantic import BaseModel, Field
class Item(BaseModel):
time_from: str = Field(None, alias='from')
app = FastAPI()
@app.post("/")
async def create_item(item: Item):
return item |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help here @phy25 ! 🙇♂️ 🍰 Thanks @jsrimr for reporting back and closing the issue 👍 |
Beta Was this translation helpful? Give feedback.
-
I have a request from grafana, and the body is json like as below.
as you can see, when I model this json, I have to use "from" keyword which is already reserved keyword.
I modelled like this. However, when I launch the process, I got syntax error. So, I want to know how can I use the reserved keyword as request body? I cannot change the body reqeust keyword because request is from the grafana json tool which is out of my control.
thanks!
Beta Was this translation helpful? Give feedback.
All reactions