mirror of https://github.com/tiangolo/fastapi.git
Remove code examples for Python 3.8 in `path_operation_configuration`
This commit is contained in:
parent
f310e923bc
commit
2bb4f885bf
|
|
@ -46,7 +46,7 @@ In these cases, it could make sense to store the tags in an `Enum`.
|
||||||
|
|
||||||
**FastAPI** supports that the same way as with plain strings:
|
**FastAPI** supports that the same way as with plain strings:
|
||||||
|
|
||||||
{* ../../docs_src/path_operation_configuration/tutorial002b.py hl[1,8:10,13,18] *}
|
{* ../../docs_src/path_operation_configuration/tutorial002b_py39.py hl[1,8:10,13,18] *}
|
||||||
|
|
||||||
## Summary and description { #summary-and-description }
|
## Summary and description { #summary-and-description }
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ So, if you don't provide one, **FastAPI** will automatically generate one of "Su
|
||||||
|
|
||||||
If you need to mark a *path operation* as <abbr title="obsolete, recommended not to use it">deprecated</abbr>, but without removing it, pass the parameter `deprecated`:
|
If you need to mark a *path operation* as <abbr title="obsolete, recommended not to use it">deprecated</abbr>, but without removing it, pass the parameter `deprecated`:
|
||||||
|
|
||||||
{* ../../docs_src/path_operation_configuration/tutorial006.py hl[16] *}
|
{* ../../docs_src/path_operation_configuration/tutorial006_py39.py hl[16] *}
|
||||||
|
|
||||||
It will be clearly marked as deprecated in the interactive docs:
|
It will be clearly marked as deprecated in the interactive docs:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
from typing import Set, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI, status
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class Item(BaseModel):
|
|
||||||
name: str
|
|
||||||
description: Union[str, None] = None
|
|
||||||
price: float
|
|
||||||
tax: Union[float, None] = None
|
|
||||||
tags: Set[str] = set()
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
|
|
||||||
async def create_item(item: Item):
|
|
||||||
return item
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
from typing import Set, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class Item(BaseModel):
|
|
||||||
name: str
|
|
||||||
description: Union[str, None] = None
|
|
||||||
price: float
|
|
||||||
tax: Union[float, None] = None
|
|
||||||
tags: Set[str] = set()
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/items/", response_model=Item, tags=["items"])
|
|
||||||
async def create_item(item: Item):
|
|
||||||
return item
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/", tags=["items"])
|
|
||||||
async def read_items():
|
|
||||||
return [{"name": "Foo", "price": 42}]
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/users/", tags=["users"])
|
|
||||||
async def read_users():
|
|
||||||
return [{"username": "johndoe"}]
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
from typing import Set, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class Item(BaseModel):
|
|
||||||
name: str
|
|
||||||
description: Union[str, None] = None
|
|
||||||
price: float
|
|
||||||
tax: Union[float, None] = None
|
|
||||||
tags: Set[str] = set()
|
|
||||||
|
|
||||||
|
|
||||||
@app.post(
|
|
||||||
"/items/",
|
|
||||||
response_model=Item,
|
|
||||||
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):
|
|
||||||
return item
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
from typing import Set, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class Item(BaseModel):
|
|
||||||
name: str
|
|
||||||
description: Union[str, None] = None
|
|
||||||
price: float
|
|
||||||
tax: Union[float, None] = None
|
|
||||||
tags: Set[str] = set()
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/items/", response_model=Item, summary="Create an item")
|
|
||||||
async def create_item(item: Item):
|
|
||||||
"""
|
|
||||||
Create an item with all the information:
|
|
||||||
|
|
||||||
- **name**: each item must have a name
|
|
||||||
- **description**: a long description
|
|
||||||
- **price**: required
|
|
||||||
- **tax**: if the item doesn't have tax, you can omit this
|
|
||||||
- **tags**: a set of unique tag strings for this item
|
|
||||||
"""
|
|
||||||
return item
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
from typing import Set, Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class Item(BaseModel):
|
|
||||||
name: str
|
|
||||||
description: Union[str, None] = None
|
|
||||||
price: float
|
|
||||||
tax: Union[float, None] = None
|
|
||||||
tags: Set[str] = set()
|
|
||||||
|
|
||||||
|
|
||||||
@app.post(
|
|
||||||
"/items/",
|
|
||||||
response_model=Item,
|
|
||||||
summary="Create an item",
|
|
||||||
response_description="The created item",
|
|
||||||
)
|
|
||||||
async def create_item(item: Item):
|
|
||||||
"""
|
|
||||||
Create an item with all the information:
|
|
||||||
|
|
||||||
- **name**: each item must have a name
|
|
||||||
- **description**: a long description
|
|
||||||
- **price**: required
|
|
||||||
- **tax**: if the item doesn't have tax, you can omit this
|
|
||||||
- **tags**: a set of unique tag strings for this item
|
|
||||||
"""
|
|
||||||
return item
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from docs_src.path_operation_configuration.tutorial002b import app
|
from docs_src.path_operation_configuration.tutorial002b_py39 import app
|
||||||
|
|
||||||
client = TestClient(app)
|
client = TestClient(app)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,13 @@ import importlib
|
||||||
import pytest
|
import pytest
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from ...utils import needs_py39, needs_py310, needs_pydanticv1, needs_pydanticv2
|
from ...utils import needs_py310, needs_pydanticv1, needs_pydanticv2
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
name="client",
|
name="client",
|
||||||
params=[
|
params=[
|
||||||
"tutorial005",
|
pytest.param("tutorial005_py39"),
|
||||||
pytest.param("tutorial005_py39", marks=needs_py39),
|
|
||||||
pytest.param("tutorial005_py310", marks=needs_py310),
|
pytest.param("tutorial005_py310", marks=needs_py310),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from docs_src.path_operation_configuration.tutorial006 import app
|
from docs_src.path_operation_configuration.tutorial006_py39 import app
|
||||||
|
|
||||||
client = TestClient(app)
|
client = TestClient(app)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue