diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index 2b5c37ff50a4..be804beec015 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -187,7 +187,7 @@ class {{classname}}: # process the path parameters _path_params = {} {{#pathParams}} - if _params['{{paramName}}']: + if _params['{{paramName}}'] is not None: _path_params['{{baseName}}'] = _params['{{paramName}}'] {{#isArray}} _collection_formats['{{baseName}}'] = '{{collectionFormat}}' @@ -224,7 +224,7 @@ class {{classname}}: # process the header parameters _header_params = dict(_params.get('_headers', {})) {{#headerParams}} - if _params['{{paramName}}']: + if _params['{{paramName}}'] is not None: _header_params['{{baseName}}'] = _params['{{paramName}}'] {{#isArray}} _collection_formats['{{baseName}}'] = '{{collectionFormat}}' @@ -235,7 +235,7 @@ class {{classname}}: _form_params = [] _files = {} {{#formParams}} - if _params['{{paramName}}']: + if _params['{{paramName}}'] is not None: {{^isFile}} _form_params.append(('{{{baseName}}}', _params['{{paramName}}'])) {{/isFile}} diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index 553feae23a3c..ebb8111b7725 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -438,7 +438,7 @@ class BodyApi: # process the form parameters _form_params = [] _files = {} - if _params['files']: + if _params['files'] is not None: _files['files'] = _params['files'] _collection_formats['files'] = 'csv' diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 0071725761d6..7b0f9720c6c9 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -161,13 +161,13 @@ class FormApi: # process the form parameters _form_params = [] _files = {} - if _params['integer_form']: + if _params['integer_form'] is not None: _form_params.append(('integer_form', _params['integer_form'])) - if _params['boolean_form']: + if _params['boolean_form'] is not None: _form_params.append(('boolean_form', _params['boolean_form'])) - if _params['string_form']: + if _params['string_form'] is not None: _form_params.append(('string_form', _params['string_form'])) # process the body parameter @@ -339,22 +339,22 @@ class FormApi: # process the form parameters _form_params = [] _files = {} - if _params['form1']: + if _params['form1'] is not None: _form_params.append(('form1', _params['form1'])) - if _params['form2']: + if _params['form2'] is not None: _form_params.append(('form2', _params['form2'])) - if _params['form3']: + if _params['form3'] is not None: _form_params.append(('form3', _params['form3'])) - if _params['form4']: + if _params['form4'] is not None: _form_params.append(('form4', _params['form4'])) - if _params['id']: + if _params['id'] is not None: _form_params.append(('id', _params['id'])) - if _params['name']: + if _params['name'] is not None: _form_params.append(('name', _params['name'])) # process the body parameter diff --git a/samples/client/echo_api/python/openapi_client/api/header_api.py b/samples/client/echo_api/python/openapi_client/api/header_api.py index 7f9dc25354f5..e9ebc11e9cd9 100644 --- a/samples/client/echo_api/python/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python/openapi_client/api/header_api.py @@ -158,13 +158,13 @@ class HeaderApi: _query_params = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['integer_header']: + if _params['integer_header'] is not None: _header_params['integer_header'] = _params['integer_header'] - if _params['boolean_header']: + if _params['boolean_header'] is not None: _header_params['boolean_header'] = _params['boolean_header'] - if _params['string_header']: + if _params['string_header'] is not None: _header_params['string_header'] = _params['string_header'] # process the form parameters diff --git a/samples/client/echo_api/python/openapi_client/api/path_api.py b/samples/client/echo_api/python/openapi_client/api/path_api.py index 35d0c6a11b0d..a2798c4d604a 100644 --- a/samples/client/echo_api/python/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python/openapi_client/api/path_api.py @@ -146,10 +146,10 @@ class PathApi: # process the path parameters _path_params = {} - if _params['path_string']: + if _params['path_string'] is not None: _path_params['path_string'] = _params['path_string'] - if _params['path_integer']: + if _params['path_integer'] is not None: _path_params['path_integer'] = _params['path_integer'] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index 17c8a17a918c..9bb46314e7ea 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -509,7 +509,7 @@ class FakeApi: # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['header_1']: + if _params['header_1'] is not None: _header_params['header_1'] = _params['header_1'] # process the form parameters @@ -2239,49 +2239,49 @@ class FakeApi: # process the form parameters _form_params = [] _files = {} - if _params['integer']: + if _params['integer'] is not None: _form_params.append(('integer', _params['integer'])) - if _params['int32']: + if _params['int32'] is not None: _form_params.append(('int32', _params['int32'])) - if _params['int64']: + if _params['int64'] is not None: _form_params.append(('int64', _params['int64'])) - if _params['number']: + if _params['number'] is not None: _form_params.append(('number', _params['number'])) - if _params['float']: + if _params['float'] is not None: _form_params.append(('float', _params['float'])) - if _params['double']: + if _params['double'] is not None: _form_params.append(('double', _params['double'])) - if _params['string']: + if _params['string'] is not None: _form_params.append(('string', _params['string'])) - if _params['pattern_without_delimiter']: + if _params['pattern_without_delimiter'] is not None: _form_params.append(('pattern_without_delimiter', _params['pattern_without_delimiter'])) - if _params['byte']: + if _params['byte'] is not None: _form_params.append(('byte', _params['byte'])) - if _params['binary']: + if _params['binary'] is not None: _files['binary'] = _params['binary'] - if _params['byte_with_max_length']: + if _params['byte_with_max_length'] is not None: _form_params.append(('byte_with_max_length', _params['byte_with_max_length'])) - if _params['var_date']: + if _params['var_date'] is not None: _form_params.append(('date', _params['var_date'])) - if _params['date_time']: + if _params['date_time'] is not None: _form_params.append(('dateTime', _params['date_time'])) - if _params['password']: + if _params['password'] is not None: _form_params.append(('password', _params['password'])) - if _params['param_callback']: + if _params['param_callback'] is not None: _form_params.append(('callback', _params['param_callback'])) # process the body parameter @@ -2440,10 +2440,10 @@ class FakeApi: # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['required_boolean_group']: + if _params['required_boolean_group'] is not None: _header_params['required_boolean_group'] = _params['required_boolean_group'] - if _params['boolean_group']: + if _params['boolean_group'] is not None: _header_params['boolean_group'] = _params['boolean_group'] # process the form parameters @@ -2694,10 +2694,10 @@ class FakeApi: # process the form parameters _form_params = [] _files = {} - if _params['param']: + if _params['param'] is not None: _form_params.append(('param', _params['param'])) - if _params['param2']: + if _params['param2'] is not None: _form_params.append(('param2', _params['param2'])) # process the body parameter diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 3eb04cb7cefc..cb4e3ee8896e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -261,7 +261,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -269,7 +269,7 @@ class PetApi: _query_params = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['api_key']: + if _params['api_key'] is not None: _header_params['api_key'] = _params['api_key'] # process the form parameters @@ -636,7 +636,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -897,7 +897,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -908,10 +908,10 @@ class PetApi: # process the form parameters _form_params = [] _files = {} - if _params['name']: + if _params['name'] is not None: _form_params.append(('name', _params['name'])) - if _params['status']: + if _params['status'] is not None: _form_params.append(('status', _params['status'])) # process the body parameter @@ -1038,7 +1038,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -1049,10 +1049,10 @@ class PetApi: # process the form parameters _form_params = [] _files = {} - if _params['additional_metadata']: + if _params['additional_metadata'] is not None: _form_params.append(('additionalMetadata', _params['additional_metadata'])) - if _params['file']: + if _params['file'] is not None: _files['file'] = _params['file'] # process the body parameter @@ -1185,7 +1185,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -1196,10 +1196,10 @@ class PetApi: # process the form parameters _form_params = [] _files = {} - if _params['additional_metadata']: + if _params['additional_metadata'] is not None: _form_params.append(('additionalMetadata', _params['additional_metadata'])) - if _params['required_file']: + if _params['required_file'] is not None: _files['requiredFile'] = _params['required_file'] # process the body parameter diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index f103deea2915..a904a1f2c572 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -130,7 +130,7 @@ class StoreApi: # process the path parameters _path_params = {} - if _params['order_id']: + if _params['order_id'] is not None: _path_params['order_id'] = _params['order_id'] @@ -364,7 +364,7 @@ class StoreApi: # process the path parameters _path_params = {} - if _params['order_id']: + if _params['order_id'] is not None: _path_params['order_id'] = _params['order_id'] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 9591e1ccc63f..379693e4bd0b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -518,7 +518,7 @@ class UserApi: # process the path parameters _path_params = {} - if _params['username']: + if _params['username'] is not None: _path_params['username'] = _params['username'] @@ -636,7 +636,7 @@ class UserApi: # process the path parameters _path_params = {} - if _params['username']: + if _params['username'] is not None: _path_params['username'] = _params['username'] @@ -1010,7 +1010,7 @@ class UserApi: # process the path parameters _path_params = {} - if _params['username']: + if _params['username'] is not None: _path_params['username'] = _params['username'] diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 1bdbf4e06a91..fb80af75b0f2 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -571,7 +571,7 @@ class FakeApi: # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['header_1']: + if _params['header_1'] is not None: _header_params['header_1'] = _params['header_1'] # process the form parameters @@ -2509,49 +2509,49 @@ class FakeApi: # process the form parameters _form_params = [] _files = {} - if _params['integer']: + if _params['integer'] is not None: _form_params.append(('integer', _params['integer'])) - if _params['int32']: + if _params['int32'] is not None: _form_params.append(('int32', _params['int32'])) - if _params['int64']: + if _params['int64'] is not None: _form_params.append(('int64', _params['int64'])) - if _params['number']: + if _params['number'] is not None: _form_params.append(('number', _params['number'])) - if _params['float']: + if _params['float'] is not None: _form_params.append(('float', _params['float'])) - if _params['double']: + if _params['double'] is not None: _form_params.append(('double', _params['double'])) - if _params['string']: + if _params['string'] is not None: _form_params.append(('string', _params['string'])) - if _params['pattern_without_delimiter']: + if _params['pattern_without_delimiter'] is not None: _form_params.append(('pattern_without_delimiter', _params['pattern_without_delimiter'])) - if _params['byte']: + if _params['byte'] is not None: _form_params.append(('byte', _params['byte'])) - if _params['binary']: + if _params['binary'] is not None: _files['binary'] = _params['binary'] - if _params['byte_with_max_length']: + if _params['byte_with_max_length'] is not None: _form_params.append(('byte_with_max_length', _params['byte_with_max_length'])) - if _params['var_date']: + if _params['var_date'] is not None: _form_params.append(('date', _params['var_date'])) - if _params['date_time']: + if _params['date_time'] is not None: _form_params.append(('dateTime', _params['date_time'])) - if _params['password']: + if _params['password'] is not None: _form_params.append(('password', _params['password'])) - if _params['param_callback']: + if _params['param_callback'] is not None: _form_params.append(('callback', _params['param_callback'])) # process the body parameter @@ -2726,10 +2726,10 @@ class FakeApi: # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['required_boolean_group']: + if _params['required_boolean_group'] is not None: _header_params['required_boolean_group'] = _params['required_boolean_group'] - if _params['boolean_group']: + if _params['boolean_group'] is not None: _header_params['boolean_group'] = _params['boolean_group'] # process the form parameters @@ -3012,10 +3012,10 @@ class FakeApi: # process the form parameters _form_params = [] _files = {} - if _params['param']: + if _params['param'] is not None: _form_params.append(('param', _params['param'])) - if _params['param2']: + if _params['param2'] is not None: _form_params.append(('param2', _params['param2'])) # process the body parameter diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index f0eefd7ec890..44df5ee26605 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -291,7 +291,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -299,7 +299,7 @@ class PetApi: _query_params = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) - if _params['api_key']: + if _params['api_key'] is not None: _header_params['api_key'] = _params['api_key'] # process the form parameters @@ -714,7 +714,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -1007,7 +1007,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -1018,10 +1018,10 @@ class PetApi: # process the form parameters _form_params = [] _files = {} - if _params['name']: + if _params['name'] is not None: _form_params.append(('name', _params['name'])) - if _params['status']: + if _params['status'] is not None: _form_params.append(('status', _params['status'])) # process the body parameter @@ -1164,7 +1164,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -1175,10 +1175,10 @@ class PetApi: # process the form parameters _form_params = [] _files = {} - if _params['additional_metadata']: + if _params['additional_metadata'] is not None: _form_params.append(('additionalMetadata', _params['additional_metadata'])) - if _params['file']: + if _params['file'] is not None: _files['file'] = _params['file'] # process the body parameter @@ -1327,7 +1327,7 @@ class PetApi: # process the path parameters _path_params = {} - if _params['pet_id']: + if _params['pet_id'] is not None: _path_params['petId'] = _params['pet_id'] @@ -1338,10 +1338,10 @@ class PetApi: # process the form parameters _form_params = [] _files = {} - if _params['additional_metadata']: + if _params['additional_metadata'] is not None: _form_params.append(('additionalMetadata', _params['additional_metadata'])) - if _params['required_file']: + if _params['required_file'] is not None: _files['requiredFile'] = _params['required_file'] # process the body parameter diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index b5b845531fe6..ad1fc048da50 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -144,7 +144,7 @@ class StoreApi: # process the path parameters _path_params = {} - if _params['order_id']: + if _params['order_id'] is not None: _path_params['order_id'] = _params['order_id'] @@ -410,7 +410,7 @@ class StoreApi: # process the path parameters _path_params = {} - if _params['order_id']: + if _params['order_id'] is not None: _path_params['order_id'] = _params['order_id'] diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index 240a692ebcad..41ccd5601535 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -580,7 +580,7 @@ class UserApi: # process the path parameters _path_params = {} - if _params['username']: + if _params['username'] is not None: _path_params['username'] = _params['username'] @@ -714,7 +714,7 @@ class UserApi: # process the path parameters _path_params = {} - if _params['username']: + if _params['username'] is not None: _path_params['username'] = _params['username'] @@ -1136,7 +1136,7 @@ class UserApi: # process the path parameters _path_params = {} - if _params['username']: + if _params['username'] is not None: _path_params['username'] = _params['username']