lqs
d20566fe07
Some checks failed
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Issue Manager / issue-manager (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
29 lines
524 B
Python
29 lines
524 B
Python
from typing import List, Union
|
|
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class Item(BaseModel):
|
|
name: str
|
|
description: Union[str, None] = None
|
|
|
|
|
|
app = FastAPI(separate_input_output_schemas=False)
|
|
|
|
|
|
@app.post("/items/")
|
|
def create_item(item: Item):
|
|
return item
|
|
|
|
|
|
@app.get("/items/")
|
|
def read_items() -> List[Item]:
|
|
return [
|
|
Item(
|
|
name="Portal Gun",
|
|
description="Device to travel through the multi-rick-verse",
|
|
),
|
|
Item(name="Plumbus"),
|
|
]
|