Skip to content

Commit c341698

Browse files
Sync flask-connexion-rest-part-3 with the updated tutorial (#884)
* Sync flask-connexion-rest-part-3 with the maintenance update of Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3 Replace the legacy Query.get() calls in notes.py with db.session.get(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Move flask-connexion-rest-part-3 to Connexion 3 and the series' current pins Re-pin requirements.txt on Connexion 3.3.0, Flask 3.1.3, flask-marshmallow 1.5.0, and marshmallow-sqlalchemy 1.5.0, matching Part 1's update. Move x-body-name onto requestBody, the only position Connexion 3 reads, and drop the debug argument that Connexion 3's uvicorn-based run() rejects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Run Part 3 app with Uvicorn auto-reload like Part 2 Align app.run() with Part 2's app.py so readers continuing the series keep the same reload behavior. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fa205bd commit c341698

4 files changed

Lines changed: 49 additions & 35 deletions

File tree

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1-
attrs==22.1.0
2-
certifi==2022.9.24
3-
charset-normalizer==2.1.1
4-
click==8.1.3
5-
clickclick==20.10.2
6-
connexion==2.14.1
7-
Flask==2.2.2
8-
flask-marshmallow==0.14.0
9-
Flask-SQLAlchemy==3.0.2
10-
idna==3.4
1+
a2wsgi==1.10.10
2+
anyio==4.15.1
3+
asgiref==3.12.1
4+
attrs==26.1.0
5+
blinker==1.9.0
6+
certifi==2026.7.22
7+
charset-normalizer==3.5.2
8+
click==8.5.0
9+
connexion==3.3.0
10+
Flask==3.1.3
11+
flask-marshmallow==1.5.0
12+
Flask-SQLAlchemy==3.1.1
13+
h11==0.16.0
14+
httpcore==1.0.9
15+
httptools==0.9.0
16+
httpx==0.28.1
17+
idna==3.20
1118
inflection==0.5.1
12-
itsdangerous==2.1.2
13-
Jinja2==3.1.2
14-
jsonschema==4.16.0
15-
MarkupSafe==2.1.1
16-
marshmallow==3.18.0
17-
marshmallow-sqlalchemy==0.28.1
18-
packaging==21.3
19-
pyparsing==3.0.9
20-
pyrsistent==0.19.1
21-
PyYAML==6.0
22-
requests==2.28.1
23-
six==1.16.0
24-
SQLAlchemy==1.4.42
25-
swagger-ui-bundle==0.0.9
26-
urllib3==1.26.12
27-
Werkzeug==2.2.2
19+
itsdangerous==2.2.0
20+
Jinja2==3.1.6
21+
jsonschema==4.26.0
22+
jsonschema-specifications==2025.9.1
23+
MarkupSafe==3.0.4
24+
marshmallow==4.3.1
25+
marshmallow-sqlalchemy==1.5.0
26+
python-dotenv==1.2.4
27+
python-multipart==0.0.32
28+
PyYAML==6.0.3
29+
referencing==0.37.0
30+
requests==2.34.2
31+
rpds-py==2026.9.1
32+
SQLAlchemy==2.1.4
33+
starlette==1.7.0
34+
swagger_ui_bundle==1.1.0
35+
typing_extensions==4.16.0
36+
urllib3==2.8.0
37+
uvicorn==0.54.0
38+
uvloop==0.23.0
39+
watchfiles==1.3.0
40+
websockets==17.2
41+
Werkzeug==3.1.9

‎flask-connexion-rest-part-3/rp_flask_api/app.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ def home():
1313

1414

1515
if __name__ == "__main__":
16-
app.run(host="0.0.0.0", port=8000, debug=True)
16+
app.run("__main__:app", host="0.0.0.0", port=8000, reload=True)

‎flask-connexion-rest-part-3/rp_flask_api/notes.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def read_one(note_id):
7-
note = Note.query.get(note_id)
7+
note = db.session.get(Note, note_id)
88

99
if note is not None:
1010
return note_schema.dump(note)
@@ -13,7 +13,7 @@ def read_one(note_id):
1313

1414

1515
def update(note_id, note):
16-
existing_note = Note.query.get(note_id)
16+
existing_note = db.session.get(Note, note_id)
1717

1818
if existing_note:
1919
update_note = note_schema.load(note, session=db.session)
@@ -26,7 +26,7 @@ def update(note_id, note):
2626

2727

2828
def delete(note_id):
29-
existing_note = Note.query.get(note_id)
29+
existing_note = db.session.get(Note, note_id)
3030

3131
if existing_note:
3232
db.session.delete(existing_note)
@@ -38,7 +38,7 @@ def delete(note_id):
3838

3939
def create(note):
4040
person_id = note.get("person_id")
41-
person = Person.query.get(person_id)
41+
person = db.session.get(Person, person_id)
4242

4343
if person:
4444
new_note = note_schema.load(note, session=db.session)

‎flask-connexion-rest-part-3/rp_flask_api/swagger.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ paths:
5050
- People
5151
summary: "Create a person"
5252
requestBody:
53+
x-body-name: "person"
5354
description: "Person to create"
5455
required: True
5556
content:
5657
application/json:
5758
schema:
58-
x-body-name: "person"
5959
$ref: "#/components/schemas/Person"
6060
responses:
6161
"201":
@@ -82,10 +82,10 @@ paths:
8282
"200":
8383
description: "Successfully updated person"
8484
requestBody:
85+
x-body-name: "person"
8586
content:
8687
application/json:
8788
schema:
88-
x-body-name: "person"
8989
$ref: "#/components/schemas/Person"
9090
delete:
9191
tags:
@@ -104,12 +104,12 @@ paths:
104104
- Notes
105105
summary: "Create a note associated with a person"
106106
requestBody:
107+
x-body-name: "note"
107108
description: "Note to create"
108109
required: True
109110
content:
110111
application/json:
111112
schema:
112-
x-body-name: "note"
113113
type: "object"
114114
properties:
115115
person_id:
@@ -141,10 +141,10 @@ paths:
141141
"200":
142142
description: "Successfully updated note"
143143
requestBody:
144+
x-body-name: "note"
144145
content:
145146
application/json:
146147
schema:
147-
x-body-name: "note"
148148
type: "object"
149149
properties:
150150
content:

0 commit comments

Comments
 (0)