13 changed files with 2 additions and 95 deletions
@ -1,17 +0,0 @@ |
|||||
from typing import Union |
|
||||
|
|
||||
from fastapi import FastAPI, Path, Query |
|
||||
from typing_extensions import Annotated |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@app.get("/items/{item_id}") |
|
||||
async def read_items( |
|
||||
item_id: Annotated[int, Path(title="The ID of the item to get")], |
|
||||
q: Annotated[Union[str, None], Query(alias="item-query")] = None, |
|
||||
): |
|
||||
results = {"item_id": item_id} |
|
||||
if q: |
|
||||
results.update({"q": q}) |
|
||||
return results |
|
||||
@ -1,14 +0,0 @@ |
|||||
from fastapi import FastAPI, Path |
|
||||
from typing_extensions import Annotated |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@app.get("/items/{item_id}") |
|
||||
async def read_items( |
|
||||
q: str, item_id: Annotated[int, Path(title="The ID of the item to get")] |
|
||||
): |
|
||||
results = {"item_id": item_id} |
|
||||
if q: |
|
||||
results.update({"q": q}) |
|
||||
return results |
|
||||
@ -1,14 +0,0 @@ |
|||||
from fastapi import FastAPI, Path |
|
||||
from typing_extensions import Annotated |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@app.get("/items/{item_id}") |
|
||||
async def read_items( |
|
||||
item_id: Annotated[int, Path(title="The ID of the item to get")], q: str |
|
||||
): |
|
||||
results = {"item_id": item_id} |
|
||||
if q: |
|
||||
results.update({"q": q}) |
|
||||
return results |
|
||||
@ -1,14 +0,0 @@ |
|||||
from fastapi import FastAPI, Path |
|
||||
from typing_extensions import Annotated |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@app.get("/items/{item_id}") |
|
||||
async def read_items( |
|
||||
item_id: Annotated[int, Path(title="The ID of the item to get", ge=1)], q: str |
|
||||
): |
|
||||
results = {"item_id": item_id} |
|
||||
if q: |
|
||||
results.update({"q": q}) |
|
||||
return results |
|
||||
@ -1,15 +0,0 @@ |
|||||
from fastapi import FastAPI, Path |
|
||||
from typing_extensions import Annotated |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@app.get("/items/{item_id}") |
|
||||
async def read_items( |
|
||||
item_id: Annotated[int, Path(title="The ID of the item to get", gt=0, le=1000)], |
|
||||
q: str, |
|
||||
): |
|
||||
results = {"item_id": item_id} |
|
||||
if q: |
|
||||
results.update({"q": q}) |
|
||||
return results |
|
||||
@ -1,19 +0,0 @@ |
|||||
from fastapi import FastAPI, Path, Query |
|
||||
from typing_extensions import Annotated |
|
||||
|
|
||||
app = FastAPI() |
|
||||
|
|
||||
|
|
||||
@app.get("/items/{item_id}") |
|
||||
async def read_items( |
|
||||
*, |
|
||||
item_id: Annotated[int, Path(title="The ID of the item to get", ge=0, le=1000)], |
|
||||
q: str, |
|
||||
size: Annotated[float, Query(gt=0, lt=10.5)], |
|
||||
): |
|
||||
results = {"item_id": item_id} |
|
||||
if q: |
|
||||
results.update({"q": q}) |
|
||||
if size: |
|
||||
results.update({"size": size}) |
|
||||
return results |
|
||||
Loading…
Reference in new issue