mirror of https://github.com/tiangolo/fastapi.git
* Fix for - [FEATURE] Remove *, where it's not needed #1234 * 🔥 Remove unnecessary arg *, * 🎨 Update docs format highlight lines Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
parent
1b2a7546af
commit
7e2518350a
|
|
@ -33,7 +33,7 @@ The same way you can pass extra info to `Field`, you can do the same with `Path`
|
|||
|
||||
For example, you can pass an `example` for a body request to `Body`:
|
||||
|
||||
```Python hl_lines="20 21 22 23 24 25"
|
||||
```Python hl_lines="19 20 21 22 23 24"
|
||||
{!../../../docs_src/schema_extra_example/tutorial003.py!}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item = Body(..., embed=True)):
|
||||
async def update_item(item_id: int, item: Item = Body(..., embed=True)):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ class User(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item, user: User):
|
||||
async def update_item(item_id: int, item: Item, user: User):
|
||||
results = {"item_id": item_id, "item": item, "user": user}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class User(BaseModel):
|
|||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(
|
||||
*, item_id: int, item: Item, user: User, importance: int = Body(...)
|
||||
item_id: int, item: Item, user: User, importance: int = Body(...)
|
||||
):
|
||||
results = {"item_id": item_id, "item": item, "user": user, "importance": importance}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item = Body(..., embed=True)):
|
||||
async def update_item(item_id: int, item: Item = Body(..., embed=True)):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -28,5 +28,5 @@ class Offer(BaseModel):
|
|||
|
||||
|
||||
@app.post("/offers/")
|
||||
async def create_offer(*, offer: Offer):
|
||||
async def create_offer(offer: Offer):
|
||||
return offer
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ class Image(BaseModel):
|
|||
|
||||
|
||||
@app.post("/images/multiple/")
|
||||
async def create_multiple_images(*, images: List[Image]):
|
||||
async def create_multiple_images(images: List[Image]):
|
||||
return images
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ app = FastAPI()
|
|||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(*, ads_id: str = Cookie(None)):
|
||||
async def read_items(ads_id: str = Cookie(None)):
|
||||
return {"ads_id": ads_id}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ def fake_save_user(user_in: UserIn):
|
|||
|
||||
|
||||
@app.post("/user/", response_model=UserOut)
|
||||
async def create_user(*, user_in: UserIn):
|
||||
async def create_user(user_in: UserIn):
|
||||
user_saved = fake_save_user(user_in)
|
||||
return user_saved
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ def fake_save_user(user_in: UserIn):
|
|||
|
||||
|
||||
@app.post("/user/", response_model=UserOut)
|
||||
async def create_user(*, user_in: UserIn):
|
||||
async def create_user(user_in: UserIn):
|
||||
user_saved = fake_save_user(user_in)
|
||||
return user_saved
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ app = FastAPI()
|
|||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(*, user_agent: str = Header(None)):
|
||||
async def read_items(user_agent: str = Header(None)):
|
||||
return {"User-Agent": user_agent}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ app = FastAPI()
|
|||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(*, strange_header: str = Header(None, convert_underscores=False)):
|
||||
async def read_items(strange_header: str = Header(None, convert_underscores=False)):
|
||||
return {"strange_header": strange_header}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.post("/items/", response_model=Item, summary="Create an item")
|
||||
async def create_item(*, item: Item):
|
||||
async def create_item(item: Item):
|
||||
"""
|
||||
Create an item with all the information:
|
||||
|
||||
|
|
|
|||
|
|
@ -15,5 +15,5 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
|
||||
async def create_item(*, item: Item):
|
||||
async def create_item(item: Item):
|
||||
return item
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.post("/items/", response_model=Item, tags=["items"])
|
||||
async def create_item(*, item: Item):
|
||||
async def create_item(item: Item):
|
||||
return item
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ class Item(BaseModel):
|
|||
summary="Create an item",
|
||||
description="Create an item with all the information, name, description, price, tax and a set of unique tags",
|
||||
)
|
||||
async def create_item(*, item: Item):
|
||||
async def create_item(item: Item):
|
||||
return item
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.post("/items/", response_model=Item, summary="Create an item")
|
||||
async def create_item(*, item: Item):
|
||||
async def create_item(item: Item):
|
||||
"""
|
||||
Create an item with all the information:
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class Item(BaseModel):
|
|||
summary="Create an item",
|
||||
response_description="The created item",
|
||||
)
|
||||
async def create_item(*, item: Item):
|
||||
async def create_item(item: Item):
|
||||
"""
|
||||
Create an item with all the information:
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ app = FastAPI()
|
|||
|
||||
|
||||
@app.post("/login/")
|
||||
async def login(*, username: str = Form(...), password: str = Form(...)):
|
||||
async def login(username: str = Form(...), password: str = Form(...)):
|
||||
return {"username": username}
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ class UserIn(BaseModel):
|
|||
|
||||
# Don't do this in production!
|
||||
@app.post("/user/", response_model=UserIn)
|
||||
async def create_user(*, user: UserIn):
|
||||
async def create_user(user: UserIn):
|
||||
return user
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ class UserOut(BaseModel):
|
|||
|
||||
|
||||
@app.post("/user/", response_model=UserOut)
|
||||
async def create_user(*, user: UserIn):
|
||||
async def create_user(user: UserIn):
|
||||
return user
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ class Item(BaseModel):
|
|||
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(*, item_id: int, item: Item):
|
||||
async def update_item(item_id: int, item: Item):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ class Item(BaseModel):
|
|||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(
|
||||
*,
|
||||
item_id: int,
|
||||
item: Item = Body(
|
||||
...,
|
||||
|
|
@ -23,7 +22,7 @@ async def update_item(
|
|||
"price": 35.4,
|
||||
"tax": 3.2,
|
||||
},
|
||||
)
|
||||
),
|
||||
):
|
||||
results = {"item_id": item_id, "item": item}
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ def authenticate_user(fake_db, username: str, password: str):
|
|||
return user
|
||||
|
||||
|
||||
def create_access_token(*, data: dict, expires_delta: timedelta = None):
|
||||
def create_access_token(data: dict, expires_delta: timedelta = None):
|
||||
to_encode = data.copy()
|
||||
if expires_delta:
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ def authenticate_user(fake_db, username: str, password: str):
|
|||
return user
|
||||
|
||||
|
||||
def create_access_token(*, data: dict, expires_delta: timedelta = None):
|
||||
def create_access_token(data: dict, expires_delta: timedelta = None):
|
||||
to_encode = data.copy()
|
||||
if expires_delta:
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
|
|
|
|||
Loading…
Reference in New Issue