diff --git a/README.md b/README.md index d11dd683590..f08798582d5 100644 --- a/README.md +++ b/README.md @@ -1136,7 +1136,7 @@ If you want to join the committee, please kindly apply by sending an email to te | Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) | | PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), [@ybelenko](https://github.com/ybelenko) (2018/07), @renepardon (2018/12) | | PowerShell | @wing328 (2020/05) | -| Python | @spacether (2019/11) [:heart:][spacether sponsorship] | +| Python | @spacether (2019/11) [:heart:][spacether sponsorship] @krjakbrjak (2023/02) | | R | @Ramanth (2019/07) @saigiridhar21 (2019/07) | | Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) | | Rust | @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) | diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java index c37f6dcf466..52e021c9c73 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java @@ -974,7 +974,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements codegenProperties = model.vars; } - //loop through properties/schemas to setup typing, pydantic + //loop through properties/schemas to set up typing, pydantic for (CodegenProperty cp : codegenProperties) { String typing = getPydanticType(cp, typingImports, pydanticImports, datetimeImports, modelImports); List fields = new ArrayList<>(); @@ -1020,7 +1020,12 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements if (cp.defaultValue == null) { fieldCustomization = "None"; } else { - fieldCustomization = cp.defaultValue; + if (cp.isArray || cp.isMap) { + // TODO handle default value for array/map + fieldCustomization = "None"; + } else { + fieldCustomization = cp.defaultValue; + } } } else { // required field fieldCustomization = firstField; diff --git a/modules/openapi-generator/src/main/resources/python-nextgen/configuration.mustache b/modules/openapi-generator/src/main/resources/python-nextgen/configuration.mustache index 4301c13e20f..6a3ac109bc0 100644 --- a/modules/openapi-generator/src/main/resources/python-nextgen/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/python-nextgen/configuration.mustache @@ -38,30 +38,7 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication. :param password: Password for HTTP basic authentication. - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. - :param disabled_client_side_validations (string): Comma-separated list of - JSON schema validation keywords to disable JSON schema structural validation - rules. The following keywords may be specified: multipleOf, maximum, - exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, - maxItems, minItems. - By default, the validation is performed for data generated locally by the client - and data received from the server, independent of any validation performed by - the server side. If the input data does not satisfy the JSON schema validation - rules specified in the OpenAPI document, an exception is raised. - If disabled_client_side_validations is set, structural validation is - disabled. This can be useful to troubleshoot data validation problem, such as - when the OpenAPI document validation rules do not match the actual API data - received by the server. + :param access_token: Access token. {{#hasHttpSignatureMethods}} :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration @@ -168,8 +145,7 @@ conf = {{{packageName}}}.Configuration( def __init__(self, host=None, api_key=None, api_key_prefix=None, username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations="", + access_token=None, {{#hasHttpSignatureMethods}} signing_info=None, {{/hasHttpSignatureMethods}} @@ -213,8 +189,9 @@ conf = {{{packageName}}}.Configuration( self.password = password """Password for HTTP basic authentication """ - self.discard_unknown_keys = discard_unknown_keys - self.disabled_client_side_validations = disabled_client_side_validations + self.access_token = access_token + """Access token + """ {{#hasHttpSignatureMethods}} if signing_info is not None: signing_info.host = host @@ -324,13 +301,6 @@ conf = {{{packageName}}}.Configuration( def __setattr__(self, name, value): object.__setattr__(self, name, value) - if name == 'disabled_client_side_validations': - s = set(filter(None, value.split(','))) - for v in s: - if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: - raise ApiValueError( - "Invalid keyword: '{0}''".format(v)) - self._disabled_client_side_validations = s {{#hasHttpSignatureMethods}} if name == "signing_info" and value is not None: # Ensure the host parameter from signing info is the same as diff --git a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/configuration.py index 8c22f571fbf..d0c210e5a9b 100644 --- a/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-nextgen-aiohttp/petstore_api/configuration.py @@ -43,30 +43,7 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication. :param password: Password for HTTP basic authentication. - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. - :param disabled_client_side_validations (string): Comma-separated list of - JSON schema validation keywords to disable JSON schema structural validation - rules. The following keywords may be specified: multipleOf, maximum, - exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, - maxItems, minItems. - By default, the validation is performed for data generated locally by the client - and data received from the server, independent of any validation performed by - the server side. If the input data does not satisfy the JSON schema validation - rules specified in the OpenAPI document, an exception is raised. - If disabled_client_side_validations is set, structural validation is - disabled. This can be useful to troubleshoot data validation problem, such as - when the OpenAPI document validation rules do not match the actual API data - received by the server. + :param access_token: Access token. :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of petstore_api.signing.HttpSigningConfiguration :param server_index: Index to servers configuration. @@ -163,8 +140,7 @@ conf = petstore_api.Configuration( def __init__(self, host=None, api_key=None, api_key_prefix=None, username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations="", + access_token=None, signing_info=None, server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, @@ -206,8 +182,9 @@ conf = petstore_api.Configuration( self.password = password """Password for HTTP basic authentication """ - self.discard_unknown_keys = discard_unknown_keys - self.disabled_client_side_validations = disabled_client_side_validations + self.access_token = access_token + """Access token + """ if signing_info is not None: signing_info.host = host self.signing_info = signing_info @@ -295,13 +272,6 @@ conf = petstore_api.Configuration( def __setattr__(self, name, value): object.__setattr__(self, name, value) - if name == 'disabled_client_side_validations': - s = set(filter(None, value.split(','))) - for v in s: - if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: - raise ApiValueError( - "Invalid keyword: '{0}''".format(v)) - self._disabled_client_side_validations = s if name == "signing_info" and value is not None: # Ensure the host parameter from signing info is the same as # Configuration.host. diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-nextgen/petstore_api/configuration.py index acae925a0cb..72f32620259 100755 --- a/samples/openapi3/client/petstore/python-nextgen/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api/configuration.py @@ -44,30 +44,7 @@ class Configuration(object): The dict value is an API key prefix when generating the auth data. :param username: Username for HTTP basic authentication. :param password: Password for HTTP basic authentication. - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. - :param disabled_client_side_validations (string): Comma-separated list of - JSON schema validation keywords to disable JSON schema structural validation - rules. The following keywords may be specified: multipleOf, maximum, - exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, - maxItems, minItems. - By default, the validation is performed for data generated locally by the client - and data received from the server, independent of any validation performed by - the server side. If the input data does not satisfy the JSON schema validation - rules specified in the OpenAPI document, an exception is raised. - If disabled_client_side_validations is set, structural validation is - disabled. This can be useful to troubleshoot data validation problem, such as - when the OpenAPI document validation rules do not match the actual API data - received by the server. + :param access_token: Access token. :param signing_info: Configuration parameters for the HTTP signature security scheme. Must be an instance of petstore_api.signing.HttpSigningConfiguration :param server_index: Index to servers configuration. @@ -164,8 +141,7 @@ conf = petstore_api.Configuration( def __init__(self, host=None, api_key=None, api_key_prefix=None, username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations="", + access_token=None, signing_info=None, server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, @@ -207,8 +183,9 @@ conf = petstore_api.Configuration( self.password = password """Password for HTTP basic authentication """ - self.discard_unknown_keys = discard_unknown_keys - self.disabled_client_side_validations = disabled_client_side_validations + self.access_token = access_token + """Access token + """ if signing_info is not None: signing_info.host = host self.signing_info = signing_info @@ -299,13 +276,6 @@ conf = petstore_api.Configuration( def __setattr__(self, name, value): object.__setattr__(self, name, value) - if name == 'disabled_client_side_validations': - s = set(filter(None, value.split(','))) - for v in s: - if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: - raise ApiValueError( - "Invalid keyword: '{0}''".format(v)) - self._disabled_client_side_validations = s if name == "signing_info" and value is not None: # Ensure the host parameter from signing info is the same as # Configuration.host.