Skip to content

Conversation

@padznich
Copy link

@padznich padznich commented Dec 30, 2025

for Python 3.11+
anyOf / allOf Root model based
StrEnum, IntEnum

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.

@cbornet
@tomplus
@krjakbrjak
@fa0311
@multani

Fixes issues:


Summary by cubic

Modernizes the Python generator for 3.11+ by adopting Pydantic v2 APIs and RootModel-based unions for anyOf/oneOf. Adds StrEnum/IntEnum, simplifies serialization, and updates client/header handling for urllib3 v2.

  • New Features

    • anyOf/oneOf now use RootModel[Union[...]] with optional discriminator.
    • String and integer enums generate StrEnum/IntEnum.
    • Switch to Pydantic v2 methods (model_validate, model_dump, model_validate_json, model_dump_json).
    • Cleaner exceptions with unified body/data output.
    • ApiClient uses getheader/getheaders and model_validate for deserialization.
  • Migration

    • Requires Python 3.11+; urllib3 >= 2.1.0.
    • Replace:
      • from_json → model_validate_json
      • to_json → model_dump_json(by_alias=True, exclude_unset=True)
      • from_dict → model_validate
      • to_dict → model_dump(by_alias=True)
    • anyOf/oneOf values are on .root.
    • ApiClient now calls klass.model_validate(data); response headers use getheaders() (list of pairs) instead of a mapping. Adjust code that reads headers accordingly.

Written for commit 5da74e6. Summary will update on new commits.

for Python 3.11+
anyOf / allOf Root model based
StrEnum, IntEnum
Copy link

@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 9 files

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/pyproject.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/python/pyproject.mustache:64">
P2: Inconsistent template variable: poetry1 section uses `{{#asyncio}}` for aiohttp dependencies (line 38), but the non-poetry section uses `{{#async}}` (line 64). These should use the same template variable for consistent behavior across both output formats.</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/python/pyproject.mustache:64">
P1: Missing httpx dependency in non-poetry section. The `{{#httpx}}` block was removed from the `{{^poetry1}}` dependencies array, but it still exists in the `{{#poetry1}}` section. Projects using httpx with the modern pyproject.toml format will fail at runtime due to missing dependency.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_generic.mustache:34">
P1: Missing field definition for array enum types. When `isEnum=true` AND `isArray=true`, no field is rendered because the `{{^isArray}}` block is skipped but there&#39;s no `{{#isArray}}` handler. Consider adding a fallback or explicit array enum handling.</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/python/model_generic.mustache:39">
P2: Single-value enum Literal always uses string quoting. For integer enums (IntEnum mentioned in PR), `Literal[&#39;{{{.}}}&#39;]` will produce `Literal[&#39;1&#39;]` instead of `Literal[1]`. Consider using conditional quoting based on the enum type or using `{{{.}}}` without quotes.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_doc.mustache:24">
P1: `model_dump_json()` is an instance method in Pydantic v2 and must be called on the instance variable, not the class. This code will fail at runtime with a `TypeError`.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_anyof.mustache:13">
P2: Redundant imports: `Literal` and `Union` are imported from both `typing` and `typing_extensions`. Since this is for Python 3.11+, these are already available in `typing`. The `typing_extensions` import should only include `Self` (or be removed entirely since `Self` is also in `typing` for 3.11+).</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

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

{{/poetry1}}
keywords = ["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"]
{{#poetry1}}
include = ["{{packageName}}/py.typed"]
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 30, 2025

Choose a reason for hiding this comment

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

P1: Missing httpx dependency in non-poetry section. The {{#httpx}} block was removed from the {{^poetry1}} dependencies array, but it still exists in the {{#poetry1}} section. Projects using httpx with the modern pyproject.toml format will fail at runtime due to missing dependency.

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/pyproject.mustache, line 64:

<comment>Missing httpx dependency in non-poetry section. The `{{#httpx}}` block was removed from the `{{^poetry1}}` dependencies array, but it still exists in the `{{#poetry1}}` section. Projects using httpx with the modern pyproject.toml format will fail at runtime due to missing dependency.</comment>

<file context>
@@ -58,20 +56,15 @@ lazy-imports = &quot;&gt;= 1, &lt; 2&quot;
-  &quot;httpx (&gt;=0.28.1)&quot;,
-{{/httpx}}
-{{#asyncio}}
+{{#async}}
   &quot;aiohttp (&gt;=3.8.4)&quot;,
   &quot;aiohttp-retry (&gt;=2.8.3)&quot;,
</file context>
Suggested change
include = ["{{packageName}}/py.typed"]
{{#httpx}}
"httpx (>=0.28.1)",
{{/httpx}}
{{#async}}
Fix with Cubic

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

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

33 issues found across 965 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/model_oneof.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:30">
P2: Calling `hasattr(self, &#39;root&#39;)` inside `__getattr__` risks infinite recursion. Use `self.__dict__.get(&#39;root&#39;)` instead to safely check for the attribute without triggering recursive `__getattr__` calls.</violation>
</file>

<file name="samples/client/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md">

<violation number="1" location="samples/client/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md:23">
P1: `model_dump_json()` should be called on the instance, not the class. This will fail at runtime since `model_dump_json` is an instance method in Pydantic v2.</violation>
</file>

<file name="samples/client/echo_api/python/docs/DataQuery.md">

<violation number="1" location="samples/client/echo_api/python/docs/DataQuery.md:22">
P1: `model_dump_json` is an instance method in Pydantic v2, not a class method. This should be called on `data_query_instance` to serialize the object that was just created from JSON.</violation>
</file>

<file name="samples/client/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md">

<violation number="1" location="samples/client/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md:20">
P1: `model_dump_json()` is an instance method in Pydantic v2, not a class method. This should be called on the instance (`test_query_style_form_explode_true_array_string_query_object_parameter_instance`) rather than the class, otherwise it will raise an AttributeError.</violation>
</file>

<file name="samples/client/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md">

<violation number="1" location="samples/client/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md:20">
P1: `model_dump_json()` is an instance method in Pydantic v2 but is being called on the class. This should be called on the instance `test_form_object_multipart_request_marker_instance` that was created on the previous line.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Tag.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Tag.md:21">
P1: Incorrect method call: `model_dump_json()` is an instance method in Pydantic v2, not a class method. This should be called on `tag_instance` instead of `Tag`.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/pyproject.mustache:64">
P1: Missing httpx dependency in non-poetry1 section. The `{{#httpx}}` block with the httpx dependency was removed, but it&#39;s still present in the poetry1 section. When using the httpx library option, the generated pyproject.toml won&#39;t include httpx as a required dependency, causing import failures at runtime.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md:28">
P1: `model_dump_json()` is an instance method in Pydantic v2 and must be called on the instance, not the class. This should use `default_value_instance.model_dump_json(...)` to match the previous behavior of `to_json()`.</violation>
</file>

<file name="samples/client/echo_api/python/docs/Pet.md">

<violation number="1" location="samples/client/echo_api/python/docs/Pet.md:25">
P1: `model_dump_json()` is an instance method in Pydantic v2, not a class method. This should be called on `pet_instance` instead of the class `Pet`.</violation>
</file>

<file name="samples/client/echo_api/python/docs/Query.md">

<violation number="1" location="samples/client/echo_api/python/docs/Query.md:21">
P2: `model_dump_json()` is an instance method in Pydantic v2, but it&#39;s being called on the class `Query` instead of the instance `query_instance`. This example code will raise a `TypeError` when executed.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/body_api.py:18">
P2: Duplicate import of `Annotated`: imported from `typing` here but also still imported from `typing_extensions` on line 22. The `typing_extensions` import shadows this one, making it redundant. Since this PR targets Python 3.11+, the `typing_extensions` import on line 22 should be removed instead.</violation>
</file>

<file name="samples/client/echo_api/python/docs/Category.md">

<violation number="1" location="samples/client/echo_api/python/docs/Category.md:21">
P1: `model_dump_json` is an instance method in Pydantic v2, not a class method. This should be called on `category_instance` instead of the `Category` class, otherwise it will raise a `TypeError`.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestFormObjectMultipartRequestMarker.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestFormObjectMultipartRequestMarker.md:20">
P1: `model_dump_json()` is an instance method in Pydantic v2, but it&#39;s being called on the class. This will raise an error at runtime. It should be called on `test_form_object_multipart_request_marker_instance` instead.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_doc.mustache:24">
P1: `model_dump_json()` is an instance method in Pydantic v2, but it&#39;s being called on the class instead of the instance. This will cause an `AttributeError` at runtime.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md:20">
P1: `model_dump_json()` is an instance method in Pydantic v2, but it&#39;s being called on the class instead of the instance. This will raise a TypeError at runtime.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md:23">
P1: `model_dump_json` is an instance method in Pydantic v2, not a class method. This should be called on the instance `test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance` instead of the class.</violation>
</file>

<file name="samples/client/echo_api/python/openapi_client/api/body_api.py">

<violation number="1" location="samples/client/echo_api/python/openapi_client/api/body_api.py:18">
P3: This import is immediately shadowed by `from typing_extensions import Annotated` on line 22, making it redundant. Either remove this line or remove the duplicate `typing_extensions` import below.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/pet.py:37">
P0: `StatusEnum` is used as a type annotation but is never defined or imported. This will cause a `NameError` when the module is imported.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_generic.mustache:33">
P1: Missing field definition for array-typed enum fields. When `isEnum` is true AND `isArray` is true, no field definition is generated because the only rendering path is inside `{{^isArray}}`. This would cause missing fields in generated models for OpenAPI specs with array enum properties.</violation>
</file>

<file name="samples/client/echo_api/python/docs/DefaultValue.md">

<violation number="1" location="samples/client/echo_api/python/docs/DefaultValue.md:28">
P1: `model_dump_json()` is an instance method in Pydantic v2, not a class method. This should be called on `default_value_instance` to print the JSON representation of the object created earlier.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DataQuery.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DataQuery.md:22">
P1: `model_dump_json()` is an instance method in Pydantic v2 and should be called on `data_query_instance`, not on the class `DataQuery`. This will raise a `TypeError` at runtime.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Pet.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Pet.md:25">
P1: `model_dump_json` is an instance method in Pydantic v2, not a class method. This should be called on `pet_instance` rather than the `Pet` class to avoid a runtime TypeError.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/exceptions.mustache:160">
P2: Using `or` operator to select between `data` and `body` fails for falsy but valid data values like empty dicts/lists. If `self.data` is `{}` or `[]`, it will incorrectly show `self.body` instead. Consider using explicit `None` checks:
```python
if self.data is not None or self.body:
    error_message += &quot;HTTP response body: {0}\n&quot;.format(self.data if self.data is not None else self.body)
```</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:37">
P0: `StatusEnum` is used as a type annotation but is not defined or imported anywhere in this file. This will cause a `NameError: name &#39;StatusEnum&#39; is not defined` when the module loads.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/NumberPropertiesOnly.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/NumberPropertiesOnly.md:22">
P1: `model_dump_json()` is an instance method in Pydantic v2, but it&#39;s being called on the class instead of the instance. This documentation example will fail at runtime.</violation>
</file>

<file name="samples/client/echo_api/python/docs/Tag.md">

<violation number="1" location="samples/client/echo_api/python/docs/Tag.md:21">
P1: `model_dump_json()` is an instance method in Pydantic v2 and must be called on an instance, not the class. This should be `tag_instance.model_dump_json(...)` to match the created instance from the previous line.</violation>
</file>

<file name="samples/client/echo_api/python/docs/NumberPropertiesOnly.md">

<violation number="1" location="samples/client/echo_api/python/docs/NumberPropertiesOnly.md:22">
P1: `model_dump_json()` is a Pydantic v2 instance method but is being called on the class instead of the instance. This will cause a `TypeError` at runtime. Should be called on `number_properties_only_instance` instead of `NumberPropertiesOnly`.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_anyof.mustache:34">
P2: Using `hasattr(self, &#39;root&#39;)` inside `__getattr__` can cause infinite recursion. When `root` isn&#39;t accessible through normal attribute lookup, `hasattr` triggers `__getattr__(&#39;root&#39;)` which calls `hasattr(self, &#39;root&#39;)` again. Use `object.__getattribute__` instead.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md:21">
P1: `model_dump_json()` is an instance method in Pydantic v2 and must be called on `category_instance`, not on the `Category` class. This example code will fail at runtime.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md:21">
P1: `model_dump_json()` is an instance method in Pydantic v2, but it&#39;s being called on the class `Bird` instead of the instance `bird_instance`. This documentation example will not work as written.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_enum.mustache:25">
P2: Using `{{name}}` (double braces) instead of `{{{name}}}` (triple braces) causes HTML escaping of enum member names, which could corrupt identifiers containing special characters. This is also inconsistent with `{{{value}}}` on the same line which remains unescaped.</violation>
</file>

<file name="samples/client/echo_api/python/docs/Bird.md">

<violation number="1" location="samples/client/echo_api/python/docs/Bird.md:21">
P1: `model_dump_json()` is an instance method in Pydantic v2, not a class method. This should be called on `bird_instance` rather than the `Bird` class. The current code will raise a `TypeError` at runtime.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md:21">
P1: `model_dump_json()` is an instance method in Pydantic v2, not a class method. Should be called on `query_instance` instead of `Query`.</violation>
</file>

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

@plaes
Copy link

plaes commented Jan 13, 2026

Looks a like an excellent cleanup (and improvement), though I don't like the unexpected removal of existing methods: from_dict/from_json and to_dict/to_json. I would keep these for at least a few versions, but with @warnings.deprecated annotation.

And unfortunately doesn't seem to be a solution for #22687. - seems to be core issue.

./mvnw clean package || exit
./bin/generate-samples.sh ./bin/configs/*.yaml || exit
./bin/utils/export_docs_generators.sh || exit
Copy link

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

22 issues found across 965 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/setup.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/python/setup.mustache:14">
P2: PYTHON_REQUIRES set to ">= 3.11" but never passed to setup(); generated package won’t enforce the minimum Python version.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/exceptions.py:172">
P2: Parsed response data replaces raw body in error message, hiding the actual HTTP body and mislabeling parsed data as the body.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:11">
P2: Unused and duplicate imports added (BaseModel, ConfigDict, StrictStr, model_validator, Any, List, Set, Optional, Dict, Literal, Self; Union imported twice) making generated code fail linting</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:15">
P2: oneOf exclusivity no longer enforced; RootModel Union parsing can accept inputs matching multiple schemas without error, unlike prior explicit match-counting validator</violation>

<violation number="3" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:19">
P2: Nullable oneOf schemas no longer accept None: root is required and Union excludes Optional/None, breaking nullable oneOf handling</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/setup.py">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/setup.py:25">
P2: Minimum Python version not enforced: PYTHON_REQUIRES is defined/updated but not passed to setup(), so install metadata won’t block unsupported Python versions.</violation>
</file>

<file name="samples/client/echo_api/python/setup.py">

<violation number="1" location="samples/client/echo_api/python/setup.py:25">
P2: Python version requirement updated to ">= 3.11" but not passed to setup(); package metadata will not enforce this minimum version.</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:23">
P2: Unused and duplicate imports added: Set/Literal/Self/Field are unused and Optional is imported twice.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/default_value.py:32">
P2: Field uses undefined type and incompatible nested list annotation, causing NameError/TypeError in validation</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:37">
P1: `StatusEnum` is undefined and not imported; the `status` field annotation references a missing type, causing Pydantic model resolution to fail.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/query.py:31">
P1: Nested `outcomes` type is validated as flat list, causing `TypeError: unhashable list` on valid inputs</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md:28">
P2: Doc example hides default values: exclude_unset=True omits defaulted fields after validating empty input, defeating the default-value demonstration.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py:32">
P1: Undefined enum type and mismatched nested list annotation will break model build/validation for `array_string_enum_default`.</violation>
</file>

<file name="samples/client/echo_api/python/docs/DefaultValue.md">

<violation number="1" location="samples/client/echo_api/python/docs/DefaultValue.md:28">
P2: Example hides default-valued fields by using exclude_unset=True, so the default-value demo outputs an empty object.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/api_client.mustache:719">
P1: Downloaded file path uses unsanitized Content-Disposition filename, allowing path traversal writes outside temp directory.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/pet.py:37">
P1: `StatusEnum` referenced in field annotation but never defined or imported, causing unresolved annotation at runtime</violation>

<violation number="2" location="samples/client/echo_api/python/openapi_client/models/pet.py:61">
P2: Removed Pet serialization helpers while other code still calls them; Pet.from_json/to_json/to_dict/from_dict now raise AttributeError</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/number_properties_only.py:24">
P2: Redundant/unused imports added (duplicate Optional/Field and unused Set/Literal/Self) after helper removal</violation>

<violation number="2" location="samples/client/echo_api/python/openapi_client/models/number_properties_only.py:24">
P1: Removed serialization helpers while call sites remain: `NumberPropertiesOnly.from_json` is still used and will now fail with AttributeError.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/api_client.py:384">
P2: `model_dump` result may be scalar; `.items()` call will raise for RootModel serialization</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_anyof.mustache:12">
P2: Unused imports added/left over; symbols like Literal, Self, getfullargspec, json, pprint, TYPE_CHECKING, etc. are not used in the generated anyOf model, causing unused-import lint failures.</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/python/model_anyof.mustache:23">
P1: Nullable anyOf schemas now reject null because the required root Union field no longer includes Optional/nullable handling.</violation>
</file>

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

Comment on lines +37 to +39
status: Optional[StatusEnum] = Field(
None,
description="pet status in the store"
Copy link

Choose a reason for hiding this comment

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

P1: StatusEnum is undefined and not imported; the status field annotation references a missing type, causing Pydantic model resolution to fail.

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 37:

<comment>`StatusEnum` is undefined and not imported; the `status` field annotation references a missing type, causing Pydantic model resolution to fail.</comment>

<file context>
@@ -34,7 +34,10 @@ class Pet(BaseModel):
     photo_urls: List[StrictStr] = Field(alias="photoUrls")
     tags: Optional[List[Tag]] = None
-    status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
+    status: Optional[StatusEnum] = Field(
+        None,
+        description="pet status in the store"
</file context>
Suggested change
status: Optional[StatusEnum] = Field(
None,
description="pet status in the store"
status: Optional[Literal["available", "pending", "sold"]] = Field(
None,
description="pet status in the store"
)

Comment on lines +32 to +35
array_string_enum_default: Optional[List[List[Array_string_enum_defaultEnum]]] = Field(
None,
description="array_string_enum_default of the DefaultValue"
)
Copy link

Choose a reason for hiding this comment

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

P1: Undefined enum type and mismatched nested list annotation will break model build/validation for array_string_enum_default.

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/default_value.py, line 32:

<comment>Undefined enum type and mismatched nested list annotation will break model build/validation for `array_string_enum_default`.</comment>

<file context>
@@ -21,15 +21,18 @@
     """ # noqa: E501
     array_string_enum_ref_default: Optional[List[StringEnumRef]] = None
-    array_string_enum_default: Optional[List[StrictStr]] = None
+    array_string_enum_default: Optional[List[List[Array_string_enum_defaultEnum]]] = Field(
+        None,
+        description="array_string_enum_default of the DefaultValue"
</file context>
Suggested change
array_string_enum_default: Optional[List[List[Array_string_enum_defaultEnum]]] = Field(
None,
description="array_string_enum_default of the DefaultValue"
)
array_string_enum_default: Optional[List[Literal['success', 'failure', 'unclassified']]] = Field(
None,
description="array_string_enum_default of the DefaultValue"
)

Comment on lines +719 to 722
content_disposition = response.getheader("Content-Disposition")
if content_disposition:
m = re.search(
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
Copy link

Choose a reason for hiding this comment

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

P1: Downloaded file path uses unsanitized Content-Disposition filename, allowing path traversal writes outside temp directory.

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/api_client.mustache, line 719:

<comment>Downloaded file path uses unsanitized Content-Disposition filename, allowing path traversal writes outside temp directory.</comment>

<file context>
@@ -719,7 +716,7 @@ class ApiClient:
         os.remove(path)
 
-        content_disposition = response.headers.get("Content-Disposition")
+        content_disposition = response.getheader("Content-Disposition")
         if content_disposition:
             m = re.search(
</file context>

Copy link
Author

Choose a reason for hiding this comment

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

content_disposition = response.headers.get("Content-Disposition")
VS
content_disposition = response.getheader("Content-Disposition")

Copy link

Choose a reason for hiding this comment

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

@padznich The difference between these two approaches is about the API used to access HTTP headers:

response.headers.get("Content-Disposition") (old code)

  • Treats headers as a dict-like object
  • Used with urllib3 v1.x where response.headers was an HTTPHeaderDict

response.getheader("Content-Disposition") (new code)

  • Calls a method on the response object
  • Used with urllib3 v2.x where the response object provides getheader() and getheaders() methods

Your PR correctly updates this to getheader() to be compatible with urllib3 >= 2.1.0 (as specified in your pyproject.mustache). This is the right change.


However, my P1 review comment is still valid — it's about a security issue, not the API change:

The code extracts a filename from the Content-Disposition header and uses it directly in a file path:

filename = m.group(1)
path = os.path.join(os.path.dirname(path), filename)

If a malicious server returns Content-Disposition: attachment; filename="../../etc/passwd", this could write outside the temp directory. You should sanitize the filename:

filename = os.path.basename(m.group(1))  # Strip any directory traversal
path = os.path.join(os.path.dirname(path), filename)

This prevents path traversal attacks regardless of whether you use .get() or .getheader().

photo_urls: List[StrictStr] = Field(alias="photoUrls")
tags: Optional[List[Tag]] = None
status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
status: Optional[StatusEnum] = Field(
Copy link

Choose a reason for hiding this comment

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

P1: StatusEnum referenced in field annotation but never defined or imported, causing unresolved annotation at runtime

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/pet.py, line 37:

<comment>`StatusEnum` referenced in field annotation but never defined or imported, causing unresolved annotation at runtime</comment>

<file context>
@@ -34,7 +34,10 @@ class Pet(BaseModel):
     photo_urls: List[StrictStr] = Field(alias="photoUrls")
     tags: Optional[List[Tag]] = None
-    status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
+    status: Optional[StatusEnum] = Field(
+        None,
+        description="pet status in the store"
</file context>
Suggested change
status: Optional[StatusEnum] = Field(
status: Optional[Literal["available", "pending", "sold"]] = Field(



def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
Copy link

Choose a reason for hiding this comment

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

P2: Removed Pet serialization helpers while other code still calls them; Pet.from_json/to_json/to_dict/from_dict now raise AttributeError

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/pet.py, line 61:

<comment>Removed Pet serialization helpers while other code still calls them; Pet.from_json/to_json/to_dict/from_dict now raise AttributeError</comment>

<file context>
@@ -58,63 +61,5 @@ def to_str(self) -> str:
         """Returns the string representation of the model using alias"""
         return pprint.pformat(self.model_dump(by_alias=True))
 
</file context>

from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self
from typing import Optional, Set, Literal, Self
Copy link

Choose a reason for hiding this comment

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

P2: Redundant/unused imports added (duplicate Optional/Field and unused Set/Literal/Self) after helper removal

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/number_properties_only.py, line 24:

<comment>Redundant/unused imports added (duplicate Optional/Field and unused Set/Literal/Self) after helper removal</comment>

<file context>
@@ -21,8 +21,8 @@
 from typing_extensions import Annotated
-from typing import Optional, Set
-from typing_extensions import Self
+from typing import Optional, Set, Literal, Self
+from pydantic import Field
 
</file context>

Comment on lines +384 to 390
obj_dict = obj.model_dump(by_alias=True, exclude_none=True)

if isinstance(obj_dict, list):
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
# here we handle instances that can either be a list or something else, and only became a real list by calling model_dump(by_alias=True)
return self.sanitize_for_serialization(obj_dict)

return {
Copy link

Choose a reason for hiding this comment

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

P2: model_dump result may be scalar; .items() call will raise for RootModel serialization

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/api_client.py, line 384:

<comment>`model_dump` result may be scalar; `.items()` call will raise for RootModel serialization</comment>

<file context>
@@ -381,13 +381,10 @@ def sanitize_for_serialization(self, obj):
-                obj_dict = obj.to_dict()
-            else:
-                obj_dict = obj.__dict__
+            obj_dict = obj.model_dump(by_alias=True, exclude_none=True)
 
         if isinstance(obj_dict, list):
</file context>

./mvnw clean package || exit
./bin/generate-samples.sh ./bin/configs/*.yaml || exit
./bin/utils/export_docs_generators.sh || exit
Copy link

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

28 issues found across 965 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="samples/client/echo_api/python/openapi_client/models/category.py">

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/category.py:23">
P3: Unused typing imports (Optional/Set/Literal/Self) were added but never referenced, leading to lint/type-check failures and unnecessary noise.</violation>

<violation number="2" location="samples/client/echo_api/python/openapi_client/models/category.py:24">
P3: Unused pydantic Field import was added but never used, causing lint failures and dead code.</violation>
</file>

<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md">

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md:28">
P2: Documentation example hides defaulted fields by using exclude_unset=True, so the sample prints `{}` instead of showing defaults.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/default_value.py:32">
P1: `array_string_enum_default` references undefined enum type and is typed as nested list, conflicting with validator and causing model build/validation failure.</violation>
</file>

<file name="samples/client/echo_api/python/setup.py">

<violation number="1" location="samples/client/echo_api/python/setup.py:25">
P2: Python 3.11+ requirement is defined but not enforced in setup() because python_requires is omitted.</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:37">
P1: `StatusEnum` annotation is undefined; model references a non-existent type causing runtime resolution failure</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py:31">
P2: `OutcomesEnum` is referenced in the `outcomes` annotation but is not imported/defined, causing Pydantic to fail when resolving the model.</violation>

<violation number="2" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py:31">
P1: `outcomes` validator rejects all non-empty nested lists: it now checks list items against strings instead of iterating inner enum values, so valid inputs fail validation.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/query.py:31">
P1: `OutcomesEnum` is referenced in the outcomes type annotation but is never defined or imported, so the model will error when Pydantic resolves annotations.</violation>

<violation number="2" location="samples/client/echo_api/python/openapi_client/models/query.py:31">
P1: Validator still treats outcomes as a flat string list; with the new nested list type this membership check hashes a list and raises TypeError, preventing valid data from passing validation.</violation>
</file>

<file name="samples/client/echo_api/python/pyproject.toml">

<violation number="1" location="samples/client/echo_api/python/pyproject.toml:11">
P2: Python version requirement bumped to 3.11 while README still promises support for 3.9+, leading to installation failure for users on 3.9/3.10 following the docs.</violation>
</file>

<file name="samples/client/echo_api/python/docs/DefaultValue.md">

<violation number="1" location="samples/client/echo_api/python/docs/DefaultValue.md:28">
P2: Default-value example omits defaults because `exclude_unset=True` drops defaulted fields, so the sample prints `{}` instead of showing defaults.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py:25">
P2: Duplicate and unused imports introduced (Optional/Field re-imported; Set/Literal/Self unused), likely to trigger lint errors.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:13">
P2: Forward-ref handling removed: oneOf RootModel no longer runs postponed imports or model_rebuild, so generated models with circular/forward refs will fail.</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:17">
P2: Strict oneOf exclusivity validation removed; Union parsing now accepts ambiguous inputs instead of rejecting 0 or multiple matches</violation>

<violation number="3" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:17">
P2: Nullable oneOf models are no longer supported; generated model requires a non-null root even when schema is nullable.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py:384">
P1: `model_dump` on Pydantic RootModel can return a primitive; code assumes dict and will crash calling `.items()`.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/exceptions.mustache:161">
P2: ApiException __str__ now drops one of body/data and mislabels data as body due to `self.data or self.body`</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api/body_api.py:18">
P2: Annotated is imported from typing but then immediately shadowed by a later import from typing_extensions, leaving duplicate/contradictory imports and keeping the typing_extensions dependency.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/number_properties_only.py:47">
P1: Removed serialization helpers (`from_json`/`to_json`/`from_dict`) break existing calls; NumberPropertiesOnly no longer provides these methods but tests still invoke them, leading to AttributeError at runtime.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/exceptions.py:172">
P2: Error message now drops either the raw body or parsed data when both are present, reducing debugging information.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/models/pet.py:37">
P1: `StatusEnum` is referenced in the status field annotation but is not defined or imported, causing runtime failures when Pydantic resolves annotations.</violation>

<violation number="2" location="samples/client/echo_api/python/openapi_client/models/pet.py:61">
P1: Removed Pet serialization helpers (`to_json/from_json/to_dict/from_dict`) but callers/tests still invoke them, causing AttributeError.</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py:23">
P2: Unused and duplicate imports (`Optional`, `Set`, `Literal`, `Self`, `Field`) were added; they aren’t referenced anywhere, so linting (F401) will fail.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_generic.mustache:38">
P2: Non-required single-value enums are typed as non-optional Literal while defaulting to None, causing a type/validation mismatch.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python/model_anyof.mustache:15">
P2: Assignment-time validation and protected namespace overrides were removed from anyOf models, changing behavior and allowing invalid root assignments</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py:32">
P1: array_string_enum_default references an undefined type and uses an incorrect nested list type that breaks validation</violation>
</file>

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

<violation number="1" location="samples/client/echo_api/python/openapi_client/api_client.py:384">
P1: RootModel outputs from model_dump can be primitives, so obj_dict.items() will raise AttributeError during serialization</violation>
</file>

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

Comment on lines +32 to +35
array_string_enum_default: Optional[List[List[Array_string_enum_defaultEnum]]] = Field(
None,
description="array_string_enum_default of the DefaultValue"
)
Copy link

Choose a reason for hiding this comment

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

P1: array_string_enum_default references undefined enum type and is typed as nested list, conflicting with validator and causing model build/validation failure.

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/default_value.py, line 32:

<comment>`array_string_enum_default` references undefined enum type and is typed as nested list, conflicting with validator and causing model build/validation failure.</comment>

<file context>
@@ -21,15 +21,18 @@
     """ # noqa: E501
     array_string_enum_ref_default: Optional[List[StringEnumRef]] = None
-    array_string_enum_default: Optional[List[StrictStr]] = None
+    array_string_enum_default: Optional[List[List[Array_string_enum_defaultEnum]]] = Field(
+        None,
+        description="array_string_enum_default of the DefaultValue"
</file context>
Suggested change
array_string_enum_default: Optional[List[List[Array_string_enum_defaultEnum]]] = Field(
None,
description="array_string_enum_default of the DefaultValue"
)
array_string_enum_default: Optional[List[StrictStr]] = Field(
None,
description="array_string_enum_default of the DefaultValue"
)

photo_urls: List[StrictStr] = Field(alias="photoUrls")
tags: Optional[List[Tag]] = None
status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
status: Optional[StatusEnum] = Field(
Copy link

Choose a reason for hiding this comment

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

P1: StatusEnum annotation is undefined; model references a non-existent type causing runtime resolution failure

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 37:

<comment>`StatusEnum` annotation is undefined; model references a non-existent type causing runtime resolution failure</comment>

<file context>
@@ -34,7 +34,10 @@ class Pet(BaseModel):
     photo_urls: List[StrictStr] = Field(alias="photoUrls")
     tags: Optional[List[Tag]] = None
-    status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
+    status: Optional[StatusEnum] = Field(
+        None,
+        description="pet status in the store"
</file context>
Suggested change
status: Optional[StatusEnum] = Field(
from openapi_client.models.status_enum import StatusEnum
...
status: Optional[StatusEnum] = Field(
None,
description="pet status in the store"
)

""" # noqa: E501
id: Optional[StrictInt] = Field(default=None, description="Query")
outcomes: Optional[List[StrictStr]] = None
outcomes: Optional[List[List[OutcomesEnum]]] = Field(
Copy link

Choose a reason for hiding this comment

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

P1: outcomes validator rejects all non-empty nested lists: it now checks list items against strings instead of iterating inner enum values, so valid inputs fail validation.

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/query.py, line 31:

<comment>`outcomes` validator rejects all non-empty nested lists: it now checks list items against strings instead of iterating inner enum values, so valid inputs fail validation.</comment>

<file context>
@@ -20,15 +20,18 @@
     """ # noqa: E501
     id: Optional[StrictInt] = Field(default=None, description="Query")
-    outcomes: Optional[List[StrictStr]] = None
+    outcomes: Optional[List[List[OutcomesEnum]]] = Field(
+        None,
+        description="outcomes of the Query"
</file context>

""" # noqa: E501
id: Optional[StrictInt] = Field(default=None, description="Query")
outcomes: Optional[List[StrictStr]] = None
outcomes: Optional[List[List[OutcomesEnum]]] = Field(
Copy link

Choose a reason for hiding this comment

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

P1: OutcomesEnum is referenced in the outcomes type annotation but is never defined or imported, so the model will error when Pydantic resolves annotations.

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/query.py, line 31:

<comment>`OutcomesEnum` is referenced in the outcomes type annotation but is never defined or imported, so the model will error when Pydantic resolves annotations.</comment>

<file context>
@@ -20,15 +20,18 @@
     """ # noqa: E501
     id: Optional[StrictInt] = Field(default=None, description="Query")
-    outcomes: Optional[List[StrictStr]] = None
+    outcomes: Optional[List[List[OutcomesEnum]]] = Field(
+        None,
+        description="outcomes of the Query"
</file context>

""" # noqa: E501
id: Optional[StrictInt] = Field(default=None, description="Query")
outcomes: Optional[List[StrictStr]] = None
outcomes: Optional[List[List[OutcomesEnum]]] = Field(
Copy link

Choose a reason for hiding this comment

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

P1: Validator still treats outcomes as a flat string list; with the new nested list type this membership check hashes a list and raises TypeError, preventing valid data from passing validation.

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/query.py, line 31:

<comment>Validator still treats outcomes as a flat string list; with the new nested list type this membership check hashes a list and raises TypeError, preventing valid data from passing validation.</comment>

<file context>
@@ -20,15 +20,18 @@
     """ # noqa: E501
     id: Optional[StrictInt] = Field(default=None, description="Query")
-    outcomes: Optional[List[StrictStr]] = None
+    outcomes: Optional[List[List[OutcomesEnum]]] = Field(
+        None,
+        description="outcomes of the Query"
</file context>

from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self
from typing import Optional, Set, Literal, Self
Copy link

Choose a reason for hiding this comment

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

P2: Unused and duplicate imports (Optional, Set, Literal, Self, Field) were added; they aren’t referenced anywhere, so linting (F401) will fail.

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/tag.py, line 23:

<comment>Unused and duplicate imports (`Optional`, `Set`, `Literal`, `Self`, `Field`) were added; they aren’t referenced anywhere, so linting (F401) will fail.</comment>

<file context>
@@ -20,8 +20,8 @@
 from typing import Any, ClassVar, Dict, List, Optional
-from typing import Optional, Set
-from typing_extensions import Self
+from typing import Optional, Set, Literal, Self
+from pydantic import Field
 
</file context>

{{#-first}}
{{#-last}}
{{! Single value enum - use Literal }}
{{name}}: Literal[{{#isString}}"{{{.}}}"{{/isString}}{{^isString}}{{{.}}}{{/isString}}] = Field(
Copy link

Choose a reason for hiding this comment

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

P2: Non-required single-value enums are typed as non-optional Literal while defaulting to None, causing a type/validation mismatch.

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/model_generic.mustache, line 38:

<comment>Non-required single-value enums are typed as non-optional Literal while defaulting to None, causing a type/validation mismatch.</comment>

<file context>
@@ -28,7 +28,40 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
+          {{#-first}}
+            {{#-last}}
+              {{! Single value enum - use Literal }}
+    {{name}}: Literal[{{#isString}}"{{{.}}}"{{/isString}}{{^isString}}{{{.}}}{{/isString}}] = Field(
+        {{#required}}...{{/required}}{{^required}}None{{/required}},
+        description="{{description}}{{^description}}{{{name}}} of the {{classname}}{{/description}}"
</file context>
Suggested change
{{name}}: Literal[{{#isString}}"{{{.}}}"{{/isString}}{{^isString}}{{{.}}}{{/isString}}] = Field(
{{name}}: {{#required}}Literal[{{#isString}}"{{{.}}}"{{/isString}}{{^isString}}{{{.}}}{{/isString}}]{{/required}}{{^required}}Optional[Literal[{{#isString}}"{{{.}}}"{{/isString}}{{^isString}}{{{.}}}{{/isString}}]]{{/required}} = Field(


class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}):

class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}]]):
Copy link

Choose a reason for hiding this comment

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

P2: Assignment-time validation and protected namespace overrides were removed from anyOf models, changing behavior and allowing invalid root assignments

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/model_anyof.mustache, line 15:

<comment>Assignment-time validation and protected namespace overrides were removed from anyOf models, changing behavior and allowing invalid root assignments</comment>

<file context>
@@ -1,177 +1,40 @@
 
-class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}):
+
+class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}]]):
     """
     {{{description}}}{{^description}}{{{classname}}}{{/description}}
</file context>

from typing import Optional, Set
from typing_extensions import Self
from typing import Optional, Set, Literal, Self
from pydantic import Field
Copy link

Choose a reason for hiding this comment

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

P3: Unused pydantic Field import was added but never used, causing lint failures and dead code.

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 24:

<comment>Unused pydantic Field import was added but never used, causing lint failures and dead code.</comment>

<file context>
@@ -20,8 +20,8 @@
-from typing import Optional, Set
-from typing_extensions import Self
+from typing import Optional, Set, Literal, Self
+from pydantic import Field
 
 class Category(BaseModel):
</file context>

from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self
from typing import Optional, Set, Literal, Self
Copy link

Choose a reason for hiding this comment

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

P3: Unused typing imports (Optional/Set/Literal/Self) were added but never referenced, leading to lint/type-check failures and unnecessary noise.

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 23:

<comment>Unused typing imports (Optional/Set/Literal/Self) were added but never referenced, leading to lint/type-check failures and unnecessary noise.</comment>

<file context>
@@ -20,8 +20,8 @@
 from typing import Any, ClassVar, Dict, List, Optional
-from typing import Optional, Set
-from typing_extensions import Self
+from typing import Optional, Set, Literal, Self
+from pydantic import Field
 
</file context>

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.

2 participants