pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
377 B
17 lines
377 B
from typing import Optional
|
|
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class ItemSearch(BaseModel):
|
|
keyword: str
|
|
min_price: Optional[float] = None
|
|
max_price: Optional[float] = None
|
|
|
|
|
|
@app.query("/items/")
|
|
async def search_items(search_params: ItemSearch):
|
|
return {"message": "Searching items", "search_params": search_params}
|