Skip to content

Conversation

@timonrieger
Copy link
Contributor

@timonrieger timonrieger commented Feb 9, 2026

see https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.populate_by_name, requires pydantic 2.11.

keeping as draft for now since this pydantic version restriction might be to limiting

EDIT: pydantic v2.11 was released ~1 year ago

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • 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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Switch Python model templates to Pydantic’s validate_by_name/validate_by_alias (replacing deprecated populate_by_name) and raise the minimum Pydantic version to 2.11. FastAPI generator remains unchanged.

  • Dependencies

    • Require pydantic >= 2.11 across Python templates and samples.
  • Migration

    • Upgrade to pydantic >= 2.11 and regenerate clients. No other code changes expected.

Written for commit 6460f34. Summary will update on new commits.

@timonrieger timonrieger marked this pull request as ready for review February 12, 2026 11:57
Copy link
Contributor

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

Choose a reason for hiding this comment

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

3 issues found across 407 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="modules/openapi-generator/src/main/resources/python/requirements.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/python/requirements.mustache:19">
P2: Dependency version mismatch: requirements.mustache now enforces pydantic >=2.11, but pyproject.mustache (non-poetry1 dependencies) still allows pydantic >=2. This can generate projects that install pydantic <2.11, inconsistent with the new validate_by_name requirement.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py:51">
P2: New `validate_by_name`/`validate_by_alias` config requires Pydantic 2.11+, but `pyproject.toml` still allows `pydantic>=2`, so users can install 2.10 and hit runtime errors when importing this model.</violation>
</file>

<file name="samples/client/echo_api/python/openapi_client/models/category.py">

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/category.py:35">
P2: validate_by_name/validate_by_alias require Pydantic >=2.11, but the sample’s pyproject allows >=2 and poetry.lock pins 2.9.2. Poetry installs can use an older Pydantic that doesn’t support these config keys, breaking alias validation. Update the dependency constraints/lock to >=2.11.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

pycryptodome >= 3.9.0
{{/hasHttpSignatureMethods}}
pydantic >= 2
pydantic >= 2.11
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 12, 2026

Choose a reason for hiding this comment

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

P2: Dependency version mismatch: requirements.mustache now enforces pydantic >=2.11, but pyproject.mustache (non-poetry1 dependencies) still allows pydantic >=2. This can generate projects that install pydantic <2.11, inconsistent with the new validate_by_name requirement.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/python/requirements.mustache, line 19:

<comment>Dependency version mismatch: requirements.mustache now enforces pydantic >=2.11, but pyproject.mustache (non-poetry1 dependencies) still allows pydantic >=2. This can generate projects that install pydantic <2.11, inconsistent with the new validate_by_name requirement.</comment>

<file context>
@@ -16,7 +16,7 @@ tornado = ">= 4.2, < 5"
 pycryptodome >= 3.9.0
 {{/hasHttpSignatureMethods}}
-pydantic >= 2
+pydantic >= 2.11
 typing-extensions >= 4.7.1
 {{#lazyImports}}
</file context>
Fix with Cubic

Copy link
Member

Choose a reason for hiding this comment

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

@timonrieger can you please take a look at this feedback, which seems valid to me?


model_config = ConfigDict(
populate_by_name=True,
validate_by_name=True,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 12, 2026

Choose a reason for hiding this comment

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

P2: New validate_by_name/validate_by_alias config requires Pydantic 2.11+, but pyproject.toml still allows pydantic>=2, so users can install 2.10 and hit runtime errors when importing this model.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py, line 51:

<comment>New `validate_by_name`/`validate_by_alias` config requires Pydantic 2.11+, but `pyproject.toml` still allows `pydantic>=2`, so users can install 2.10 and hit runtime errors when importing this model.</comment>

<file context>
@@ -48,7 +48,8 @@ def status_validate_enum(cls, value):
 
     model_config = ConfigDict(
-        populate_by_name=True,
+        validate_by_name=True,
+        validate_by_alias=True,
         validate_assignment=True,
</file context>
Fix with Cubic


model_config = ConfigDict(
populate_by_name=True,
validate_by_name=True,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 12, 2026

Choose a reason for hiding this comment

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

P2: validate_by_name/validate_by_alias require Pydantic >=2.11, but the sample’s pyproject allows >=2 and poetry.lock pins 2.9.2. Poetry installs can use an older Pydantic that doesn’t support these config keys, breaking alias validation. Update the dependency constraints/lock to >=2.11.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/echo_api/python/openapi_client/models/category.py, line 35:

<comment>validate_by_name/validate_by_alias require Pydantic >=2.11, but the sample’s pyproject allows >=2 and poetry.lock pins 2.9.2. Poetry installs can use an older Pydantic that doesn’t support these config keys, breaking alias validation. Update the dependency constraints/lock to >=2.11.</comment>

<file context>
@@ -32,7 +32,8 @@ class Category(BaseModel):
 
     model_config = ConfigDict(
-        populate_by_name=True,
+        validate_by_name=True,
+        validate_by_alias=True,
         validate_assignment=True,
</file context>
Fix with Cubic

Copy link
Contributor

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

Choose a reason for hiding this comment

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

6 issues found across 13 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="samples/server/petstore/python-fastapi/src/openapi_server/models/api_response.py">

<violation number="1">
P2: `populate_by_name` is deprecated in Pydantic v2.11+; this change removes `validate_by_name`/`validate_by_alias` and can trigger deprecation warnings or future incompatibility. Use the new config keys instead.</violation>
</file>

<file name="samples/server/petstore/python-fastapi/src/openapi_server/models/category.py">

<violation number="1">
P2: `populate_by_name` is deprecated in Pydantic 2.11+. Replacing `validate_by_name`/`validate_by_alias` with `populate_by_name` will emit deprecation warnings now and break in v3. Use the new config keys instead to avoid future incompatibility.</violation>
</file>

<file name="samples/server/petstore/python-fastapi/src/openapi_server/models/tag.py">

<violation number="1">
P2: `populate_by_name` is deprecated in Pydantic 2.11+ and replaced by `validate_by_name`/`validate_by_alias`. Reintroducing it can emit deprecation warnings and diverges from the recommended config.</violation>
</file>

<file name="samples/server/petstore/python-fastapi/src/openapi_server/models/pet.py">

<violation number="1">
P2: Model config uses deprecated `populate_by_name` instead of `validate_by_name`/`validate_by_alias`, which will trigger deprecation warnings in Pydantic v2.11+ and conflicts with the PR goal of moving to the new config settings.</violation>
</file>

<file name="samples/server/petstore/python-fastapi/src/openapi_server/models/user.py">

<violation number="1">
P2: Using `populate_by_name` is deprecated in Pydantic 2.11+ and will be removed in v3, which will emit warnings and hurt forward compatibility. Prefer `validate_by_name`/`validate_by_alias` instead.</violation>
</file>

<file name="samples/server/petstore/python-fastapi/src/openapi_server/models/order.py">

<violation number="1">
P2: `populate_by_name` is deprecated in Pydantic >=2.11 and will be removed in v3; this reintroduces a deprecated setting instead of `validate_by_name`/`validate_by_alias`, causing deprecation warnings and future breakage.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@wing328 wing328 added Client: Python Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. labels Feb 12, 2026
@wing328 wing328 added this to the 7.20.0 milestone Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Client: Python Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants