-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
enhance python openapi generator #22600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
enhance python openapi generator #22600
Conversation
for Python 3.11+ anyOf / allOf Root model based StrEnum, IntEnum
There was a problem hiding this 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'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['{{{.}}}']` will produce `Literal['1']` 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.
modules/openapi-generator/src/main/resources/python/pyproject.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_generic.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_generic.mustache
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_doc.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_anyof.mustache
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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, 'root')` inside `__getattr__` risks infinite recursion. Use `self.__dict__.get('root')` 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's still present in the poetry1 section. When using the httpx library option, the generated pyproject.toml won'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'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'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'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'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 += "HTTP response body: {0}\n".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 'StatusEnum' 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'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, 'root')` inside `__getattr__` can cause infinite recursion. When `root` isn't accessible through normal attribute lookup, `hasattr` triggers `__getattr__('root')` which calls `hasattr(self, 'root')` 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'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.
modules/openapi-generator/src/main/resources/python/model_oneof.mustache
Outdated
Show resolved
Hide resolved
...t/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
Outdated
Show resolved
Hide resolved
.../client/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
Outdated
Show resolved
Hide resolved
samples/client/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md
Outdated
Show resolved
Hide resolved
samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md
Outdated
Show resolved
Hide resolved
samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_enum.mustache
Outdated
Show resolved
Hide resolved
samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md
Outdated
Show resolved
Hide resolved
|
Looks a like an excellent cleanup (and improvement), though I don't like the unexpected removal of existing methods:
|
There was a problem hiding this 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.
...client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py
Outdated
Show resolved
Hide resolved
...o_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py
Outdated
Show resolved
Hide resolved
samples/client/echo_api/python/openapi_client/models/number_properties_only.py
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_anyof.mustache
Outdated
Show resolved
Hide resolved
filename = os.path.basename(m.group(1))
There was a problem hiding this 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.
samples/client/echo_api/python/openapi_client/models/default_value.py
Outdated
Show resolved
Hide resolved
...client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py
Outdated
Show resolved
Hide resolved
...ient/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py
Outdated
Show resolved
Hide resolved
...client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_generic.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_anyof.mustache
Show resolved
Hide resolved
samples/client/echo_api/python/openapi_client/models/category.py
Outdated
Show resolved
Hide resolved
samples/client/echo_api/python/openapi_client/models/category.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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="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 `from_json`/`to_json` helpers while tests still call them, causing AttributeError</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:23">
P2: Docs example validates an empty JSON string, which raises ValidationError because required fields (name, photoUrls) are missing.</violation>
</file>
<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py">
<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py:23">
P3: Unused imports (Set, Literal, Self, Field) were introduced but are never referenced after removing the serialization helpers, leaving dead code that will trip lint/static checks.</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: Default-value example omits defaults by using `exclude_unset=True`, so printing from `{}` hides defaulted fields and misleads the example.</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: Doc example hides default values by using exclude_unset=True, so printing from '{}' shows an empty JSON instead of the defaults the doc aims to demonstrate.</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` uses an undefined enum type and validator logic that doesn’t match its nested list annotation, causing import/validation errors.</violation>
</file>
<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py">
<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py:47">
P1: Removed serialization helpers (`from_json`/`to_json`/`from_dict`/`to_dict`) while tests still call them, causing AttributeError.</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` now refers to an undefined enum and the validator still expects a flat list, leading to import/validation failures.</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:171">
P2: Error message now collapses body and data, hiding one and mislabeling parsed data as body when both are set</violation>
</file>
<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: Minimum Python version (>=3.11) is not enforced because python_requires is never passed to setup()</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 referenced in the `status` annotation but is not defined or imported, causing Pydantic to fail resolving the type at runtime.</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: Undefined type `StatusEnum` used in `status` annotation causes model import/validation failure.</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">
P1: oneOf uniqueness enforcement removed; ambiguous payloads now validate via plain Union</violation>
</file>
<file name="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/string_enum_ref.py">
<violation number="1" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/string_enum_ref.py:18">
P2: Unused imports Enum and IntEnum are added but never used, which can trigger lint failures or add unnecessary noise.</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: Enum fields lack alias mapping, so JSON keys differing from the Python attribute won’t serialize/deserialize correctly</violation>
</file>
<file name="samples/client/echo_api/python/setup.py">
<violation number="1" location="samples/client/echo_api/python/setup.py:25">
P2: Updated PYTHON_REQUIRES is unused—setup() omits python_requires, so the minimum Python version isn’t enforced from this setup.py.</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">
P2: `OutcomesEnum` is referenced in the `outcomes` annotation but is never imported or defined, causing Pydantic type resolution to fail at runtime.</violation>
<violation number="2" location="samples/client/echo_api/python/openapi_client/models/query.py:31">
P1: Validator rejects valid nested outcomes because it still assumes a flat list of enum strings after outcomes became a list of lists.</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">
P1: Missing import/definition for `OutcomesEnum` makes the `outcomes` annotation undefined, causing model build/import failure.</violation>
<violation number="2" location="samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py:31">
P1: `outcomes` now declared as nested list but validator still flat, causing TypeError/unusable validation for any non-null value</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: Nullable anyOf root models no longer accept `null`/`None` because the root union and Field are required and exclude `None`.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/python/model_anyof.mustache:15">
P1: RootModel base evaluates anyOf types before postponed imports, risking NameError when any union member is only imported in the deferred block.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
samples/client/echo_api/python/openapi_client/models/number_properties_only.py
Show resolved
Hide resolved
samples/client/echo_api/python/openapi_client/models/default_value.py
Outdated
Show resolved
Hide resolved
...hon-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py
Show resolved
Hide resolved
...o_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py
Outdated
Show resolved
Hide resolved
...client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_generic.mustache
Outdated
Show resolved
Hide resolved
| NAME = "openapi-client" | ||
| VERSION = "1.0.0" | ||
| PYTHON_REQUIRES = ">= 3.9" | ||
| PYTHON_REQUIRES = ">= 3.11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Updated PYTHON_REQUIRES is unused—setup() omits python_requires, so the minimum Python version isn’t enforced from this setup.py.
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/setup.py, line 25:
<comment>Updated PYTHON_REQUIRES is unused—setup() omits python_requires, so the minimum Python version isn’t enforced from this setup.py.</comment>
<file context>
@@ -23,7 +22,7 @@
NAME = "openapi-client"
VERSION = "1.0.0"
-PYTHON_REQUIRES = ">= 3.9"
+PYTHON_REQUIRES = ">= 3.11"
REQUIRES = [
"urllib3 >= 2.1.0, < 3.0.0",
</file context>
modules/openapi-generator/src/main/resources/python/model_anyof.mustache
Show resolved
Hide resolved
...t/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py
Outdated
Show resolved
Hide resolved
add to_json / to_dict/ to_str ./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
21 issues found across 28 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/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py:52">
P2: `to_dict` return type incorrectly marked Optional even though method always returns a dict and root is required</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py:18">
P1: Missing List import causes NameError when evaluating RootModel[Union[List[int], str]]</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/color.py:18">
P1: Missing `List` import causes NameError when evaluating `RootModel[Union[List[int], str]]`.</violation>
<violation number="2" location="samples/openapi3/client/petstore/python/petstore_api/models/color.py:49">
P2: `to_dict` return type/doc claims dict but returns root value (list/str) from RootModel, creating a type mismatch</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py:18">
P1: Module import fails: `List` is used in `RootModel[Union[List[int], str]]` but is no longer imported, causing NameError on module load.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py:18">
P1: List is used in the model base/annotations but is no longer imported, causing NameError at module import/class definition.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py:18">
P1: Missing List import causes NameError at class definition for RootModel[Union[List[int], str]]</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py:49">
P2: `to_dict` promises a dict but returns the root list/string from `RootModel.model_dump`, misleading callers and type checkers.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py:49">
P2: to_dict return type/docs claim a dict/optional but actually return raw int/str from RootModel, misleading callers</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py:51">
P2: `to_dict` is annotated/documented to return a dict but actually returns the root value; `RootModel.model_dump()` returns the root, not a dict, so callers will get a str/enum instead of a mapping.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py:49">
P2: `to_dict` advertises returning a dict but returns the root int/str value from `model_dump`, causing a type/documentation mismatch that can mislead callers.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py:52">
P3: `to_dict` return type is incorrectly marked Optional even though the method never returns None</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:40">
P2: Incorrect return type hint: `to_dict` uses `model_dump` (returns serialized data) but annotates union with model classes, misleading type checking.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py:18">
P1: Missing `List` import causes NameError when evaluating `RootModel[Union[List[int], str]]`</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py:49">
P2: `to_dict` return type claims a dict but `RootModel` dump returns list/str, misleading callers and risking runtime errors.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py:18">
P1: `List` not imported: module will raise NameError when evaluating Union[List[int], str]</violation>
<violation number="2" location="samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py:51">
P2: Return annotation for to_dict is broader than actual: model_dump on this RootModel cannot return Dict or None; it returns the required Union[List[int], str].</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py:49">
P2: to_dict() is typed/doc’d to return a dict but RootModel.model_dump returns the root int/str, so callers will receive a primitive rather than the advertised dict</violation>
</file>
<file name="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py:18">
P1: Missing typing.List import causes NameError when evaluating RootModel[Union[List[int], str]].</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py:49">
P2: `to_dict` is annotated/documented to return a dict, but for this RootModel it actually returns the root value (list/str), making the API contract misleading and potentially breaking callers expecting a mapping.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py:49">
P1: `to_dict` is annotated/documented as returning a dict but actually returns the root int/str value from `RootModel.model_dump`, causing incorrect typing and potential runtime misuse.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py
Outdated
Show resolved
Hide resolved
add to_json / to_dict/ to_str ./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
23 issues found across 28 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/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py:18">
P1: List is used in the RootModel type parameters but is not imported, causing a NameError at import time.</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py:51">
P2: `to_dict` return type is incorrect for RootModel; `model_dump` returns the root value (list/str), not a dict.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py:18">
P1: List not imported though used in RootModel type arguments, causing NameError at import time</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py:51">
P2: `to_dict` return annotation claims `Dict[str, Any]` but actually returns the root value (list or str) of this `RootModel`, causing a mismatched contract.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py:18">
P1: Missing import for `List` used in RootModel and annotations causes NameError at import time.</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py:51">
P2: to_dict() return type claims Dict but model_dump on RootModel returns the root list/str, so annotation and doc are incorrect</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py:18">
P1: `List` is referenced in the RootModel base type but is never imported, causing a NameError when the module is imported.</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py:51">
P2: `to_dict` return type is incorrect for RootModel; it returns the root value (list/str), not a dict.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py:53">
P2: `to_dict` advertises `Dict[str, Any]` but returns the root scalar/enum from `RootModel.model_dump`, causing a runtime type mismatch</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/color.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/color.py:18">
P1: `List` is used in the base class but not imported, causing NameError at import time.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py:18">
P1: Missing typing.List import causes NameError when evaluating RootModel[Union[List[int], str]].</violation>
<violation number="2" location="samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py:51">
P2: `to_dict` return type/docstring claims a dict but model_dump on RootModel returns the root value (list or str)</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py:18">
P1: Missing import for `List` causes NameError during class definition, breaking module import</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py:51">
P2: `to_dict` return type is incorrect for RootModel; model_dump returns the root list/str, not a dict</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:40">
P2: `to_dict` now claims to return `Dict[str, Any]` but still returns the root value, which may be non-dict for primitive/array anyOf branches, causing a contract mismatch and potential runtime errors.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py:18">
P1: `List` is used in type arguments but never imported, causing a NameError during class definition.</violation>
<violation number="2" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py:51">
P2: to_dict() is now typed/documented as returning Dict but model_dump on RootModel returns the root value (list or str), so callers expecting a dict will misbehave.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py:51">
P2: to_dict() type/docstring claim a dict but returns scalar root value for this RootModel, breaking the method contract</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py:51">
P2: to_dict() is annotated/docstringed to return a dict but actually returns the scalar root value for this RootModel (int/str), misleading callers and risking runtime errors</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py:53">
P2: `to_dict` return type is incorrect: RootModel.model_dump returns the root enum/string value, not a dict, so callers expecting a mapping will receive a scalar.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py:51">
P2: `to_dict` return type/docstring claim a dict but actually return an int/str from RootModel.model_dump, risking misuse and serialization 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:40">
P2: `to_dict` return type misdeclared: RootModel may return non-dict values for primitive/array oneOf variants</violation>
</file>
<file name="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py">
<violation number="1" location="samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py:51">
P2: `to_dict` type and docstring claim a dict but `model_dump` on RootModel returns the root value (`int`/`str`), so callers expecting a mapping will get a scalar.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python/petstore_api/models/color.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/model_oneof.mustache
Show resolved
Hide resolved
samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py
Show resolved
Hide resolved
allow inline Enums add to_json / to_dict/ to_str ./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 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:13">
P2: Forward references for oneOf models are no longer resolved because deferred imports and model_rebuild were removed, risking runtime ForwardRef errors.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/python/model_oneof.mustache:17">
P1: Nullable oneOf models no longer accept null: root field is required and excludes None</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:38">
P1: status enum literals include embedded quotes, so valid values like "available" now fail Literal/validator checks</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:32">
P2: outcomes enum literals include spurious quotes, rejecting valid values (expects "'SUCCESS'" instead of "SUCCESS")</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:25">
P1: Unknown fields are no longer rejected: Tag now uses default pydantic extra=ignore after removing the from_dict extra-field check, so additional properties are silently accepted and dropped instead of raising.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
modules/openapi-generator/src/main/resources/python/model_oneof.mustache
Outdated
Show resolved
Hide resolved
| import pprint | ||
| import re # noqa: F401 | ||
| import json | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Unknown fields are no longer rejected: Tag now uses default pydantic extra=ignore after removing the from_dict extra-field check, so additional properties are silently accepted and dropped instead of raising.
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 25:
<comment>Unknown fields are no longer rejected: Tag now uses default pydantic extra=ignore after removing the from_dict extra-field check, so additional properties are silently accepted and dropped instead of raising.</comment>
<file context>
@@ -20,8 +20,9 @@
-from typing_extensions import Self
+from typing import Optional, Set, Literal
+from typing import Self
+from pydantic import Field
class Tag(BaseModel):
</file context>
| @@ -1,209 +1,46 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Forward references for oneOf models are no longer resolved because deferred imports and model_rebuild were removed, risking runtime ForwardRef errors.
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_oneof.mustache, line 13:
<comment>Forward references for oneOf models are no longer resolved because deferred imports and model_rebuild were removed, risking runtime ForwardRef errors.</comment>
<file context>
@@ -1,209 +1,46 @@
-class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}):
+
+class {{classname}}(RootModel[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]]):
"""
{{{description}}}{{^description}}{{{classname}}}{{/description}}
</file context>
add to_json / to_dict/ to_str ./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue 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/pet.py">
<violation number="1" location="samples/client/echo_api/python/openapi_client/models/pet.py:25">
P1: Removed `to_json`/`from_json`/`to_dict`/`from_dict` methods; existing tests still call them, causing `AttributeError` and changing serialization behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
restore from_dict() / from_json() ./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || ex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 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/pyproject.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/python/pyproject.mustache:68">
P1: httpx dependency now gated by {{#asyncio}} so httpx clients omit required dependency</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/python/pyproject.mustache:68">
P1: Invalid TOML: httpx entry in project.dependencies uses key assignment inside the array instead of a PEP 508 string, producing an unparsable pyproject.toml when httpx is enabled.</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">
P1: Additional properties are now silently accepted because the model no longer rejects unknown keys and `extra="forbid"` is not configured.</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:14">
P2: Importing `Self` from `typing` requires Python 3.11+, breaking runtime compatibility with earlier Python versions still implied by the sample client.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| import pprint | ||
| import re # noqa: F401 | ||
| import json | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Additional properties are now silently accepted because the model no longer rejects unknown keys and extra="forbid" is not configured.
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>Additional properties are now silently accepted because the model no longer rejects unknown keys and `extra="forbid"` is not configured.</comment>
<file context>
@@ -20,8 +20,9 @@
from typing import Any, ClassVar, Dict, List, Optional
-from typing import Optional, Set
-from typing_extensions import Self
+from typing import Optional, Set, Literal
+from typing import Self
+from pydantic import Field
</file context>
| from typing import Any, Optional | ||
| from typing_extensions import Self | ||
|
|
||
| from typing import Any, Optional, Self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Importing Self from typing requires Python 3.11+, breaking runtime compatibility with earlier Python versions still implied by the sample client.
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/exceptions.py, line 14:
<comment>Importing `Self` from `typing` requires Python 3.11+, breaking runtime compatibility with earlier Python versions still implied by the sample client.</comment>
<file context>
@@ -12,8 +10,8 @@
-from typing import Any, Optional
-from typing_extensions import Self
+
+from typing import Any, Optional, Self
class OpenApiException(Exception):
</file context>
There was a problem hiding this 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 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/number_properties_only.py">
<violation number="1" location="samples/client/echo_api/python/openapi_client/models/number_properties_only.py:47">
P1: Removed to_json/from_json/from_dict/to_dict helpers; existing call sites (tests) still call from_json, causing AttributeError at runtime.</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:14">
P2: Importing Self from typing requires Python 3.11+, causing ImportError on older supported runtimes unless minimum version is raised.</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: sanitize_for_serialization can crash on RootModel of primitives; model_dump may return a scalar but code blindly iterates obj_dict.items()</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:24">
P1: Removed custom serialization drops explicit nulls for nullable fields when exclude_none=True, changing request semantics</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: python_requires updated to 3.11 but not passed to setup(), so the minimum Python version is not enforced in package metadata.</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:68">
P1: Invalid PEP 621 dependency entry: uses assignment inside dependencies array, producing unparsable pyproject.toml</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
samples/client/echo_api/python/openapi_client/models/number_properties_only.py
Show resolved
Hide resolved
| obj_dict = obj.to_dict() | ||
| else: | ||
| obj_dict = obj.__dict__ | ||
| obj_dict = obj.model_dump(by_alias=True, exclude_none=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: sanitize_for_serialization can crash on RootModel of primitives; model_dump may return a scalar but code blindly iterates obj_dict.items()
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>sanitize_for_serialization can crash on RootModel of primitives; model_dump may return a scalar but code blindly iterates obj_dict.items()</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>
| import re # noqa: F401 | ||
| import json | ||
|
|
||
| from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Removed custom serialization drops explicit nulls for nullable fields when exclude_none=True, changing request semantics
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 24:
<comment>Removed custom serialization drops explicit nulls for nullable fields when exclude_none=True, changing request semantics</comment>
<file context>
@@ -21,15 +21,19 @@
from openapi_client.models.string_enum_ref import StringEnumRef
-from typing import Optional, Set
-from typing_extensions import Self
+from typing import Optional, Set, Literal
+from typing import Self
+from pydantic import Field
</file context>
| "aiohttp (>=3.8.4)", | ||
| "aiohttp-retry (>=2.8.3)", | ||
| {{#httpx}} | ||
| httpx = ">= 0.28.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Invalid PEP 621 dependency entry: uses assignment inside dependencies array, producing unparsable pyproject.toml
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 68:
<comment>Invalid PEP 621 dependency entry: uses assignment inside dependencies array, producing unparsable pyproject.toml</comment>
<file context>
@@ -58,19 +56,17 @@ lazy-imports = ">= 1, < 2"
"aiohttp (>=3.8.4)",
"aiohttp-retry (>=2.8.3)",
+{{#httpx}}
+httpx = ">= 0.28.1",
+{{/httpx}}
{{/asyncio}}
</file context>
| from typing import Any, Optional | ||
| from typing_extensions import Self | ||
|
|
||
| from typing import Any, Optional, Self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Importing Self from typing requires Python 3.11+, causing ImportError on older supported runtimes unless minimum version is raised.
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/exceptions.py, line 14:
<comment>Importing Self from typing requires Python 3.11+, causing ImportError on older supported runtimes unless minimum version is raised.</comment>
<file context>
@@ -12,8 +10,8 @@
-from typing import Any, Optional
-from typing_extensions import Self
+
+from typing import Any, Optional, Self
class OpenApiException(Exception):
</file context>
| NAME = "openapi-client" | ||
| VERSION = "1.0.0" | ||
| PYTHON_REQUIRES = ">= 3.9" | ||
| PYTHON_REQUIRES = ">= 3.11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: python_requires updated to 3.11 but not passed to setup(), so the minimum Python version is not enforced in package metadata.
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/setup.py, line 25:
<comment>python_requires updated to 3.11 but not passed to setup(), so the minimum Python version is not enforced in package metadata.</comment>
<file context>
@@ -23,7 +22,7 @@
NAME = "openapi-client"
VERSION = "1.0.0"
-PYTHON_REQUIRES = ">= 3.9"
+PYTHON_REQUIRES = ">= 3.11"
REQUIRES = [
"urllib3 >= 2.1.0, < 3.0.0",
</file context>
restore from_dict() / from_json()
for Python 3.11+
anyOf / allOf Root model based
StrEnum, IntEnum
PR checklist
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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)@cbornet
@tomplus
@krjakbrjak
@fa0311
@multani
Fixes issues:
anyOfis not supported within items #22261Summary by cubic
Modernizes the Python generator for 3.11+ by adopting Pydantic v2 APIs and RootModel-based unions for anyOf/oneOf. Adds StrEnum/IntEnum, Literal-typed inline enums, simplifies serialization, and updates client/header handling for urllib3 v2.
New Features
Migration
Written for commit 9a41599. Summary will update on new commits.