Skip to content

Comments

feat(python): expose all config properties in constructor#23021

Open
timonrieger wants to merge 5 commits intoOpenAPITools:masterfrom
timonrieger:feat/expose-config-python
Open

feat(python): expose all config properties in constructor#23021
timonrieger wants to merge 5 commits intoOpenAPITools:masterfrom
timonrieger:feat/expose-config-python

Conversation

@timonrieger
Copy link
Contributor

@timonrieger timonrieger commented Feb 21, 2026

Configuration options that were only assignable after construction are now constructor parameters for the Python generator, so callers can set them in one place.

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.

cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)


Summary by cubic

Expose all Python client Configuration options as constructor parameters so users can set everything at initialization. Defaults are preserved; samples and docstrings updated, and pydantic v1 templates remain unchanged after reverting earlier additions.

  • New Features
    • Added constructor args for verify_ssl, assert_hostname, tls_server_name, connection_pool_maxsize, proxy, proxy_headers, safe_chars_for_path_param, client_side_validation, socket_options, datetime_format, and date_format.
    • Connection pool size is configurable; passing None keeps defaults (100 for async, cpu_count*5 for sync).
    • Regenerated samples to reflect the new constructor options.

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

Copy link
Contributor

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

Choose a reason for hiding this comment

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

5 issues found across 11 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py">

<violation number="1" location="samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py:99">
P2: Constructor still lacks newly documented parameters (retries, cert_file, proxy, etc.), so passing these advertised keyword arguments will raise TypeError.</violation>
</file>

<file name="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/configuration.py">

<violation number="1" location="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/configuration.py:58">
P2: Constructor docstring now advertises parameters (e.g., retries, cert_file, proxy) that are not accepted by __init__, so passing them will raise unexpected keyword argument errors.</violation>
</file>

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

<violation number="1" location="modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache:54">
P2: Docstring documents new constructor parameters (e.g., retries, cert_file, key_file, proxy, connection_pool_maxsize) but __init__ does not accept them, so using these documented arguments will raise `TypeError: __init__() got an unexpected keyword argument`.</violation>
</file>

<file name="samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py">

<violation number="1" location="samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py:159">
P2: Constructor docstring documents new parameters (cert_file, retries, proxy, etc.) but __init__ does not accept them, so using documented kwargs will raise a TypeError and users cannot set these values via the constructor.</violation>
</file>

<file name="samples/openapi3/client/petstore/python/petstore_api/configuration.py">

<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/configuration.py:286">
P3: `assert_hostname` is typed as Optional[bool], but urllib3 accepts a string hostname (or False/None). This type hint incorrectly excludes valid string values, causing type-checkers to flag legitimate usage.</violation>
</file>

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

server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
ssl_ca_cert=None,
ssl_ca_cert=None, verify_ssl=True,
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: Constructor still lacks newly documented parameters (retries, cert_file, proxy, etc.), so passing these advertised keyword arguments will raise TypeError.

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-pydantic-v1/openapi_client/configuration.py, line 99:

<comment>Constructor still lacks newly documented parameters (retries, cert_file, proxy, etc.), so passing these advertised keyword arguments will raise TypeError.</comment>

<file context>
@@ -81,7 +96,7 @@ def __init__(self, host=None,
                  server_index=None, server_variables=None,
                  server_operation_index=None, server_operation_variables=None,
-                 ssl_ca_cert=None,
+                 ssl_ca_cert=None, verify_ssl=True,
                  ) -> None:
         """Constructor
</file context>
Fix with Cubic

server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
ssl_ca_cert=None,
ssl_ca_cert=None, verify_ssl=True,
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: Constructor docstring documents new parameters (cert_file, retries, proxy, etc.) but init does not accept them, so using documented kwargs will raise a TypeError and users cannot set these values via the constructor.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py, line 159:

<comment>Constructor docstring documents new parameters (cert_file, retries, proxy, etc.) but __init__ does not accept them, so using documented kwargs will raise a TypeError and users cannot set these values via the constructor.</comment>

<file context>
@@ -141,7 +156,7 @@ def __init__(self, host=None,
                  server_index=None, server_variables=None,
                  server_operation_index=None, server_operation_variables=None,
-                 ssl_ca_cert=None,
+                 ssl_ca_cert=None, verify_ssl=True,
                  ) -> None:
         """Constructor
</file context>
Fix with Cubic

cert_file: Optional[str]=None,
key_file: Optional[str]=None,
verify_ssl: bool=True,
assert_hostname: Optional[bool]=None,
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P3: assert_hostname is typed as Optional[bool], but urllib3 accepts a string hostname (or False/None). This type hint incorrectly excludes valid string values, causing type-checkers to flag legitimate usage.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python/petstore_api/configuration.py, line 286:

<comment>`assert_hostname` is typed as Optional[bool], but urllib3 accepts a string hostname (or False/None). This type hint incorrectly excludes valid string values, causing type-checkers to flag legitimate usage.</comment>

<file context>
@@ -270,6 +282,17 @@ def __init__(
         cert_file: Optional[str]=None,
         key_file: Optional[str]=None,
+        verify_ssl: bool=True,
+        assert_hostname: Optional[bool]=None,
+        tls_server_name: Optional[str]=None,
+        connection_pool_maxsize: Optional[int]=None,
</file context>
Suggested change
assert_hostname: Optional[bool]=None,
assert_hostname: Optional[Union[bool, str]]=None,
Fix with Cubic

Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 4 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. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py">

<violation number="1">
P2: verify_ssl is no longer configurable in the constructor; it’s hardcoded to True, removing the ability to pass verify_ssl=False during initialization.</violation>
</file>

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

@@ -602,4 +602,4 @@ def host(self):
def host(self, value):
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: verify_ssl is no longer configurable in the constructor; it’s hardcoded to True, removing the ability to pass verify_ssl=False during initialization.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py, line 211:

<comment>verify_ssl is no longer configurable in the constructor; it’s hardcoded to True, removing the ability to pass verify_ssl=False during initialization.</comment>

<file context>
@@ -223,7 +208,7 @@ def __init__(self, host=None,
         """
 
-        self.verify_ssl = verify_ssl
+        self.verify_ssl = True
         """SSL/TLS verification
            Set this to false to skip verifying SSL certificate when calling API
</file context>
Fix with Cubic

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.

1 participant