From 64d0c403d074ac5af522d4dff333d9b85c80a931 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 5 Feb 2017 23:51:35 +0800 Subject: [PATCH] [Python] Fix issue with CI due to dependency (#4716) * Issue 4637 Fix for ci build (#4643) * [Python] update python requirement.txt and use single quote for safe characters (#4702) * update python requirement * update petstore sample --- .../resources/python/requirements.mustache | 2 +- samples/client/petstore/python/README.md | 1 + .../petstore/python/docs/Capitalization.md | 15 ++ .../petstore/python/petstore_api/__init__.py | 1 + .../python/petstore_api/api_client.py | 2 +- .../python/petstore_api/apis/store_api.py | 2 - .../python/petstore_api/models/__init__.py | 1 + .../petstore_api/models/capitalization.py | 234 ++++++++++++++++++ .../client/petstore/python/requirements.txt | 2 +- .../python/swagger_client/models/animal.py | 120 --------- .../python/swagger_client/models/cat.py | 145 ----------- .../python/swagger_client/models/dog.py | 145 ----------- .../python/test/test_capitalization.py | 42 ++++ 13 files changed, 297 insertions(+), 415 deletions(-) create mode 100644 samples/client/petstore/python/docs/Capitalization.md create mode 100644 samples/client/petstore/python/petstore_api/models/capitalization.py delete mode 100644 samples/client/petstore/python/swagger_client/models/animal.py delete mode 100644 samples/client/petstore/python/swagger_client/models/cat.py delete mode 100644 samples/client/petstore/python/swagger_client/models/dog.py create mode 100644 samples/client/petstore/python/test/test_capitalization.py diff --git a/modules/swagger-codegen/src/main/resources/python/requirements.mustache b/modules/swagger-codegen/src/main/resources/python/requirements.mustache index f00e08fa339..bafdc07532f 100644 --- a/modules/swagger-codegen/src/main/resources/python/requirements.mustache +++ b/modules/swagger-codegen/src/main/resources/python/requirements.mustache @@ -1,5 +1,5 @@ certifi >= 14.05.14 -six == 1.8.0 +six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.15.1 diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 248a90d45af..6272e435e2c 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -104,6 +104,7 @@ Class | Method | HTTP request | Description - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) + - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [ClassModel](docs/ClassModel.md) diff --git a/samples/client/petstore/python/docs/Capitalization.md b/samples/client/petstore/python/docs/Capitalization.md new file mode 100644 index 00000000000..85d88d239ee --- /dev/null +++ b/samples/client/petstore/python/docs/Capitalization.md @@ -0,0 +1,15 @@ +# Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **str** | | [optional] +**capital_camel** | **str** | | [optional] +**small_snake** | **str** | | [optional] +**capital_snake** | **str** | | [optional] +**sca_eth_flow_points** | **str** | | [optional] +**att_name** | **str** | Name of the pet | [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) + + diff --git a/samples/client/petstore/python/petstore_api/__init__.py b/samples/client/petstore/python/petstore_api/__init__.py index b0a406dde8e..f86e57eaeac 100644 --- a/samples/client/petstore/python/petstore_api/__init__.py +++ b/samples/client/petstore/python/petstore_api/__init__.py @@ -21,6 +21,7 @@ from .models.api_response import ApiResponse from .models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from .models.array_of_number_only import ArrayOfNumberOnly from .models.array_test import ArrayTest +from .models.capitalization import Capitalization from .models.cat import Cat from .models.category import Category from .models.class_model import ClassModel diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index d4a40cfcbfd..620bb3e4bc8 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -116,7 +116,7 @@ class ApiClient(object): collection_formats) for k, v in path_params: resource_path = resource_path.replace( - '{%s}' % k, quote(str(v))) + '{%s}' % k, quote(str(v), safe='')) # no safe chars, encode everything # query parameters if query_params: diff --git a/samples/client/petstore/python/petstore_api/apis/store_api.py b/samples/client/petstore/python/petstore_api/apis/store_api.py index 089342ed275..7bfe115b10e 100644 --- a/samples/client/petstore/python/petstore_api/apis/store_api.py +++ b/samples/client/petstore/python/petstore_api/apis/store_api.py @@ -105,8 +105,6 @@ class StoreApi(object): if ('order_id' not in params) or (params['order_id'] is None): raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") - if 'order_id' in params and params['order_id'] < 1.0: - raise ValueError("Invalid value for parameter `order_id` when calling `delete_order`, must be a value greater than or equal to `1.0`") collection_formats = {} diff --git a/samples/client/petstore/python/petstore_api/models/__init__.py b/samples/client/petstore/python/petstore_api/models/__init__.py index 844bc150b72..f2a15c2d194 100644 --- a/samples/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/client/petstore/python/petstore_api/models/__init__.py @@ -21,6 +21,7 @@ from .api_response import ApiResponse from .array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from .array_of_number_only import ArrayOfNumberOnly from .array_test import ArrayTest +from .capitalization import Capitalization from .cat import Cat from .category import Category from .class_model import ClassModel diff --git a/samples/client/petstore/python/petstore_api/models/capitalization.py b/samples/client/petstore/python/petstore_api/models/capitalization.py new file mode 100644 index 00000000000..e524d7604fd --- /dev/null +++ b/samples/client/petstore/python/petstore_api/models/capitalization.py @@ -0,0 +1,234 @@ +# coding: utf-8 + +""" + Swagger Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from pprint import pformat +from six import iteritems +import re + + +class Capitalization(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self, small_camel=None, capital_camel=None, small_snake=None, capital_snake=None, sca_eth_flow_points=None, att_name=None): + """ + Capitalization - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'small_camel': 'str', + 'capital_camel': 'str', + 'small_snake': 'str', + 'capital_snake': 'str', + 'sca_eth_flow_points': 'str', + 'att_name': 'str' + } + + self.attribute_map = { + 'small_camel': 'smallCamel', + 'capital_camel': 'CapitalCamel', + 'small_snake': 'small_Snake', + 'capital_snake': 'Capital_Snake', + 'sca_eth_flow_points': 'SCA_ETH_Flow_Points', + 'att_name': 'ATT_NAME' + } + + self._small_camel = small_camel + self._capital_camel = capital_camel + self._small_snake = small_snake + self._capital_snake = capital_snake + self._sca_eth_flow_points = sca_eth_flow_points + self._att_name = att_name + + @property + def small_camel(self): + """ + Gets the small_camel of this Capitalization. + + :return: The small_camel of this Capitalization. + :rtype: str + """ + return self._small_camel + + @small_camel.setter + def small_camel(self, small_camel): + """ + Sets the small_camel of this Capitalization. + + :param small_camel: The small_camel of this Capitalization. + :type: str + """ + + self._small_camel = small_camel + + @property + def capital_camel(self): + """ + Gets the capital_camel of this Capitalization. + + :return: The capital_camel of this Capitalization. + :rtype: str + """ + return self._capital_camel + + @capital_camel.setter + def capital_camel(self, capital_camel): + """ + Sets the capital_camel of this Capitalization. + + :param capital_camel: The capital_camel of this Capitalization. + :type: str + """ + + self._capital_camel = capital_camel + + @property + def small_snake(self): + """ + Gets the small_snake of this Capitalization. + + :return: The small_snake of this Capitalization. + :rtype: str + """ + return self._small_snake + + @small_snake.setter + def small_snake(self, small_snake): + """ + Sets the small_snake of this Capitalization. + + :param small_snake: The small_snake of this Capitalization. + :type: str + """ + + self._small_snake = small_snake + + @property + def capital_snake(self): + """ + Gets the capital_snake of this Capitalization. + + :return: The capital_snake of this Capitalization. + :rtype: str + """ + return self._capital_snake + + @capital_snake.setter + def capital_snake(self, capital_snake): + """ + Sets the capital_snake of this Capitalization. + + :param capital_snake: The capital_snake of this Capitalization. + :type: str + """ + + self._capital_snake = capital_snake + + @property + def sca_eth_flow_points(self): + """ + Gets the sca_eth_flow_points of this Capitalization. + + :return: The sca_eth_flow_points of this Capitalization. + :rtype: str + """ + return self._sca_eth_flow_points + + @sca_eth_flow_points.setter + def sca_eth_flow_points(self, sca_eth_flow_points): + """ + Sets the sca_eth_flow_points of this Capitalization. + + :param sca_eth_flow_points: The sca_eth_flow_points of this Capitalization. + :type: str + """ + + self._sca_eth_flow_points = sca_eth_flow_points + + @property + def att_name(self): + """ + Gets the att_name of this Capitalization. + Name of the pet + + :return: The att_name of this Capitalization. + :rtype: str + """ + return self._att_name + + @att_name.setter + def att_name(self, att_name): + """ + Sets the att_name of this Capitalization. + Name of the pet + + :param att_name: The att_name of this Capitalization. + :type: str + """ + + self._att_name = att_name + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other diff --git a/samples/client/petstore/python/requirements.txt b/samples/client/petstore/python/requirements.txt index f00e08fa339..bafdc07532f 100644 --- a/samples/client/petstore/python/requirements.txt +++ b/samples/client/petstore/python/requirements.txt @@ -1,5 +1,5 @@ certifi >= 14.05.14 -six == 1.8.0 +six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.15.1 diff --git a/samples/client/petstore/python/swagger_client/models/animal.py b/samples/client/petstore/python/swagger_client/models/animal.py deleted file mode 100644 index 762e3df5b37..00000000000 --- a/samples/client/petstore/python/swagger_client/models/animal.py +++ /dev/null @@ -1,120 +0,0 @@ -# coding: utf-8 - -""" -Copyright 2016 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. - - Ref: https://github.com/swagger-api/swagger-codegen -""" - -from pprint import pformat -from six import iteritems - - -class Animal(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - def __init__(self): - """ - Animal - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. - """ - self.swagger_types = { - 'class_name': 'str' - } - - self.attribute_map = { - 'class_name': 'className' - } - - self._class_name = None - - @property - def class_name(self): - """ - Gets the class_name of this Animal. - - - :return: The class_name of this Animal. - :rtype: str - """ - return self._class_name - - @class_name.setter - def class_name(self, class_name): - """ - Sets the class_name of this Animal. - - - :param class_name: The class_name of this Animal. - :type: str - """ - self._class_name = class_name - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other - diff --git a/samples/client/petstore/python/swagger_client/models/cat.py b/samples/client/petstore/python/swagger_client/models/cat.py deleted file mode 100644 index 4744fc4821c..00000000000 --- a/samples/client/petstore/python/swagger_client/models/cat.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding: utf-8 - -""" -Copyright 2016 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. - - Ref: https://github.com/swagger-api/swagger-codegen -""" - -from pprint import pformat -from six import iteritems - - -class Cat(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - def __init__(self): - """ - Cat - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. - """ - self.swagger_types = { - 'class_name': 'str', - 'declawed': 'bool' - } - - self.attribute_map = { - 'class_name': 'className', - 'declawed': 'declawed' - } - - self._class_name = None - self._declawed = None - - @property - def class_name(self): - """ - Gets the class_name of this Cat. - - - :return: The class_name of this Cat. - :rtype: str - """ - return self._class_name - - @class_name.setter - def class_name(self, class_name): - """ - Sets the class_name of this Cat. - - - :param class_name: The class_name of this Cat. - :type: str - """ - self._class_name = class_name - - @property - def declawed(self): - """ - Gets the declawed of this Cat. - - - :return: The declawed of this Cat. - :rtype: bool - """ - return self._declawed - - @declawed.setter - def declawed(self, declawed): - """ - Sets the declawed of this Cat. - - - :param declawed: The declawed of this Cat. - :type: bool - """ - self._declawed = declawed - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other - diff --git a/samples/client/petstore/python/swagger_client/models/dog.py b/samples/client/petstore/python/swagger_client/models/dog.py deleted file mode 100644 index 3885dd314ef..00000000000 --- a/samples/client/petstore/python/swagger_client/models/dog.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding: utf-8 - -""" -Copyright 2016 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. - - Ref: https://github.com/swagger-api/swagger-codegen -""" - -from pprint import pformat -from six import iteritems - - -class Dog(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - def __init__(self): - """ - Dog - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. - """ - self.swagger_types = { - 'class_name': 'str', - 'breed': 'str' - } - - self.attribute_map = { - 'class_name': 'className', - 'breed': 'breed' - } - - self._class_name = None - self._breed = None - - @property - def class_name(self): - """ - Gets the class_name of this Dog. - - - :return: The class_name of this Dog. - :rtype: str - """ - return self._class_name - - @class_name.setter - def class_name(self, class_name): - """ - Sets the class_name of this Dog. - - - :param class_name: The class_name of this Dog. - :type: str - """ - self._class_name = class_name - - @property - def breed(self): - """ - Gets the breed of this Dog. - - - :return: The breed of this Dog. - :rtype: str - """ - return self._breed - - @breed.setter - def breed(self, breed): - """ - Sets the breed of this Dog. - - - :param breed: The breed of this Dog. - :type: str - """ - self._breed = breed - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other - diff --git a/samples/client/petstore/python/test/test_capitalization.py b/samples/client/petstore/python/test/test_capitalization.py new file mode 100644 index 00000000000..1415107dcdc --- /dev/null +++ b/samples/client/petstore/python/test/test_capitalization.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + Swagger Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import os +import sys +import unittest + +import petstore_api +from petstore_api.rest import ApiException +from petstore_api.models.capitalization import Capitalization + + +class TestCapitalization(unittest.TestCase): + """ Capitalization unit test stubs """ + + def setUp(self): + pass + + def tearDown(self): + pass + + def testCapitalization(self): + """ + Test Capitalization + """ + model = petstore_api.models.capitalization.Capitalization() + + +if __name__ == '__main__': + unittest.main()