Adds exceptions module to python clients (#2393)

* Adds python client exceptions module and updates samples

* Adds python style updates, detects integers in exception paths with six

* Updates to ruby samples which circleci needs

* Removes petstore-security-tests samples

* readme char removal (triggers ci tests)

* Readme fix, triggers CI tests

* Updates python client sample
This commit is contained in:
Justin Black
2019-03-21 19:40:32 -07:00
committed by William Cheng
parent 45ad72b032
commit b1955f3517
47 changed files with 655 additions and 707 deletions

View File

@@ -27,6 +27,11 @@ from petstore_api.api.user_api import UserApi
# import ApiClient
from petstore_api.api_client import ApiClient
from petstore_api.configuration import Configuration
from petstore_api.exceptions import OpenApiException
from petstore_api.exceptions import ApiTypeError
from petstore_api.exceptions import ApiValueError
from petstore_api.exceptions import ApiKeyError
from petstore_api.exceptions import ApiException
# import models into sdk package
from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType
from petstore_api.models.additional_properties_array import AdditionalPropertiesArray
@@ -72,3 +77,4 @@ from petstore_api.models.type_holder_default import TypeHolderDefault
from petstore_api.models.type_holder_example import TypeHolderExample
from petstore_api.models.user import User
from petstore_api.models.xml_item import XmlItem

View File

@@ -18,6 +18,10 @@ import re # noqa: F401
import six
from petstore_api.api_client import ApiClient
from petstore_api.exceptions import (
ApiTypeError,
ApiValueError
)
class AnotherFakeApi(object):
@@ -80,7 +84,7 @@ class AnotherFakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method call_123_test_special_tags" % key
)
@@ -89,7 +93,7 @@ class AnotherFakeApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `call_123_test_special_tags`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `call_123_test_special_tags`") # noqa: E501
collection_formats = {}

View File

@@ -18,6 +18,10 @@ import re # noqa: F401
import six
from petstore_api.api_client import ApiClient
from petstore_api.exceptions import (
ApiTypeError,
ApiValueError
)
class FakeApi(object):
@@ -80,7 +84,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method create_xml_item" % key
)
@@ -89,7 +93,7 @@ class FakeApi(object):
# verify the required parameter 'xml_item' is set
if ('xml_item' not in local_var_params or
local_var_params['xml_item'] is None):
raise ValueError("Missing the required parameter `xml_item` when calling `create_xml_item`") # noqa: E501
raise ApiValueError("Missing the required parameter `xml_item` when calling `create_xml_item`") # noqa: E501
collection_formats = {}
@@ -176,7 +180,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method fake_outer_boolean_serialize" % key
)
@@ -268,7 +272,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method fake_outer_composite_serialize" % key
)
@@ -360,7 +364,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method fake_outer_number_serialize" % key
)
@@ -452,7 +456,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method fake_outer_string_serialize" % key
)
@@ -544,7 +548,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_body_with_file_schema" % key
)
@@ -553,7 +557,7 @@ class FakeApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_body_with_file_schema`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `test_body_with_file_schema`") # noqa: E501
collection_formats = {}
@@ -640,7 +644,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_body_with_query_params" % key
)
@@ -649,11 +653,11 @@ class FakeApi(object):
# verify the required parameter 'query' is set
if ('query' not in local_var_params or
local_var_params['query'] is None):
raise ValueError("Missing the required parameter `query` when calling `test_body_with_query_params`") # noqa: E501
raise ApiValueError("Missing the required parameter `query` when calling `test_body_with_query_params`") # noqa: E501
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_body_with_query_params`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `test_body_with_query_params`") # noqa: E501
collection_formats = {}
@@ -742,7 +746,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_client_model" % key
)
@@ -751,7 +755,7 @@ class FakeApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_client_model`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `test_client_model`") # noqa: E501
collection_formats = {}
@@ -868,7 +872,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_endpoint_parameters" % key
)
@@ -877,48 +881,48 @@ class FakeApi(object):
# verify the required parameter 'number' is set
if ('number' not in local_var_params or
local_var_params['number'] is None):
raise ValueError("Missing the required parameter `number` when calling `test_endpoint_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `number` when calling `test_endpoint_parameters`") # noqa: E501
# verify the required parameter 'double' is set
if ('double' not in local_var_params or
local_var_params['double'] is None):
raise ValueError("Missing the required parameter `double` when calling `test_endpoint_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `double` when calling `test_endpoint_parameters`") # noqa: E501
# verify the required parameter 'pattern_without_delimiter' is set
if ('pattern_without_delimiter' not in local_var_params or
local_var_params['pattern_without_delimiter'] is None):
raise ValueError("Missing the required parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`") # noqa: E501
# verify the required parameter 'byte' is set
if ('byte' not in local_var_params or
local_var_params['byte'] is None):
raise ValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`") # noqa: E501
if 'number' in local_var_params and local_var_params['number'] > 543.2: # noqa: E501
raise ValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value less than or equal to `543.2`") # noqa: E501
raise ApiValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value less than or equal to `543.2`") # noqa: E501
if 'number' in local_var_params and local_var_params['number'] < 32.1: # noqa: E501
raise ValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value greater than or equal to `32.1`") # noqa: E501
raise ApiValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value greater than or equal to `32.1`") # noqa: E501
if 'double' in local_var_params and local_var_params['double'] > 123.4: # noqa: E501
raise ValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value less than or equal to `123.4`") # noqa: E501
raise ApiValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value less than or equal to `123.4`") # noqa: E501
if 'double' in local_var_params and local_var_params['double'] < 67.8: # noqa: E501
raise ValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value greater than or equal to `67.8`") # noqa: E501
raise ApiValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value greater than or equal to `67.8`") # noqa: E501
if 'pattern_without_delimiter' in local_var_params and not re.search(r'^[A-Z].*', local_var_params['pattern_without_delimiter']): # noqa: E501
raise ValueError("Invalid value for parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`, must conform to the pattern `/^[A-Z].*/`") # noqa: E501
raise ApiValueError("Invalid value for parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`, must conform to the pattern `/^[A-Z].*/`") # noqa: E501
if 'integer' in local_var_params and local_var_params['integer'] > 100: # noqa: E501
raise ValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value less than or equal to `100`") # noqa: E501
raise ApiValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value less than or equal to `100`") # noqa: E501
if 'integer' in local_var_params and local_var_params['integer'] < 10: # noqa: E501
raise ValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value greater than or equal to `10`") # noqa: E501
raise ApiValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value greater than or equal to `10`") # noqa: E501
if 'int32' in local_var_params and local_var_params['int32'] > 200: # noqa: E501
raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value less than or equal to `200`") # noqa: E501
raise ApiValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value less than or equal to `200`") # noqa: E501
if 'int32' in local_var_params and local_var_params['int32'] < 20: # noqa: E501
raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value greater than or equal to `20`") # noqa: E501
raise ApiValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value greater than or equal to `20`") # noqa: E501
if 'float' in local_var_params and local_var_params['float'] > 987.6: # noqa: E501
raise ValueError("Invalid value for parameter `float` when calling `test_endpoint_parameters`, must be a value less than or equal to `987.6`") # noqa: E501
raise ApiValueError("Invalid value for parameter `float` when calling `test_endpoint_parameters`, must be a value less than or equal to `987.6`") # noqa: E501
if 'string' in local_var_params and not re.search(r'[a-z]', local_var_params['string'], flags=re.IGNORECASE): # noqa: E501
raise ValueError("Invalid value for parameter `string` when calling `test_endpoint_parameters`, must conform to the pattern `/[a-z]/i`") # noqa: E501
raise ApiValueError("Invalid value for parameter `string` when calling `test_endpoint_parameters`, must conform to the pattern `/[a-z]/i`") # noqa: E501
if ('password' in local_var_params and
len(local_var_params['password']) > 64):
raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be less than or equal to `64`") # noqa: E501
raise ApiValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be less than or equal to `64`") # noqa: E501
if ('password' in local_var_params and
len(local_var_params['password']) < 10):
raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be greater than or equal to `10`") # noqa: E501
raise ApiValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be greater than or equal to `10`") # noqa: E501
collection_formats = {}
path_params = {}
@@ -1044,7 +1048,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_enum_parameters" % key
)
@@ -1163,7 +1167,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_group_parameters" % key
)
@@ -1172,15 +1176,15 @@ class FakeApi(object):
# verify the required parameter 'required_string_group' is set
if ('required_string_group' not in local_var_params or
local_var_params['required_string_group'] is None):
raise ValueError("Missing the required parameter `required_string_group` when calling `test_group_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `required_string_group` when calling `test_group_parameters`") # noqa: E501
# verify the required parameter 'required_boolean_group' is set
if ('required_boolean_group' not in local_var_params or
local_var_params['required_boolean_group'] is None):
raise ValueError("Missing the required parameter `required_boolean_group` when calling `test_group_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `required_boolean_group` when calling `test_group_parameters`") # noqa: E501
# verify the required parameter 'required_int64_group' is set
if ('required_int64_group' not in local_var_params or
local_var_params['required_int64_group'] is None):
raise ValueError("Missing the required parameter `required_int64_group` when calling `test_group_parameters`") # noqa: E501
raise ApiValueError("Missing the required parameter `required_int64_group` when calling `test_group_parameters`") # noqa: E501
collection_formats = {}
@@ -1271,7 +1275,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_inline_additional_properties" % key
)
@@ -1280,7 +1284,7 @@ class FakeApi(object):
# verify the required parameter 'param' is set
if ('param' not in local_var_params or
local_var_params['param'] is None):
raise ValueError("Missing the required parameter `param` when calling `test_inline_additional_properties`") # noqa: E501
raise ApiValueError("Missing the required parameter `param` when calling `test_inline_additional_properties`") # noqa: E501
collection_formats = {}
@@ -1367,7 +1371,7 @@ class FakeApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_json_form_data" % key
)
@@ -1376,11 +1380,11 @@ class FakeApi(object):
# verify the required parameter 'param' is set
if ('param' not in local_var_params or
local_var_params['param'] is None):
raise ValueError("Missing the required parameter `param` when calling `test_json_form_data`") # noqa: E501
raise ApiValueError("Missing the required parameter `param` when calling `test_json_form_data`") # noqa: E501
# verify the required parameter 'param2' is set
if ('param2' not in local_var_params or
local_var_params['param2'] is None):
raise ValueError("Missing the required parameter `param2` when calling `test_json_form_data`") # noqa: E501
raise ApiValueError("Missing the required parameter `param2` when calling `test_json_form_data`") # noqa: E501
collection_formats = {}

View File

@@ -18,6 +18,10 @@ import re # noqa: F401
import six
from petstore_api.api_client import ApiClient
from petstore_api.exceptions import (
ApiTypeError,
ApiValueError
)
class FakeClassnameTags123Api(object):
@@ -80,7 +84,7 @@ class FakeClassnameTags123Api(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_classname" % key
)
@@ -89,7 +93,7 @@ class FakeClassnameTags123Api(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `test_classname`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `test_classname`") # noqa: E501
collection_formats = {}

View File

@@ -18,6 +18,10 @@ import re # noqa: F401
import six
from petstore_api.api_client import ApiClient
from petstore_api.exceptions import (
ApiTypeError,
ApiValueError
)
class PetApi(object):
@@ -78,7 +82,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method add_pet" % key
)
@@ -87,7 +91,7 @@ class PetApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `add_pet`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `add_pet`") # noqa: E501
collection_formats = {}
@@ -174,7 +178,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method delete_pet" % key
)
@@ -183,7 +187,7 @@ class PetApi(object):
# verify the required parameter 'pet_id' is set
if ('pet_id' not in local_var_params or
local_var_params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") # noqa: E501
raise ApiValueError("Missing the required parameter `pet_id` when calling `delete_pet`") # noqa: E501
collection_formats = {}
@@ -268,7 +272,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method find_pets_by_status" % key
)
@@ -277,7 +281,7 @@ class PetApi(object):
# verify the required parameter 'status' is set
if ('status' not in local_var_params or
local_var_params['status'] is None):
raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`") # noqa: E501
raise ApiValueError("Missing the required parameter `status` when calling `find_pets_by_status`") # noqa: E501
collection_formats = {}
@@ -365,7 +369,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method find_pets_by_tags" % key
)
@@ -374,7 +378,7 @@ class PetApi(object):
# verify the required parameter 'tags' is set
if ('tags' not in local_var_params or
local_var_params['tags'] is None):
raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`") # noqa: E501
raise ApiValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`") # noqa: E501
collection_formats = {}
@@ -462,7 +466,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_pet_by_id" % key
)
@@ -471,7 +475,7 @@ class PetApi(object):
# verify the required parameter 'pet_id' is set
if ('pet_id' not in local_var_params or
local_var_params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") # noqa: E501
raise ApiValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") # noqa: E501
collection_formats = {}
@@ -556,7 +560,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method update_pet" % key
)
@@ -565,7 +569,7 @@ class PetApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `update_pet`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `update_pet`") # noqa: E501
collection_formats = {}
@@ -654,7 +658,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method update_pet_with_form" % key
)
@@ -663,7 +667,7 @@ class PetApi(object):
# verify the required parameter 'pet_id' is set
if ('pet_id' not in local_var_params or
local_var_params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") # noqa: E501
raise ApiValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") # noqa: E501
collection_formats = {}
@@ -756,7 +760,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method upload_file" % key
)
@@ -765,7 +769,7 @@ class PetApi(object):
# verify the required parameter 'pet_id' is set
if ('pet_id' not in local_var_params or
local_var_params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") # noqa: E501
raise ApiValueError("Missing the required parameter `pet_id` when calling `upload_file`") # noqa: E501
collection_formats = {}
@@ -862,7 +866,7 @@ class PetApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method upload_file_with_required_file" % key
)
@@ -871,11 +875,11 @@ class PetApi(object):
# verify the required parameter 'pet_id' is set
if ('pet_id' not in local_var_params or
local_var_params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file_with_required_file`") # noqa: E501
raise ApiValueError("Missing the required parameter `pet_id` when calling `upload_file_with_required_file`") # noqa: E501
# verify the required parameter 'required_file' is set
if ('required_file' not in local_var_params or
local_var_params['required_file'] is None):
raise ValueError("Missing the required parameter `required_file` when calling `upload_file_with_required_file`") # noqa: E501
raise ApiValueError("Missing the required parameter `required_file` when calling `upload_file_with_required_file`") # noqa: E501
collection_formats = {}

View File

@@ -18,6 +18,10 @@ import re # noqa: F401
import six
from petstore_api.api_client import ApiClient
from petstore_api.exceptions import (
ApiTypeError,
ApiValueError
)
class StoreApi(object):
@@ -80,7 +84,7 @@ class StoreApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method delete_order" % key
)
@@ -89,7 +93,7 @@ class StoreApi(object):
# verify the required parameter 'order_id' is set
if ('order_id' not in local_var_params or
local_var_params['order_id'] is None):
raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") # noqa: E501
raise ApiValueError("Missing the required parameter `order_id` when calling `delete_order`") # noqa: E501
collection_formats = {}
@@ -170,7 +174,7 @@ class StoreApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_inventory" % key
)
@@ -260,7 +264,7 @@ class StoreApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_order_by_id" % key
)
@@ -269,12 +273,12 @@ class StoreApi(object):
# verify the required parameter 'order_id' is set
if ('order_id' not in local_var_params or
local_var_params['order_id'] is None):
raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") # noqa: E501
raise ApiValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") # noqa: E501
if 'order_id' in local_var_params and local_var_params['order_id'] > 5: # noqa: E501
raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5`") # noqa: E501
raise ApiValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5`") # noqa: E501
if 'order_id' in local_var_params and local_var_params['order_id'] < 1: # noqa: E501
raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1`") # noqa: E501
raise ApiValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1`") # noqa: E501
collection_formats = {}
path_params = {}
@@ -358,7 +362,7 @@ class StoreApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method place_order" % key
)
@@ -367,7 +371,7 @@ class StoreApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `place_order`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `place_order`") # noqa: E501
collection_formats = {}

View File

@@ -18,6 +18,10 @@ import re # noqa: F401
import six
from petstore_api.api_client import ApiClient
from petstore_api.exceptions import (
ApiTypeError,
ApiValueError
)
class UserApi(object):
@@ -80,7 +84,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method create_user" % key
)
@@ -89,7 +93,7 @@ class UserApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_user`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `create_user`") # noqa: E501
collection_formats = {}
@@ -170,7 +174,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method create_users_with_array_input" % key
)
@@ -179,7 +183,7 @@ class UserApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `create_users_with_array_input`") # noqa: E501
collection_formats = {}
@@ -260,7 +264,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method create_users_with_list_input" % key
)
@@ -269,7 +273,7 @@ class UserApi(object):
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `create_users_with_list_input`") # noqa: E501
collection_formats = {}
@@ -352,7 +356,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method delete_user" % key
)
@@ -361,7 +365,7 @@ class UserApi(object):
# verify the required parameter 'username' is set
if ('username' not in local_var_params or
local_var_params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `delete_user`") # noqa: E501
raise ApiValueError("Missing the required parameter `username` when calling `delete_user`") # noqa: E501
collection_formats = {}
@@ -442,7 +446,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_user_by_name" % key
)
@@ -451,7 +455,7 @@ class UserApi(object):
# verify the required parameter 'username' is set
if ('username' not in local_var_params or
local_var_params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") # noqa: E501
raise ApiValueError("Missing the required parameter `username` when calling `get_user_by_name`") # noqa: E501
collection_formats = {}
@@ -538,7 +542,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method login_user" % key
)
@@ -547,11 +551,11 @@ class UserApi(object):
# verify the required parameter 'username' is set
if ('username' not in local_var_params or
local_var_params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `login_user`") # noqa: E501
raise ApiValueError("Missing the required parameter `username` when calling `login_user`") # noqa: E501
# verify the required parameter 'password' is set
if ('password' not in local_var_params or
local_var_params['password'] is None):
raise ValueError("Missing the required parameter `password` when calling `login_user`") # noqa: E501
raise ApiValueError("Missing the required parameter `password` when calling `login_user`") # noqa: E501
collection_formats = {}
@@ -636,7 +640,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method logout_user" % key
)
@@ -724,7 +728,7 @@ class UserApi(object):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method update_user" % key
)
@@ -733,11 +737,11 @@ class UserApi(object):
# verify the required parameter 'username' is set
if ('username' not in local_var_params or
local_var_params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `update_user`") # noqa: E501
raise ApiValueError("Missing the required parameter `username` when calling `update_user`") # noqa: E501
# verify the required parameter 'body' is set
if ('body' not in local_var_params or
local_var_params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `update_user`") # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `update_user`") # noqa: E501
collection_formats = {}

View File

@@ -25,6 +25,7 @@ from six.moves.urllib.parse import quote
from petstore_api.configuration import Configuration
import petstore_api.models
from petstore_api import rest
from petstore_api.exceptions import ApiValueError
class ApiClient(object):
@@ -406,7 +407,7 @@ class ApiClient(object):
_request_timeout=_request_timeout,
body=body)
else:
raise ValueError(
raise ApiValueError(
"http method must be `GET`, `HEAD`, `OPTIONS`,"
" `POST`, `PATCH`, `PUT` or `DELETE`."
)
@@ -523,7 +524,7 @@ class ApiClient(object):
elif auth_setting['in'] == 'query':
querys.append((auth_setting['key'], auth_setting['value']))
else:
raise ValueError(
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)

View File

@@ -22,6 +22,8 @@ import asyncio
# python 2 and python 3 compatibility library
from six.moves.urllib.parse import urlencode
from petstore_api.exceptions import ApiException, ApiValueError
logger = logging.getLogger(__name__)
@@ -108,7 +110,7 @@ class RESTClientObject(object):
'PATCH', 'OPTIONS']
if post_params and body:
raise ValueError(
raise ApiValueError(
"body parameter cannot be used with post_params parameter."
)
@@ -246,30 +248,3 @@ class RESTClientObject(object):
_preload_content=_preload_content,
_request_timeout=_request_timeout,
body=body))
class ApiException(Exception):
def __init__(self, status=None, reason=None, http_resp=None):
if http_resp:
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data
self.headers = http_resp.getheaders()
else:
self.status = status
self.reason = reason
self.body = None
self.headers = None
def __str__(self):
"""Custom error messages for exception"""
error_message = "({0})\nReason: {1}\n".format(self.status, self.reason)
if self.headers:
error_message += "HTTP response headers: {0}\n".format(
self.headers)
if self.body:
error_message += "HTTP response body: {0}\n".format(self.body)
return error_message