Skip to content

[BUG][PYTHON] Fix #23990: Account for content-type parameters on request preparation#23992

Open
MarcelKonrad wants to merge 5 commits into
OpenAPITools:masterfrom
MarcelKonrad:issue-23990
Open

[BUG][PYTHON] Fix #23990: Account for content-type parameters on request preparation#23992
MarcelKonrad wants to merge 5 commits into
OpenAPITools:masterfrom
MarcelKonrad:issue-23990

Conversation

@MarcelKonrad

@MarcelKonrad MarcelKonrad commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Fixes #23990. A description and a guide on how to reproduce the issue can be found there.

The proposed changes include a new helper function called contenttype_matches that returns true when a given content-type string matches the given type and subtype, otherwise it returns false. Mime type parameters are ignored, but can be optionally be present in the provided string. It also allows for vendor specifications. For example, application/vendor+json is also considered valid against type=application, subtype=json.

@cbornet @tomplus @krjakbrjak @fa0311 @multani


Summary by cubic

Fixes #23990 by making the Python client’s content-type matching ignore parameters (including optional whitespace) and accept vendor suffixes so request bodies use the correct encoder.

  • Bug Fixes
    • Added contenttype_matches helper (case-insensitive, ignores MIME parameters/whitespace, supports +vendor suffix).
    • Switched JSON, application/x-www-form-urlencoded, and multipart/form-data detection to use the helper.
    • Moved the helper to module scope and updated templates/samples; also use content_type for text/* boolean handling.

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

Review in cubic

@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.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread modules/openapi-generator/src/main/resources/python/rest.mustache Outdated
@MarcelKonrad MarcelKonrad changed the title [BUG][PYTHON] Fix 23990: Account for content-type parameters on request preparation [BUG][PYTHON] Fix #23990: Account for content-type parameters on request preparation Jun 11, 2026

@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.

2 issues found across 5 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread samples/openapi3/client/petstore/python/petstore_api/rest.py
@MarcelKonrad

Copy link
Copy Markdown
Contributor Author

The pipeline failed because it could not pull the specified docker image due to a connection timeout, which is unrelated to this PR.

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][PYTHON] Request preparation fails when content-type contains parameters (except for JSON)

1 participant