mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-06 10:36:39 +00:00
33 lines
545 B
Python
33 lines
545 B
Python
from typing import List, Set
|
|
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
from pydantic.types import UrlStr
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class Image(BaseModel):
|
|
url: UrlStr
|
|
name: str
|
|
|
|
|
|
class Item(BaseModel):
|
|
name: str
|
|
description: str = None
|
|
price: float
|
|
tax: float = None
|
|
tags: Set[str] = []
|
|
image: List[Image] = None
|
|
|
|
|
|
class Offer(BaseModel):
|
|
name: str
|
|
description: str = None
|
|
price: float
|
|
items: List[Item]
|
|
|
|
|
|
@app.post("/offers/")
|
|
async def create_offer(*, offer: Offer):
|
|
return offer
|