pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/estarfoo/sqlmodel/commit/d192142eb9e83d52c3cb5bd7d5bcba93d40cb41c

c69660fa.css" /> 📝 Fix docs for Pydantic's fields using `le` (`lte` is invalid, use `l… · estarfoo/sqlmodel@d192142 · GitHub
Skip to content

Commit d192142

Browse files
jrycwtiangolo
andauthored
📝 Fix docs for Pydantic's fields using le (lte is invalid, use le ) (fastapi#207)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
1 parent beb7a24 commit d192142

14 files changed

Lines changed: 24 additions & 30 deletions

File tree

docs/tutorial/fastapi/limit-and-offset.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ We want to allow clients to set different `offset` and `limit` values.
4242

4343
But we don't want them to be able to set a `limit` of something like `9999`, that's over `9000`! 😱
4444

45-
So, to prevent it, we add additional validation to the `limit` query parameter, declaring that it has to be **l**ess **t**han or **e**qual to `100` with `lte=100`.
45+
So, to prevent it, we add additional validation to the `limit` query parameter, declaring that it has to be **l**ess than or **e**qual to `100` with `le=100`.
4646

4747
This way, a client can decide to take fewer heroes if they want, but not more.
4848

docs_src/tutorial/fastapi/app_testing/tutorial001/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def read_heroes(
6666
*,
6767
session: Session = Depends(get_session),
6868
offset: int = 0,
69-
limit: int = Query(default=100, lte=100),
69+
limit: int = Query(default=100, le=100),
7070
):
7171
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
7272
return heroes

docs_src/tutorial/fastapi/delete/tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_hero(hero: HeroCreate):
5858

5959

6060
@app.get("/heroes/", response_model=List[HeroRead])
61-
def read_heroes(offset: int = 0, limit: int = Query(default=100, lte=100)):
61+
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
6262
with Session(engine) as session:
6363
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
6464
return heroes

docs_src/tutorial/fastapi/limit_and_offset/tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create_hero(hero: HeroCreate):
5252

5353

5454
@app.get("/heroes/", response_model=List[HeroRead])
55-
def read_heroes(offset: int = 0, limit: int = Query(default=100, lte=100)):
55+
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
5656
with Session(engine) as session:
5757
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
5858
return heroes

docs_src/tutorial/fastapi/relationships/tutorial001.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def read_heroes(
104104
*,
105105
session: Session = Depends(get_session),
106106
offset: int = 0,
107-
limit: int = Query(default=100, lte=100),
107+
limit: int = Query(default=100, le=100),
108108
):
109109
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
110110
return heroes
@@ -158,7 +158,7 @@ def read_teams(
158158
*,
159159
session: Session = Depends(get_session),
160160
offset: int = 0,
161-
limit: int = Query(default=100, lte=100),
161+
limit: int = Query(default=100, le=100),
162162
):
163163
teams = session.exec(select(Team).offset(offset).limit(limit)).all()
164164
return teams

docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def read_heroes(
6666
*,
6767
session: Session = Depends(get_session),
6868
offset: int = 0,
69-
limit: int = Query(default=100, lte=100),
69+
limit: int = Query(default=100, le=100),
7070
):
7171
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
7272
return heroes

docs_src/tutorial/fastapi/teams/tutorial001.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def read_heroes(
9595
*,
9696
session: Session = Depends(get_session),
9797
offset: int = 0,
98-
limit: int = Query(default=100, lte=100),
98+
limit: int = Query(default=100, le=100),
9999
):
100100
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
101101
return heroes
@@ -149,7 +149,7 @@ def read_teams(
149149
*,
150150
session: Session = Depends(get_session),
151151
offset: int = 0,
152-
limit: int = Query(default=100, lte=100),
152+
limit: int = Query(default=100, le=100),
153153
):
154154
teams = session.exec(select(Team).offset(offset).limit(limit)).all()
155155
return teams

docs_src/tutorial/fastapi/update/tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_hero(hero: HeroCreate):
5858

5959

6060
@app.get("/heroes/", response_model=List[HeroRead])
61-
def read_heroes(offset: int = 0, limit: int = Query(default=100, lte=100)):
61+
def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
6262
with Session(engine) as session:
6363
heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
6464
return heroes

tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ def test_tutorial(clear_sqlmodel):
5757
assert response.status_code == 404, response.text
5858

5959
response = client.get("/openapi.json")
60-
data = response.json()
6160
assert response.status_code == 200, response.text
62-
assert data == {
61+
assert response.json() == {
6362
"openapi": "3.0.2",
6463
"info": {"title": "FastAPI", "version": "0.1.0"},
6564
"paths": {
@@ -82,9 +81,9 @@ def test_tutorial(clear_sqlmodel):
8281
"required": False,
8382
"schema": {
8483
"title": "Limit",
84+
"maximum": 100.0,
8585
"type": "integer",
8686
"default": 100,
87-
"lte": 100,
8887
},
8988
"name": "limit",
9089
"in": "query",

tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ def test_tutorial(clear_sqlmodel):
6262
assert data[0]["name"] == hero2_data["name"]
6363

6464
response = client.get("/openapi.json")
65-
data = response.json()
6665
assert response.status_code == 200, response.text
67-
assert data == {
66+
assert response.json() == {
6867
"openapi": "3.0.2",
6968
"info": {"title": "FastAPI", "version": "0.1.0"},
7069
"paths": {
@@ -87,9 +86,9 @@ def test_tutorial(clear_sqlmodel):
8786
"required": False,
8887
"schema": {
8988
"title": "Limit",
89+
"maximum": 100.0,
9090
"type": "integer",
9191
"default": 100,
92-
"lte": 100,
9392
},
9493
"name": "limit",
9594
"in": "query",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy