pre-commit-ci-lite[bot]
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
3 additions and
2 deletions
-
docs/en/docs/tutorial/path-params.md
-
docs_src/path_params/tutorial006_py310.py
|
|
@ -250,7 +250,7 @@ And you only have to declare them once. |
|
|
|
|
|
|
|
|
That's probably the main visible advantage of **FastAPI** compared to alternative frameworks (apart from the raw performance). |
|
|
That's probably the main visible advantage of **FastAPI** compared to alternative frameworks (apart from the raw performance). |
|
|
|
|
|
|
|
|
### Path Parameters with Validation { #path-params-validation } |
|
|
### Path Parameters with Validation { #path-parameters-with-validation } |
|
|
|
|
|
|
|
|
You can also add validation to your path parameters using Path. |
|
|
You can also add validation to your path parameters using Path. |
|
|
|
|
|
|
|
|
|
|
|
@ -2,6 +2,7 @@ from fastapi import FastAPI, Path |
|
|
|
|
|
|
|
|
app = FastAPI() |
|
|
app = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/items/{item_id}") |
|
|
@app.get("/items/{item_id}") |
|
|
def read_item(item_id: int = Path(..., ge=1, le=1000)): |
|
|
def read_item(item_id: int = Path(..., ge=1, le=1000)): |
|
|
return {"item_id": item_id} |
|
|
return {"item_id": item_id} |
|
|
|