forked from loafle/openapi-generator-original
Add nullable support to Python client (#1073)
* add nullable support to python client * update PR template
This commit is contained in:
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
|
||||
- [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\bin\windows\`.
|
||||
- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `3.3.x`, `4.0.x`. Default: `master`.
|
||||
- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master` (3.3.x), `4.0.x`. Default: `master`.
|
||||
- [ ] Copied the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language.
|
||||
|
||||
### Description of the PR
|
||||
|
||||
@@ -99,12 +99,14 @@ class {{classname}}(object):
|
||||
local_var_params[key] = val
|
||||
del local_var_params['kwargs']
|
||||
{{#allParams}}
|
||||
{{^isNullable}}
|
||||
{{#required}}
|
||||
# verify the required parameter '{{paramName}}' is set
|
||||
if ('{{paramName}}' not in local_var_params or
|
||||
local_var_params['{{paramName}}'] is None):
|
||||
raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{/allParams}}
|
||||
|
||||
{{#allParams}}
|
||||
|
||||
@@ -64,8 +64,13 @@ class {{classname}}(object):
|
||||
self.{{name}} = {{name}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{#isNullable}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
if {{name}} is not None:
|
||||
self.{{name}} = {{name}}
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
|
||||
@@ -94,10 +99,12 @@ class {{classname}}(object):
|
||||
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
||||
:type: {{dataType}}
|
||||
"""
|
||||
{{^isNullable}}
|
||||
{{#required}}
|
||||
if {{name}} is None:
|
||||
raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{#isEnum}}
|
||||
{{#isContainer}}
|
||||
allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.2.2-SNAPSHOT
|
||||
3.3.0-SNAPSHOT
|
||||
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
|
||||
**map_map_of_string** | **dict(str, dict(str, str))** | | [optional]
|
||||
**map_of_enum_string** | **dict(str, str)** | | [optional]
|
||||
**direct_map** | **dict(str, bool)** | | [optional]
|
||||
**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
|
||||
**indirect_map** | **dict(str, bool)** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MapTest(object):
|
||||
'map_map_of_string': 'dict(str, dict(str, str))',
|
||||
'map_of_enum_string': 'dict(str, str)',
|
||||
'direct_map': 'dict(str, bool)',
|
||||
'indirect_map': 'StringBooleanMap'
|
||||
'indirect_map': 'dict(str, bool)'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
@@ -138,7 +138,7 @@ class MapTest(object):
|
||||
|
||||
|
||||
:return: The indirect_map of this MapTest. # noqa: E501
|
||||
:rtype: StringBooleanMap
|
||||
:rtype: dict(str, bool)
|
||||
"""
|
||||
return self._indirect_map
|
||||
|
||||
@@ -148,7 +148,7 @@ class MapTest(object):
|
||||
|
||||
|
||||
:param indirect_map: The indirect_map of this MapTest. # noqa: E501
|
||||
:type: StringBooleanMap
|
||||
:type: dict(str, bool)
|
||||
"""
|
||||
|
||||
self._indirect_map = indirect_map
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.2.2-SNAPSHOT
|
||||
3.3.0-SNAPSHOT
|
||||
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
|
||||
**map_map_of_string** | **dict(str, dict(str, str))** | | [optional]
|
||||
**map_of_enum_string** | **dict(str, str)** | | [optional]
|
||||
**direct_map** | **dict(str, bool)** | | [optional]
|
||||
**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
|
||||
**indirect_map** | **dict(str, bool)** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MapTest(object):
|
||||
'map_map_of_string': 'dict(str, dict(str, str))',
|
||||
'map_of_enum_string': 'dict(str, str)',
|
||||
'direct_map': 'dict(str, bool)',
|
||||
'indirect_map': 'StringBooleanMap'
|
||||
'indirect_map': 'dict(str, bool)'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
@@ -138,7 +138,7 @@ class MapTest(object):
|
||||
|
||||
|
||||
:return: The indirect_map of this MapTest. # noqa: E501
|
||||
:rtype: StringBooleanMap
|
||||
:rtype: dict(str, bool)
|
||||
"""
|
||||
return self._indirect_map
|
||||
|
||||
@@ -148,7 +148,7 @@ class MapTest(object):
|
||||
|
||||
|
||||
:param indirect_map: The indirect_map of this MapTest. # noqa: E501
|
||||
:type: StringBooleanMap
|
||||
:type: dict(str, bool)
|
||||
"""
|
||||
|
||||
self._indirect_map = indirect_map
|
||||
|
||||
Reference in New Issue
Block a user