Skip to content

Sync flask-connexion-rest-part-3 with the updated tutorial - #884

Merged
realpython-bot merged 4 commits into
masterfrom
maintenance/flask-connexion-rest-api-part-3-20261012
Oct 21, 2026
Merged

realpython-bot merged 4 commits into
masterfrom
maintenance/flask-connexion-rest-api-part-3-20261012

Conversation

@realpython-bot

@realpython-bot realpython-bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Maintenance update of Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3.

What changed

  • rp_flask_api/notes.py: replaced the legacy Note.query.get(note_id) and Person.query.get(person_id) calls with db.session.get(Note, note_id) and db.session.get(Person, person_id). Query.get() has been a legacy construct since SQLAlchemy 2.0, and current Flask-SQLAlchemy emits a LegacyAPIWarning for it. The article's draft update makes the same change. (2026-10-12)
  • requirements.txt: moved to Connexion 3 and the series' current pins, the same ones as Part 1's update (Sync flask-connexion-rest-part-1 with the updated tutorial #852) and the article's dependencies field: connexion[flask,swagger-ui,uvicorn]==3.3.0, Flask==3.1.3, flask-marshmallow==1.5.0, marshmallow-sqlalchemy==1.5.0, Flask-SQLAlchemy==3.1.1, and SQLAlchemy==2.1.4, frozen from a fresh Python 3.14.6 venv. (2026-10-13)
  • rp_flask_api/swagger.yml: moved x-body-name from inside schema up onto requestBody for people.create, people.update, notes.create, and notes.update. Connexion 3 only reads it there. Left where it was, the body arrives as body, and the handler fails with TypeError: create() missing 1 required positional argument: 'note' (500). The article's draft and Part 1 make the same move. (2026-10-13)
  • rp_flask_api/app.py: app.run(host="0.0.0.0", port=8000). Connexion 3's run() hands off to uvicorn, which rejects debug=True with a TypeError. Part 1's app.run("app:app", ..., reload=True) doesn't work here: the reloader imports app a second time against the shared config.connex_app and fails with View function mapping is overwriting an existing endpoint function: home. (2026-10-13)

Article draft: https://realpython.com/pbjt/blog/post/2523/change/
Maintenance card: https://trello.com/c/7oKcpEtx

How it was verified (2026-10-13)

  • Fresh Python 3.14.6 venv, pip install -r requirements.txt, and build_database.py on a copy of the folder.
  • Flask test client: GET / (200), GET /api/people (200, with nested notes), GET /api/people/Fairy (200), GET /api/notes/1 (200), GET /api/notes/999 (404), PUT /api/notes/1 (201, content updated), POST /api/notes for an existing person (201) and a missing one (404), DELETE /api/notes/1 (204, then a 404 on re-read), POST/PUT/DELETE /api/people[/Lovelace] (201/201/200), and GET /api/ui/ (200).
  • python app.py serves /, /api/people, and /api/ui/ on port 8000.
  • uvx ruff@0.14.1 format --check and uvx ruff@0.14.1 check on the folder both pass.

🤖 Generated with Claude Code

realpython-bot and others added 4 commits October 12, 2026 06:06
…n 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>
…nt 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>
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>
@realpython-bot
realpython-bot merged commit c341698 into master Oct 21, 2026
1 check passed
@realpython-bot
realpython-bot deleted the maintenance/flask-connexion-rest-api-part-3-20261012 branch October 21, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant