Skip to content

[python][flask] Honor defaultController option for untagged operations#24201

Open
Shaun-3adesign wants to merge 1 commit into
OpenAPITools:masterfrom
Shaun-3adesign:fix/python-flask-default-controller
Open

[python][flask] Honor defaultController option for untagged operations#24201
Shaun-3adesign wants to merge 1 commit into
OpenAPITools:masterfrom
Shaun-3adesign:fix/python-flask-default-controller

Conversation

@Shaun-3adesign

@Shaun-3adesign Shaun-3adesign commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Description

The defaultController additional property was parsed but had no effect for the python-flask (Connexion) server generator: the controller module for untagged operations was always named default_controller.py, regardless of the option. (Open since 2019.)

Root cause: operations without a tag are grouped under the hardcoded "default" tag, and the controller filename is derived from that tag via toApiName. this.defaultController was stored during processOpts but never consumed.

Fix: route the default tag through the configured defaultController in AbstractPythonConnexionServerCodegen.toApiName. Because both the generated controller filename and Connexion's x-openapi-router-controller routing derive from toApiName, this single change keeps the file and the runtime routing consistent.

Verification

  • New unit test PythonFlaskConnexionServerCodegenTest#testDefaultController (added a minimal spec issue_1891.yaml with an untagged operation): the untagged handler lands in the configured module, the routing extension points at the same module, and default_controller.py is no longer emitted.
  • Backward compatible: with the default value, output is byte-identical — regenerating all affected samples (python-flask, python-flask-connexion3, python-aiohttp, python-aiohttp-srclayout, python-blueplanet) produced no diffs.
  • Verified end-to-end at runtime: generated a Connexion 3 server with a custom defaultController, started it, and confirmed Connexion imports the renamed module and routes to it successfully.

Fixes #1891

This also resolves the defaultController half of #10765. The other half of #10765 — honoring a per-operation x-openapi-router-controller for file placement (currently the handler is written into the tag-derived file rather than the referenced module) — is a larger, separate change and will be proposed in a follow-up PR.

PR checklist

  • Read the contribution guidelines.
  • Ran ./mvnw clean package, ./bin/generate-samples.sh (affected python configs), and ./bin/utils/export_docs_generators.sh — no sample or docs changes result from this fix.
  • Filed the PR against the master branch.
  • Python technical committee: @cbornet @tomplus @krjakbrjak @fa0311

Summary by cubic

Honors the defaultController option for untagged operations in the python-flask generator so the controller file and connexion routing use the configured module instead of default_controller.py. Behavior is unchanged when using the default value.

  • Bug Fixes
    • Route the "default" tag through defaultController in toApiName, aligning the generated filename and x-openapi-router-controller.
    • Added a unit test with a minimal spec to confirm the handler lands in the custom module and default_controller.py is not generated.
    • Backward compatible: default output remains identical (no sample diffs).

Written for commit f7c4afa. Summary will update on new commits.

Review in cubic

…ions

Operations without a tag are grouped under the hardcoded "default" tag, so the
defaultController additional property was parsed but never used — the generated
controller module was always default_controller.py regardless of the option.

Route the default tag through the configured defaultController in toApiName so
both the generated controller filename and connexion's x-openapi-router-controller
routing use it consistently. Default output is unchanged (samples byte-identical).

Fixes OpenAPITools#1891

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

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.

[BUG] "defaultController" property of python-flask has no effect

2 participants