diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 9811288e92..31d88380c9 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -16,10 +16,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. """ + from __future__ import absolute_import import sys @@ -34,6 +32,10 @@ from ..api_client import ApiClient {{#operations}} class {{classname}}(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ def __init__(self, api_client=None): config = Configuration() diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 637bba9d76..409a737974 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -1,10 +1,21 @@ #!/usr/bin/env python # coding: utf-8 -"""Swagger generic API client. This client handles the client- -server communication, and is invariant across implementations. Specifics of -the methods and models for each application are generated from the Swagger -templates.""" +""" +Copyright 2015 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from __future__ import absolute_import from . import models @@ -38,15 +49,27 @@ from .configuration import Configuration class ApiClient(object): """ - Generic API client for Swagger client library builds + Generic API client for Swagger client library builds. - :param host: The base path for the server to call - :param header_name: a header to pass when making calls to the API - :param header_value: a header value to pass when making calls to the API + Swagger generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the Swagger + templates. + + NOTE: This class is auto generated by the swagger code generator program. + https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + + :param host: The base path for the server to call. + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to the API. """ def __init__(self, host=Configuration().host, header_name=None, header_value=None, cookie=None): + """ + Constructor of the class. + """ self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value @@ -57,10 +80,16 @@ class ApiClient(object): @property def user_agent(self): + """ + Gets user agent. + """ return self.default_headers['User-Agent'] @user_agent.setter def user_agent(self, value): + """ + Sets user agent. + """ self.default_headers['User-Agent'] = value def set_default_header(self, header_name, header_value): @@ -129,11 +158,12 @@ class ApiClient(object): def to_path_value(self, obj): """ - Convert a string or object to a path-friendly value + Takes value and turn it into a string suitable for inclusion in + the path, by url-encoding. - :param obj: object or string value + :param obj: object or string value. - :return string: quoted value + :return string: quoted value. """ if type(obj) == list: return ','.join(obj) @@ -142,7 +172,7 @@ class ApiClient(object): def sanitize_for_serialization(self, obj): """ - Sanitize an object for Request. + Builds a JSON POST object. If obj is None, return None. If obj is str, int, float, bool, return directly. @@ -151,6 +181,9 @@ class ApiClient(object): If obj is list, santize each element in the list. If obj is dict, return the dict. If obj is swagger model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. """ if isinstance(obj, type(None)): return None @@ -181,13 +214,13 @@ class ApiClient(object): def deserialize(self, response, response_type): """ - Derialize response into an object. + Deserializes response into an object. - :param response: RESTResponse object to be deserialized + :param response: RESTResponse object to be deserialized. :param response_type: class literal for - deserialzied object, or string of class name + deserialzied object, or string of class name. - :return: deserialized object + :return: deserialized object. """ # handle file downloading # save response body into a tmp file and return the instance @@ -204,10 +237,12 @@ class ApiClient(object): def __deserialize(self, data, klass): """ - :param data: dict, list or str - :param klass: class literal, or string of class name + Deserializes dict, list, str into an object. - :return: object + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. """ if data is None: return None @@ -248,8 +283,7 @@ class ApiClient(object): body=None, post_params=None, files=None, response_type=None, auth_settings=None, callback=None): """ - Perform http request and return deserialized data - + Makes the HTTP request and return the deserialized data. :param resource_path: Path to method endpoint. :param method: Method to call. @@ -293,7 +327,7 @@ class ApiClient(object): def request(self, method, url, query_params=None, headers=None, post_params=None, body=None): """ - Perform http request using RESTClient. + Makes the HTTP request using RESTClient. """ if method == "GET": return RESTClient.GET(url, @@ -329,6 +363,13 @@ class ApiClient(object): ) def prepare_post_parameters(self, post_params=None, files=None): + """ + Builds form parameters. + + :param post_params: Normal form parameters. + :param files: File parameters. + :return: Form parameters with files. + """ params = {} if post_params: @@ -350,7 +391,10 @@ class ApiClient(object): def select_header_accept(self, accepts): """ - Return `Accept` based on an array of accepts provided + Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). """ if not accepts: return @@ -364,7 +408,10 @@ class ApiClient(object): def select_header_content_type(self, content_types): """ - Return `Content-Type` baseed on an array of content_types provided + Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). """ if not content_types: return 'application/json' @@ -378,7 +425,11 @@ class ApiClient(object): def update_params_for_auth(self, headers, querys, auth_settings): """ - Update header and query params based on authentication setting + Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters dict to be updated. + :param auth_settings: Authentication setting identifiers list. """ config = Configuration() @@ -399,12 +450,12 @@ class ApiClient(object): def __deserialize_file(self, response): """ - Save response body into a file in (the defined) temporary folder, + Saves response body into a file in (the defined) temporary folder, using the filename from the `Content-Disposition` header if provided, otherwise a random filename. - :param response: RESTResponse - :return: file path + :param response: RESTResponse. + :return: file path. """ config = Configuration() @@ -426,12 +477,12 @@ class ApiClient(object): def __deserialize_primitive(self, data, klass): """ - Deserialize string to primitive type + Deserializes string to primitive type. - :param data: str - :param klass: class literal + :param data: str. + :param klass: class literal. - :return: int, float, str, bool + :return: int, float, str, bool. """ try: value = klass(data) @@ -443,16 +494,18 @@ class ApiClient(object): def __deserialize_object(self): """ - Deserialize empty object + Deserializes empty object. + + :return: object. """ return object() def __deserialize_date(self, string): """ - Deserialize string to date + Deserializes string to date. - :param string: str - :return: date + :param string: str. + :return: date. """ try: from dateutil.parser import parse @@ -468,12 +521,12 @@ class ApiClient(object): def __deserialize_datatime(self, string): """ - Deserialize string to datetime. + Deserializes string to datetime. The string should be in iso8601 datetime format. - :param string: str - :return: datetime + :param string: str. + :return: datetime. """ try: from dateutil.parser import parse @@ -489,10 +542,11 @@ class ApiClient(object): def __deserialize_model(self, data, klass): """ - Deserialize list or dict to model + Deserializes list or dict to model. - :param data: dict, list - :param klass: class literal + :param data: dict, list. + :param klass: class literal. + :return: model object. """ instance = klass() diff --git a/modules/swagger-codegen/src/main/resources/python/configuration.mustache b/modules/swagger-codegen/src/main/resources/python/configuration.mustache index bf26ab362b..b732224b21 100644 --- a/modules/swagger-codegen/src/main/resources/python/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/python/configuration.mustache @@ -1,3 +1,21 @@ +# coding: utf-8 + +""" +Copyright 2015 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" + from __future__ import absolute_import import base64 import urllib3 @@ -18,26 +36,45 @@ def singleton(cls, *args, **kw): @singleton class Configuration(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + """ def __init__(self): + """ + Constructor + """ # Default Base url self.host = "{{basePath}}" # Default api client self.api_client = None - # Temp file folder + # Temp file folder for download self.temp_folder_path = None + # Authentication Settings + # dict to store API key(s) self.api_key = {} + # dict to store API prefix (e.g. Bearer) self.api_key_prefix = {} + # Username for HTTP basic authentication self.username = "" + # Password for HTTP basic authentication self.password = "" + # Logging Settings self.logging_format = '%(asctime)s %(levelname)s %(message)s' + # Debug file location self.__logging_file = None + # Debug switch self.__debug = False self.init_logger() def init_logger(self): + """ + Initializes logger settings. + """ self.logger = logging.getLogger() formatter = logging.Formatter(self.logging_format) stream_handler = logging.StreamHandler() @@ -83,19 +120,32 @@ class Configuration(object): self.logger.setLevel(logging.WARNING) def get_api_key_with_prefix(self, key): - """ Return api key prepend prefix for key """ + """ + Gets API key (with prefix if set). + + :param key: Name of apiKey. + :return: The token for api key authentication. + """ if self.api_key.get(key) and self.api_key_prefix.get(key): return self.api_key_prefix[key] + ' ' + self.api_key[key] elif self.api_key.get(key): return self.api_key[key] def get_basic_auth_token(self): - """ Return basic auth header string """ + """ + Gets basic auth header string. + + :return: The token for basic HTTP authentication. + """ return urllib3.util.make_headers(basic_auth=self.username + ':' + self.password)\ .get('authorization') def auth_settings(self): - """ Return Auth Settings for api client """ + """ + Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ return { {{#authMethods}} {{#isApiKey}} @@ -120,6 +170,11 @@ class Configuration(object): } def to_debug_report(self): + """ + Gets the essential information for debugging. + + :return: The report for debugging. + """ return "Python SDK Debug Report:\n"\ "OS: {env}\n"\ "Python Version: {pyversion}\n"\ diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index 7314e9ee9c..074a66395f 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -16,6 +16,7 @@ Copyright 2015 SmartBear Software See the License for the specific language governing permissions and limitations under the License. """ + {{#models}} {{#model}} from pprint import pformat diff --git a/modules/swagger-codegen/src/main/resources/python/rest.mustache b/modules/swagger-codegen/src/main/resources/python/rest.mustache index fab813a4cc..f6161a6d60 100644 --- a/modules/swagger-codegen/src/main/resources/python/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/rest.mustache @@ -1,6 +1,20 @@ # coding: utf-8 """ +Copyright 2015 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + Credit: this file (rest.py) is modified based on rest.py in Dropbox Python SDK: https://www.dropbox.com/developers/core/sdks/python """ diff --git a/modules/swagger-codegen/src/main/resources/python/setup.mustache b/modules/swagger-codegen/src/main/resources/python/setup.mustache index 9c19e413e9..f3122f9f39 100644 --- a/modules/swagger-codegen/src/main/resources/python/setup.mustache +++ b/modules/swagger-codegen/src/main/resources/python/setup.mustache @@ -34,11 +34,3 @@ setup( ) {{/hasMore}}{{/apis}}{{/apiInfo}} - - - - - - - - diff --git a/samples/client/petstore/python/setup.py b/samples/client/petstore/python/setup.py index ffc6f6a3ad..2b50c5c4cf 100644 --- a/samples/client/petstore/python/setup.py +++ b/samples/client/petstore/python/setup.py @@ -33,11 +33,3 @@ setup( ) - - - - - - - - diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index 37bf1be69c..9a1f6c6da7 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -1,10 +1,21 @@ #!/usr/bin/env python # coding: utf-8 -"""Swagger generic API client. This client handles the client- -server communication, and is invariant across implementations. Specifics of -the methods and models for each application are generated from the Swagger -templates.""" +""" +Copyright 2015 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" from __future__ import absolute_import from . import models @@ -38,15 +49,26 @@ from .configuration import Configuration class ApiClient(object): """ - Generic API client for Swagger client library builds + Generic API client for Swagger client library builds. - :param host: The base path for the server to call - :param header_name: a header to pass when making calls to the API - :param header_value: a header value to pass when making calls to the API + Swagger generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the Swagger + templates. + + NOTE: This class is auto generated by the swagger code generator program. + https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + + :param host: The base path for the server to call. + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to the API. """ def __init__(self, host=Configuration().host, header_name=None, header_value=None): - + """ + Constructor of the class. + """ self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value @@ -57,10 +79,16 @@ class ApiClient(object): @property def user_agent(self): + """ + Gets user agent. + """ return self.default_headers['User-Agent'] @user_agent.setter def user_agent(self, value): + """ + Sets user agent. + """ self.default_headers['User-Agent'] = value def set_default_header(self, header_name, header_value): @@ -129,11 +157,12 @@ class ApiClient(object): def to_path_value(self, obj): """ - Convert a string or object to a path-friendly value + Takes value and turn it into a string suitable for inclusion in + the path, by url-encoding. - :param obj: object or string value + :param obj: object or string value. - :return string: quoted value + :return string: quoted value. """ if type(obj) == list: return ','.join(obj) @@ -142,7 +171,7 @@ class ApiClient(object): def sanitize_for_serialization(self, obj): """ - Sanitize an object for Request. + Builds a JSON POST object. If obj is None, return None. If obj is str, int, float, bool, return directly. @@ -151,6 +180,9 @@ class ApiClient(object): If obj is list, santize each element in the list. If obj is dict, return the dict. If obj is swagger model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. """ if isinstance(obj, type(None)): return None @@ -181,13 +213,13 @@ class ApiClient(object): def deserialize(self, response, response_type): """ - Derialize response into an object. + Deserializes response into an object. - :param response: RESTResponse object to be deserialized + :param response: RESTResponse object to be deserialized. :param response_type: class literal for - deserialzied object, or string of class name + deserialzied object, or string of class name. - :return: deserialized object + :return: deserialized object. """ # handle file downloading # save response body into a tmp file and return the instance @@ -204,10 +236,12 @@ class ApiClient(object): def __deserialize(self, data, klass): """ - :param data: dict, list or str - :param klass: class literal, or string of class name + Deserializes dict, list, str into an object. - :return: object + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. """ if data is None: return None @@ -248,8 +282,7 @@ class ApiClient(object): body=None, post_params=None, files=None, response_type=None, auth_settings=None, callback=None): """ - Perform http request and return deserialized data - + Makes the HTTP request and return the deserialized data. :param resource_path: Path to method endpoint. :param method: Method to call. @@ -293,7 +326,7 @@ class ApiClient(object): def request(self, method, url, query_params=None, headers=None, post_params=None, body=None): """ - Perform http request using RESTClient. + Makes the HTTP request using RESTClient. """ if method == "GET": return RESTClient.GET(url, @@ -329,6 +362,13 @@ class ApiClient(object): ) def prepare_post_parameters(self, post_params=None, files=None): + """ + Builds form parameters. + + :param post_params: Normal form parameters. + :param files: File parameters. + :return: Form parameters with files. + """ params = {} if post_params: @@ -350,7 +390,10 @@ class ApiClient(object): def select_header_accept(self, accepts): """ - Return `Accept` based on an array of accepts provided + Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). """ if not accepts: return @@ -364,7 +407,10 @@ class ApiClient(object): def select_header_content_type(self, content_types): """ - Return `Content-Type` baseed on an array of content_types provided + Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). """ if not content_types: return 'application/json' @@ -378,7 +424,11 @@ class ApiClient(object): def update_params_for_auth(self, headers, querys, auth_settings): """ - Update header and query params based on authentication setting + Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters dict to be updated. + :param auth_settings: Authentication setting identifiers list. """ config = Configuration() @@ -399,12 +449,12 @@ class ApiClient(object): def __deserialize_file(self, response): """ - Save response body into a file in (the defined) temporary folder, + Saves response body into a file in (the defined) temporary folder, using the filename from the `Content-Disposition` header if provided, otherwise a random filename. - :param response: RESTResponse - :return: file path + :param response: RESTResponse. + :return: file path. """ config = Configuration() @@ -426,12 +476,12 @@ class ApiClient(object): def __deserialize_primitive(self, data, klass): """ - Deserialize string to primitive type + Deserializes string to primitive type. - :param data: str - :param klass: class literal + :param data: str. + :param klass: class literal. - :return: int, float, str, bool + :return: int, float, str, bool. """ try: value = klass(data) @@ -443,16 +493,18 @@ class ApiClient(object): def __deserialize_object(self): """ - Deserialize empty object + Deserializes empty object. + + :return: object. """ return object() def __deserialize_date(self, string): """ - Deserialize string to date + Deserializes string to date. - :param string: str - :return: date + :param string: str. + :return: date. """ try: from dateutil.parser import parse @@ -468,12 +520,12 @@ class ApiClient(object): def __deserialize_datatime(self, string): """ - Deserialize string to datetime. + Deserializes string to datetime. The string should be in iso8601 datetime format. - :param string: str - :return: datetime + :param string: str. + :return: datetime. """ try: from dateutil.parser import parse @@ -489,10 +541,11 @@ class ApiClient(object): def __deserialize_model(self, data, klass): """ - Deserialize list or dict to model + Deserializes list or dict to model. - :param data: dict, list - :param klass: class literal + :param data: dict, list. + :param klass: class literal. + :return: model object. """ instance = klass() diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 3f3e523a15..3c80becf7d 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -16,10 +16,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. """ + from __future__ import absolute_import import sys @@ -33,6 +31,10 @@ from ..api_client import ApiClient class PetApi(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ def __init__(self, api_client=None): config = Configuration() diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index ac465f792e..8e46f78619 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -16,10 +16,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. """ + from __future__ import absolute_import import sys @@ -33,6 +31,10 @@ from ..api_client import ApiClient class StoreApi(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ def __init__(self, api_client=None): config = Configuration() diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index 0469e83ae2..83158956c3 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -16,10 +16,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - -NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. """ + from __future__ import absolute_import import sys @@ -33,6 +31,10 @@ from ..api_client import ApiClient class UserApi(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ def __init__(self, api_client=None): config = Configuration() diff --git a/samples/client/petstore/python/swagger_client/configuration.py b/samples/client/petstore/python/swagger_client/configuration.py index 0fe945bee1..cfe4100e9b 100644 --- a/samples/client/petstore/python/swagger_client/configuration.py +++ b/samples/client/petstore/python/swagger_client/configuration.py @@ -1,3 +1,21 @@ +# coding: utf-8 + +""" +Copyright 2015 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" + from __future__ import absolute_import import base64 import urllib3 @@ -18,26 +36,45 @@ def singleton(cls, *args, **kw): @singleton class Configuration(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + https://github.com/swagger-api/swagger-codegen + Do not edit the class manually. + """ def __init__(self): + """ + Constructor + """ # Default Base url self.host = "http://petstore.swagger.io/v2" # Default api client self.api_client = None - # Temp file folder + # Temp file folder for download self.temp_folder_path = None + # Authentication Settings + # dict to store API key(s) self.api_key = {} + # dict to store API prefix (e.g. Bearer) self.api_key_prefix = {} + # Username for HTTP basic authentication self.username = "" + # Password for HTTP basic authentication self.password = "" + # Logging Settings self.logging_format = '%(asctime)s %(levelname)s %(message)s' + # Debug file location self.__logging_file = None + # Debug switch self.__debug = False self.init_logger() def init_logger(self): + """ + Initializes logger settings. + """ self.logger = logging.getLogger() formatter = logging.Formatter(self.logging_format) stream_handler = logging.StreamHandler() @@ -83,19 +120,32 @@ class Configuration(object): self.logger.setLevel(logging.WARNING) def get_api_key_with_prefix(self, key): - """ Return api key prepend prefix for key """ + """ + Gets API key (with prefix if set). + + :param key: Name of apiKey. + :return: The token for api key authentication. + """ if self.api_key.get(key) and self.api_key_prefix.get(key): return self.api_key_prefix[key] + ' ' + self.api_key[key] elif self.api_key.get(key): return self.api_key[key] def get_basic_auth_token(self): - """ Return basic auth header string """ + """ + Gets basic auth header string. + + :return: The token for basic HTTP authentication. + """ return urllib3.util.make_headers(basic_auth=self.username + ':' + self.password)\ .get('authorization') def auth_settings(self): - """ Return Auth Settings for api client """ + """ + Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ return { 'api_key': { @@ -107,6 +157,11 @@ class Configuration(object): } def to_debug_report(self): + """ + Gets the essential information for debugging. + + :return: The report for debugging. + """ return "Python SDK Debug Report:\n"\ "OS: {env}\n"\ "Python Version: {pyversion}\n"\ diff --git a/samples/client/petstore/python/swagger_client/models/category.py b/samples/client/petstore/python/swagger_client/models/category.py index ae03bb7ec7..65b0ac40f8 100644 --- a/samples/client/petstore/python/swagger_client/models/category.py +++ b/samples/client/petstore/python/swagger_client/models/category.py @@ -16,6 +16,7 @@ Copyright 2015 SmartBear Software See the License for the specific language governing permissions and limitations under the License. """ + from pprint import pformat from six import iteritems diff --git a/samples/client/petstore/python/swagger_client/models/order.py b/samples/client/petstore/python/swagger_client/models/order.py index 7498561372..e6a1147041 100644 --- a/samples/client/petstore/python/swagger_client/models/order.py +++ b/samples/client/petstore/python/swagger_client/models/order.py @@ -16,6 +16,7 @@ Copyright 2015 SmartBear Software See the License for the specific language governing permissions and limitations under the License. """ + from pprint import pformat from six import iteritems diff --git a/samples/client/petstore/python/swagger_client/models/pet.py b/samples/client/petstore/python/swagger_client/models/pet.py index 62f7bea7fd..fe040ec1a4 100644 --- a/samples/client/petstore/python/swagger_client/models/pet.py +++ b/samples/client/petstore/python/swagger_client/models/pet.py @@ -16,6 +16,7 @@ Copyright 2015 SmartBear Software See the License for the specific language governing permissions and limitations under the License. """ + from pprint import pformat from six import iteritems diff --git a/samples/client/petstore/python/swagger_client/models/tag.py b/samples/client/petstore/python/swagger_client/models/tag.py index ea07acacfd..abc35e419c 100644 --- a/samples/client/petstore/python/swagger_client/models/tag.py +++ b/samples/client/petstore/python/swagger_client/models/tag.py @@ -16,6 +16,7 @@ Copyright 2015 SmartBear Software See the License for the specific language governing permissions and limitations under the License. """ + from pprint import pformat from six import iteritems diff --git a/samples/client/petstore/python/swagger_client/models/user.py b/samples/client/petstore/python/swagger_client/models/user.py index d81a73318e..1fd25a1d5a 100644 --- a/samples/client/petstore/python/swagger_client/models/user.py +++ b/samples/client/petstore/python/swagger_client/models/user.py @@ -16,6 +16,7 @@ Copyright 2015 SmartBear Software See the License for the specific language governing permissions and limitations under the License. """ + from pprint import pformat from six import iteritems diff --git a/samples/client/petstore/python/swagger_client/rest.py b/samples/client/petstore/python/swagger_client/rest.py index fab813a4cc..f6161a6d60 100644 --- a/samples/client/petstore/python/swagger_client/rest.py +++ b/samples/client/petstore/python/swagger_client/rest.py @@ -1,6 +1,20 @@ # coding: utf-8 """ +Copyright 2015 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + Credit: this file (rest.py) is modified based on rest.py in Dropbox Python SDK: https://www.dropbox.com/developers/core/sdks/python """