Sync fastapi docs from 11614be9 on 2026-03-11
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
from typing import Union
|
||||
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: Union[str, None] = None
|
||||
size: float
|
||||
@@ -1,18 +0,0 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: Union[str, None] = None
|
||||
size: float
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.post("/items/")
|
||||
async def create_item(item: Item) -> Item:
|
||||
return item
|
||||
@@ -1,25 +0,0 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel as BaseModelV2
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: Union[str, None] = None
|
||||
size: float
|
||||
|
||||
|
||||
class ItemV2(BaseModelV2):
|
||||
name: str
|
||||
description: Union[str, None] = None
|
||||
size: float
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.post("/items/", response_model=ItemV2)
|
||||
async def create_item(item: Item):
|
||||
return item
|
||||
@@ -1,19 +0,0 @@
|
||||
from typing import Annotated, Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.temp_pydantic_v1_params import Body
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: Union[str, None] = None
|
||||
size: float
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.post("/items/")
|
||||
async def create_item(item: Annotated[Item, Body(embed=True)]) -> Item:
|
||||
return item
|
||||
Reference in New Issue
Block a user