Sync fastapi docs from 50fa3f7c on 2026-01-11
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
from fastapi import FastAPI, Request
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
def magic_data_reader(raw_body: bytes):
|
||||
return {
|
||||
"size": len(raw_body),
|
||||
"content": {
|
||||
"name": "Maaaagic",
|
||||
"price": 42,
|
||||
"description": "Just kiddin', no magic here. ✨",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@app.post(
|
||||
"/items/",
|
||||
openapi_extra={
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"required": ["name", "price"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"price": {"type": "number"},
|
||||
"description": {"type": "string"},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
},
|
||||
},
|
||||
)
|
||||
async def create_item(request: Request):
|
||||
raw_body = await request.body()
|
||||
data = magic_data_reader(raw_body)
|
||||
return data
|
||||
Reference in New Issue
Block a user