[python][flask] Honor defaultController option for untagged operations#24201
Open
Shaun-3adesign wants to merge 1 commit into
Open
[python][flask] Honor defaultController option for untagged operations#24201Shaun-3adesign wants to merge 1 commit into
Shaun-3adesign wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
defaultControlleradditional property was parsed but had no effect for thepython-flask(Connexion) server generator: the controller module for untagged operations was always nameddefault_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 viatoApiName.this.defaultControllerwas stored duringprocessOptsbut never consumed.Fix: route the
defaulttag through the configureddefaultControllerinAbstractPythonConnexionServerCodegen.toApiName. Because both the generated controller filename and Connexion'sx-openapi-router-controllerrouting derive fromtoApiName, this single change keeps the file and the runtime routing consistent.Verification
PythonFlaskConnexionServerCodegenTest#testDefaultController(added a minimal specissue_1891.yamlwith an untagged operation): the untagged handler lands in the configured module, the routing extension points at the same module, anddefault_controller.pyis no longer emitted.python-flask,python-flask-connexion3,python-aiohttp,python-aiohttp-srclayout,python-blueplanet) produced no diffs.defaultController, started it, and confirmed Connexion imports the renamed module and routes to it successfully.Fixes #1891
This also resolves the
defaultControllerhalf of #10765. The other half of #10765 — honoring a per-operationx-openapi-router-controllerfor 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
./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.masterbranch.Summary by cubic
Honors the
defaultControlleroption for untagged operations in thepython-flaskgenerator so the controller file andconnexionrouting use the configured module instead ofdefault_controller.py. Behavior is unchanged when using the default value."default"tag throughdefaultControllerintoApiName, aligning the generated filename andx-openapi-router-controller.default_controller.pyis not generated.Written for commit f7c4afa. Summary will update on new commits.