From ad6b347170e2835997ff4c63bc92f4e6ce33201a Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Mon, 16 May 2016 22:16:56 +0100 Subject: [PATCH] Add requirments.txt and tox.ini --- .../languages/PythonClientCodegen.java | 4 + .../resources/python/requirements.mustache | 5 + .../python/test-requirements.mustache | 5 + .../src/main/resources/python/tox.mustache | 9 + samples/client/petstore/python/README.md | 11 +- samples/client/petstore/python/docs/Animal.md | 1 + .../client/petstore/python/docs/AnimalFarm.md | 9 + samples/client/petstore/python/docs/Cat.md | 1 + samples/client/petstore/python/docs/Dog.md | 1 + .../client/petstore/python/docs/EnumClass.md | 9 + .../client/petstore/python/docs/EnumTest.md | 12 ++ .../client/petstore/python/docs/FakeApi.md | 8 +- samples/client/petstore/python/docs/Name.md | 1 + .../client/petstore/python/requirements.txt | 5 + samples/client/petstore/python/setup.py | 2 +- .../python/swagger_client.egg-info/PKG-INFO | 2 +- .../python/swagger_client/__init__.py | 3 + .../python/swagger_client/apis/fake_api.py | 4 +- .../python/swagger_client/models/__init__.py | 3 + .../python/swagger_client/models/animal.py | 30 ++- .../swagger_client/models/animal_farm.py | 98 +++++++++ .../python/swagger_client/models/cat.py | 26 +++ .../python/swagger_client/models/dog.py | 26 +++ .../swagger_client/models/enum_class.py | 98 +++++++++ .../python/swagger_client/models/enum_test.py | 192 ++++++++++++++++++ .../python/swagger_client/models/name.py | 30 ++- .../petstore/python/test-requirements.txt | 5 + .../petstore/python/test/test_animal_farm.py | 49 +++++ .../petstore/python/test/test_enum_class.py | 49 +++++ .../petstore/python/test/test_enum_test.py | 49 +++++ samples/client/petstore/python/tox.ini | 9 +- 31 files changed, 735 insertions(+), 21 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/python/requirements.mustache create mode 100644 modules/swagger-codegen/src/main/resources/python/test-requirements.mustache create mode 100644 modules/swagger-codegen/src/main/resources/python/tox.mustache create mode 100644 samples/client/petstore/python/docs/AnimalFarm.md create mode 100644 samples/client/petstore/python/docs/EnumClass.md create mode 100644 samples/client/petstore/python/docs/EnumTest.md create mode 100644 samples/client/petstore/python/requirements.txt create mode 100644 samples/client/petstore/python/swagger_client/models/animal_farm.py create mode 100644 samples/client/petstore/python/swagger_client/models/enum_class.py create mode 100644 samples/client/petstore/python/swagger_client/models/enum_test.py create mode 100644 samples/client/petstore/python/test-requirements.txt create mode 100644 samples/client/petstore/python/test/test_animal_farm.py create mode 100644 samples/client/petstore/python/test/test_enum_class.py create mode 100644 samples/client/petstore/python/test/test_enum_test.py diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index cc3892bb937..8bc117120d6 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -150,6 +150,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py")); + supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini")); + supportingFiles.add(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt")); + supportingFiles.add(new SupportingFile("requirements.mustache", "", "requirements.txt")); + supportingFiles.add(new SupportingFile("api_client.mustache", swaggerFolder, "api_client.py")); supportingFiles.add(new SupportingFile("rest.mustache", swaggerFolder, "rest.py")); supportingFiles.add(new SupportingFile("configuration.mustache", swaggerFolder, "configuration.py")); diff --git a/modules/swagger-codegen/src/main/resources/python/requirements.mustache b/modules/swagger-codegen/src/main/resources/python/requirements.mustache new file mode 100644 index 00000000000..f00e08fa339 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/requirements.mustache @@ -0,0 +1,5 @@ +certifi >= 14.05.14 +six == 1.8.0 +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.15.1 diff --git a/modules/swagger-codegen/src/main/resources/python/test-requirements.mustache b/modules/swagger-codegen/src/main/resources/python/test-requirements.mustache new file mode 100644 index 00000000000..2702246c0e6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/test-requirements.mustache @@ -0,0 +1,5 @@ +coverage>=4.0.3 +nose>=1.3.7 +pluggy>=0.3.1 +py>=1.4.31 +randomize>=0.13 diff --git a/modules/swagger-codegen/src/main/resources/python/tox.mustache b/modules/swagger-codegen/src/main/resources/python/tox.mustache new file mode 100644 index 00000000000..e4303709a71 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/tox.mustache @@ -0,0 +1,9 @@ +[tox] +envlist = py27, py34 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + python setup.py test diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 3cdf5029787..a87752e0c68 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -1,11 +1,11 @@ # swagger_client -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-05-09T01:08:25.311+01:00 +- Build date: 2016-05-16T22:16:49.376+01:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. @@ -66,7 +66,7 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) password = 'password_example' # str | None (optional) try: - # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 api_instance.test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password) except ApiException as e: print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e @@ -79,7 +79,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters +*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status @@ -105,10 +105,13 @@ Class | Method | HTTP request | Description ## Documentation For Models - [Animal](docs/Animal.md) + - [AnimalFarm](docs/AnimalFarm.md) - [ApiResponse](docs/ApiResponse.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [Dog](docs/Dog.md) + - [EnumClass](docs/EnumClass.md) + - [EnumTest](docs/EnumTest.md) - [FormatTest](docs/FormatTest.md) - [Model200Response](docs/Model200Response.md) - [ModelReturn](docs/ModelReturn.md) diff --git a/samples/client/petstore/python/docs/Animal.md b/samples/client/petstore/python/docs/Animal.md index ceb8002b4ab..7ed4ba541fa 100644 --- a/samples/client/petstore/python/docs/Animal.md +++ b/samples/client/petstore/python/docs/Animal.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | +**color** | **str** | | [optional] [default to 'red'] [[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/docs/AnimalFarm.md b/samples/client/petstore/python/docs/AnimalFarm.md new file mode 100644 index 00000000000..df6bab21dae --- /dev/null +++ b/samples/client/petstore/python/docs/AnimalFarm.md @@ -0,0 +1,9 @@ +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/docs/Cat.md b/samples/client/petstore/python/docs/Cat.md index fd4cd174fc2..d052c5615b8 100644 --- a/samples/client/petstore/python/docs/Cat.md +++ b/samples/client/petstore/python/docs/Cat.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | +**color** | **str** | | [optional] [default to 'red'] **declawed** | **bool** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/Dog.md b/samples/client/petstore/python/docs/Dog.md index a4b38a70335..ac70f17e668 100644 --- a/samples/client/petstore/python/docs/Dog.md +++ b/samples/client/petstore/python/docs/Dog.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | +**color** | **str** | | [optional] [default to 'red'] **breed** | **str** | | [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/docs/EnumClass.md b/samples/client/petstore/python/docs/EnumClass.md new file mode 100644 index 00000000000..67f017becd0 --- /dev/null +++ b/samples/client/petstore/python/docs/EnumClass.md @@ -0,0 +1,9 @@ +# EnumClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/docs/EnumTest.md b/samples/client/petstore/python/docs/EnumTest.md new file mode 100644 index 00000000000..38dd71f5b83 --- /dev/null +++ b/samples/client/petstore/python/docs/EnumTest.md @@ -0,0 +1,12 @@ +# EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_string** | **str** | | [optional] +**enum_integer** | **int** | | [optional] +**enum_number** | **float** | | [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/docs/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index 66d9a04434a..81e84f646f2 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters +[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # **test_endpoint_parameters** > test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password) -Fake endpoint for testing various parameters +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 -Fake endpoint for testing various parameters +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ### Example ```python @@ -37,7 +37,7 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) password = 'password_example' # str | None (optional) try: - # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 api_instance.test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password) except ApiException as e: print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e diff --git a/samples/client/petstore/python/docs/Name.md b/samples/client/petstore/python/docs/Name.md index a472a529a0f..542da3f0476 100644 --- a/samples/client/petstore/python/docs/Name.md +++ b/samples/client/petstore/python/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes **name** | **int** | | **snake_case** | **int** | | [optional] **_property** | **str** | | [optional] +**_123_number** | **int** | | [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/requirements.txt b/samples/client/petstore/python/requirements.txt new file mode 100644 index 00000000000..f00e08fa339 --- /dev/null +++ b/samples/client/petstore/python/requirements.txt @@ -0,0 +1,5 @@ +certifi >= 14.05.14 +six == 1.8.0 +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.15.1 diff --git a/samples/client/petstore/python/setup.py b/samples/client/petstore/python/setup.py index 577fd8133bf..f8985832d25 100644 --- a/samples/client/petstore/python/setup.py +++ b/samples/client/petstore/python/setup.py @@ -28,7 +28,7 @@ setup( packages=find_packages(), include_package_data=True, long_description="""\ - This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ """ ) diff --git a/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO b/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO index a4852b36ea4..494a1526640 100644 --- a/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO +++ b/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO @@ -6,7 +6,7 @@ Home-page: UNKNOWN Author: UNKNOWN Author-email: apiteam@swagger.io License: UNKNOWN -Description: This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +Description: This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \ Keywords: Swagger,Swagger Petstore Platform: UNKNOWN diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 783f8b9713a..f9e10599854 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -2,10 +2,13 @@ from __future__ import absolute_import # import models into sdk package from .models.animal import Animal +from .models.animal_farm import AnimalFarm from .models.api_response import ApiResponse from .models.cat import Cat from .models.category import Category from .models.dog import Dog +from .models.enum_class import EnumClass +from .models.enum_test import EnumTest from .models.format_test import FormatTest from .models.model_200_response import Model200Response from .models.model_return import ModelReturn diff --git a/samples/client/petstore/python/swagger_client/apis/fake_api.py b/samples/client/petstore/python/swagger_client/apis/fake_api.py index 5d3903b2d21..9e2b185a5aa 100644 --- a/samples/client/petstore/python/swagger_client/apis/fake_api.py +++ b/samples/client/petstore/python/swagger_client/apis/fake_api.py @@ -48,8 +48,8 @@ class FakeApi(object): def test_endpoint_parameters(self, number, double, string, byte, **kwargs): """ - Fake endpoint for testing various parameters - Fake endpoint for testing various parameters + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function diff --git a/samples/client/petstore/python/swagger_client/models/__init__.py b/samples/client/petstore/python/swagger_client/models/__init__.py index 1d0e82f2295..664ec8471dc 100644 --- a/samples/client/petstore/python/swagger_client/models/__init__.py +++ b/samples/client/petstore/python/swagger_client/models/__init__.py @@ -2,10 +2,13 @@ from __future__ import absolute_import # import models into model package from .animal import Animal +from .animal_farm import AnimalFarm from .api_response import ApiResponse from .cat import Cat from .category import Category from .dog import Dog +from .enum_class import EnumClass +from .enum_test import EnumTest from .format_test import FormatTest from .model_200_response import Model200Response from .model_return import ModelReturn diff --git a/samples/client/petstore/python/swagger_client/models/animal.py b/samples/client/petstore/python/swagger_client/models/animal.py index 0ae8f2b4bde..90735535086 100644 --- a/samples/client/petstore/python/swagger_client/models/animal.py +++ b/samples/client/petstore/python/swagger_client/models/animal.py @@ -38,14 +38,17 @@ class Animal(object): and the value is json key in definition. """ self.swagger_types = { - 'class_name': 'str' + 'class_name': 'str', + 'color': 'str' } self.attribute_map = { - 'class_name': 'className' + 'class_name': 'className', + 'color': 'color' } self._class_name = None + self._color = 'red' @property def class_name(self): @@ -70,6 +73,29 @@ class Animal(object): self._class_name = class_name + @property + def color(self): + """ + Gets the color of this Animal. + + + :return: The color of this Animal. + :rtype: str + """ + return self._color + + @color.setter + def color(self, color): + """ + Sets the color of this Animal. + + + :param color: The color of this Animal. + :type: str + """ + + self._color = color + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/swagger_client/models/animal_farm.py b/samples/client/petstore/python/swagger_client/models/animal_farm.py new file mode 100644 index 00000000000..5e362497c8d --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/animal_farm.py @@ -0,0 +1,98 @@ +# 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 +import re + + +class AnimalFarm(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + AnimalFarm - 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 = { + + } + + self.attribute_map = { + + } + + + 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 index fd2e5e4fce4..80b1e867a94 100644 --- a/samples/client/petstore/python/swagger_client/models/cat.py +++ b/samples/client/petstore/python/swagger_client/models/cat.py @@ -39,15 +39,18 @@ class Cat(object): """ self.swagger_types = { 'class_name': 'str', + 'color': 'str', 'declawed': 'bool' } self.attribute_map = { 'class_name': 'className', + 'color': 'color', 'declawed': 'declawed' } self._class_name = None + self._color = 'red' self._declawed = None @property @@ -73,6 +76,29 @@ class Cat(object): self._class_name = class_name + @property + def color(self): + """ + Gets the color of this Cat. + + + :return: The color of this Cat. + :rtype: str + """ + return self._color + + @color.setter + def color(self, color): + """ + Sets the color of this Cat. + + + :param color: The color of this Cat. + :type: str + """ + + self._color = color + @property def declawed(self): """ diff --git a/samples/client/petstore/python/swagger_client/models/dog.py b/samples/client/petstore/python/swagger_client/models/dog.py index ac25ef01807..49fcfee4ca0 100644 --- a/samples/client/petstore/python/swagger_client/models/dog.py +++ b/samples/client/petstore/python/swagger_client/models/dog.py @@ -39,15 +39,18 @@ class Dog(object): """ self.swagger_types = { 'class_name': 'str', + 'color': 'str', 'breed': 'str' } self.attribute_map = { 'class_name': 'className', + 'color': 'color', 'breed': 'breed' } self._class_name = None + self._color = 'red' self._breed = None @property @@ -73,6 +76,29 @@ class Dog(object): self._class_name = class_name + @property + def color(self): + """ + Gets the color of this Dog. + + + :return: The color of this Dog. + :rtype: str + """ + return self._color + + @color.setter + def color(self, color): + """ + Sets the color of this Dog. + + + :param color: The color of this Dog. + :type: str + """ + + self._color = color + @property def breed(self): """ diff --git a/samples/client/petstore/python/swagger_client/models/enum_class.py b/samples/client/petstore/python/swagger_client/models/enum_class.py new file mode 100644 index 00000000000..7973fd0af8f --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/enum_class.py @@ -0,0 +1,98 @@ +# 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 +import re + + +class EnumClass(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + EnumClass - 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 = { + + } + + self.attribute_map = { + + } + + + 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/enum_test.py b/samples/client/petstore/python/swagger_client/models/enum_test.py new file mode 100644 index 00000000000..ad81055385c --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/enum_test.py @@ -0,0 +1,192 @@ +# 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 +import re + + +class EnumTest(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + EnumTest - 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 = { + 'enum_string': 'str', + 'enum_integer': 'int', + 'enum_number': 'float' + } + + self.attribute_map = { + 'enum_string': 'enum_string', + 'enum_integer': 'enum_integer', + 'enum_number': 'enum_number' + } + + self._enum_string = None + self._enum_integer = None + self._enum_number = None + + @property + def enum_string(self): + """ + Gets the enum_string of this EnumTest. + + + :return: The enum_string of this EnumTest. + :rtype: str + """ + return self._enum_string + + @enum_string.setter + def enum_string(self, enum_string): + """ + Sets the enum_string of this EnumTest. + + + :param enum_string: The enum_string of this EnumTest. + :type: str + """ + allowed_values = ["UPPER", "lower"] + if enum_string not in allowed_values: + raise ValueError( + "Invalid value for `enum_string`, must be one of {0}" + .format(allowed_values) + ) + + self._enum_string = enum_string + + @property + def enum_integer(self): + """ + Gets the enum_integer of this EnumTest. + + + :return: The enum_integer of this EnumTest. + :rtype: int + """ + return self._enum_integer + + @enum_integer.setter + def enum_integer(self, enum_integer): + """ + Sets the enum_integer of this EnumTest. + + + :param enum_integer: The enum_integer of this EnumTest. + :type: int + """ + allowed_values = ["1", "-1"] + if enum_integer not in allowed_values: + raise ValueError( + "Invalid value for `enum_integer`, must be one of {0}" + .format(allowed_values) + ) + + self._enum_integer = enum_integer + + @property + def enum_number(self): + """ + Gets the enum_number of this EnumTest. + + + :return: The enum_number of this EnumTest. + :rtype: float + """ + return self._enum_number + + @enum_number.setter + def enum_number(self, enum_number): + """ + Sets the enum_number of this EnumTest. + + + :param enum_number: The enum_number of this EnumTest. + :type: float + """ + allowed_values = ["1.1", "-1.2"] + if enum_number not in allowed_values: + raise ValueError( + "Invalid value for `enum_number`, must be one of {0}" + .format(allowed_values) + ) + + self._enum_number = enum_number + + 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/name.py b/samples/client/petstore/python/swagger_client/models/name.py index 51345d131ff..21015169ee8 100644 --- a/samples/client/petstore/python/swagger_client/models/name.py +++ b/samples/client/petstore/python/swagger_client/models/name.py @@ -40,18 +40,21 @@ class Name(object): self.swagger_types = { 'name': 'int', 'snake_case': 'int', - '_property': 'str' + '_property': 'str', + '_123_number': 'int' } self.attribute_map = { 'name': 'name', 'snake_case': 'snake_case', - '_property': 'property' + '_property': 'property', + '_123_number': '123Number' } self._name = None self._snake_case = None self.__property = None + self.__123_number = None @property def name(self): @@ -122,6 +125,29 @@ class Name(object): self.__property = _property + @property + def _123_number(self): + """ + Gets the _123_number of this Name. + + + :return: The _123_number of this Name. + :rtype: int + """ + return self.__123_number + + @_123_number.setter + def _123_number(self, _123_number): + """ + Sets the _123_number of this Name. + + + :param _123_number: The _123_number of this Name. + :type: int + """ + + self.__123_number = _123_number + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/test-requirements.txt b/samples/client/petstore/python/test-requirements.txt new file mode 100644 index 00000000000..2702246c0e6 --- /dev/null +++ b/samples/client/petstore/python/test-requirements.txt @@ -0,0 +1,5 @@ +coverage>=4.0.3 +nose>=1.3.7 +pluggy>=0.3.1 +py>=1.4.31 +randomize>=0.13 diff --git a/samples/client/petstore/python/test/test_animal_farm.py b/samples/client/petstore/python/test/test_animal_farm.py new file mode 100644 index 00000000000..74dd22fd3b9 --- /dev/null +++ b/samples/client/petstore/python/test/test_animal_farm.py @@ -0,0 +1,49 @@ +# 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 __future__ import absolute_import + +import os +import sys +import unittest + +import swagger_client +from swagger_client.rest import ApiException +from swagger_client.models.animal_farm import AnimalFarm + + +class TestAnimalFarm(unittest.TestCase): + """ AnimalFarm unit test stubs """ + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAnimalFarm(self): + """ + Test AnimalFarm + """ + model = swagger_client.models.animal_farm.AnimalFarm() + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/samples/client/petstore/python/test/test_enum_class.py b/samples/client/petstore/python/test/test_enum_class.py new file mode 100644 index 00000000000..22e2b5ebb5c --- /dev/null +++ b/samples/client/petstore/python/test/test_enum_class.py @@ -0,0 +1,49 @@ +# 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 __future__ import absolute_import + +import os +import sys +import unittest + +import swagger_client +from swagger_client.rest import ApiException +from swagger_client.models.enum_class import EnumClass + + +class TestEnumClass(unittest.TestCase): + """ EnumClass unit test stubs """ + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumClass(self): + """ + Test EnumClass + """ + model = swagger_client.models.enum_class.EnumClass() + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/samples/client/petstore/python/test/test_enum_test.py b/samples/client/petstore/python/test/test_enum_test.py new file mode 100644 index 00000000000..49cb79e6bc3 --- /dev/null +++ b/samples/client/petstore/python/test/test_enum_test.py @@ -0,0 +1,49 @@ +# 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 __future__ import absolute_import + +import os +import sys +import unittest + +import swagger_client +from swagger_client.rest import ApiException +from swagger_client.models.enum_test import EnumTest + + +class TestEnumTest(unittest.TestCase): + """ EnumTest unit test stubs """ + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumTest(self): + """ + Test EnumTest + """ + model = swagger_client.models.enum_test.EnumTest() + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/samples/client/petstore/python/tox.ini b/samples/client/petstore/python/tox.ini index 9f62f3845bf..e4303709a71 100644 --- a/samples/client/petstore/python/tox.ini +++ b/samples/client/petstore/python/tox.ini @@ -2,9 +2,8 @@ envlist = py27, py34 [testenv] -deps= -r{toxinidir}/dev-requirements.txt +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + commands= - nosetests \ - [] -setenv = - PYTHONWARNINGS=always::DeprecationWarning + python setup.py test