[Python] Add Flag to Allow Ignoring Operation Servers (#18981)

* [Python] Add Flag to Allow Ignoring Operation Servers

* generate samples

* add tests
This commit is contained in:
Cameron Koegel
2024-06-26 03:08:13 -04:00
committed by GitHub
parent 38d189b159
commit 0d05ee35f0
13 changed files with 108 additions and 5 deletions

View File

@@ -228,7 +228,7 @@ class ApiClient:
body = self.sanitize_for_serialization(body)
# request url
if _host is None:
if _host is None or self.configuration.ignore_operation_servers:
url = self.configuration.host + resource_path
else:
# use server/host defined in path or operation instead

View File

@@ -33,6 +33,9 @@ class Configuration:
"""This class contains various settings of the API client.
:param host: Base url.
:param ignore_operation_servers
Boolean to ignore operation servers for the API client.
Config will use `host` as the base url regardless of the operation servers.
:param api_key: Dict to store API key(s).
Each entry in the dict specifies an API key.
The dict key is the name of the security scheme in the OAS specification.
@@ -84,6 +87,7 @@ conf = openapi_client.Configuration(
access_token=None,
server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
ignore_operation_servers=False,
ssl_ca_cert=None,
retries=None,
*,
@@ -102,6 +106,9 @@ conf = openapi_client.Configuration(
self.server_operation_variables = server_operation_variables or {}
"""Default server variables
"""
self.ignore_operation_servers = ignore_operation_servers
"""Ignore operation servers
"""
self.temp_folder_path = None
"""Temp file folder for downloading files
"""