diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index ae8cc8acd239..7a4d11bcbfa1 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -14,7 +14,7 @@ class {{classname}}(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self{{#readWriteVars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/readWriteVars}}): + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): """ {{classname}} - a model defined in Swagger @@ -33,12 +33,10 @@ class {{classname}}(object): {{/hasMore}}{{/vars}} } -{{#readOnlyVars}} - self._{{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}} -{{/readOnlyVars}} -{{#readWriteVars}} +{{#vars}} self._{{name}} = {{name}} -{{/readWriteVars}} +{{/vars}} + {{#vars}}{{#-first}} {{/-first}} @property @@ -52,7 +50,6 @@ class {{classname}}(object): """ return self._{{name}} -{{^isReadOnly}} @{{name}}.setter def {{name}}(self, {{name}}): """ @@ -100,7 +97,6 @@ class {{classname}}(object): self._{{name}} = {{name}} -{{/isReadOnly}} {{/vars}} def to_dict(self): """ diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 6a88a214b474..98e060ea2718 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-07-26T14:38:25.330+08:00 +- Build date: 2016-08-15T23:29:03.602+01:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. @@ -71,7 +71,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 -*FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters +*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum 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 @@ -107,6 +107,7 @@ Class | Method | HTTP request | Description - [Category](docs/Category.md) - [Client](docs/Client.md) - [Dog](docs/Dog.md) + - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) - [FormatTest](docs/FormatTest.md) @@ -129,12 +130,6 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## petstore_auth - **Type**: OAuth @@ -144,6 +139,16 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets +## http_basic_test + +- **Type**: HTTP basic authentication + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Author diff --git a/samples/client/petstore/python/docs/EnumArrays.md b/samples/client/petstore/python/docs/EnumArrays.md new file mode 100644 index 000000000000..e15a5f1fd049 --- /dev/null +++ b/samples/client/petstore/python/docs/EnumArrays.md @@ -0,0 +1,11 @@ +# EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_symbol** | **str** | | [optional] +**array_enum** | **list[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/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index a3ab6376e6f7..0d03962a8d50 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -6,7 +6,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 -[**test_enum_query_parameters**](FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters +[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters # **test_client_model** @@ -68,6 +68,10 @@ import petstore_api from petstore_api.rest import ApiException from pprint import pprint +# Configure HTTP basic authorization: http_basic_test +petstore_api.configuration.username = 'YOUR_USERNAME' +petstore_api.configuration.password = 'YOUR_PASSWORD' + # create an instance of the API class api_instance = petstore_api.FakeApi() number = 3.4 # float | None @@ -113,7 +117,7 @@ void (empty response body) ### Authorization -No authorization required +[http_basic_test](../README.md#http_basic_test) ### HTTP request headers @@ -122,10 +126,10 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **test_enum_query_parameters** -> test_enum_query_parameters(enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double) +# **test_enum_parameters** +> test_enum_parameters(enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string, enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double) -To test enum query parameters +To test enum parameters ### Example ```python @@ -136,21 +140,31 @@ from pprint import pprint # create an instance of the API class api_instance = petstore_api.FakeApi() +enum_form_string_array = ['enum_form_string_array_example'] # list[str] | Form parameter enum test (string array) (optional) +enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to -efg) +enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional) +enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to -efg) +enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional) enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to -efg) enum_query_integer = 3.4 # float | Query parameter enum test (double) (optional) enum_query_double = 1.2 # float | Query parameter enum test (double) (optional) try: - # To test enum query parameters - api_instance.test_enum_query_parameters(enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double) + # To test enum parameters + api_instance.test_enum_parameters(enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string, enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double) except ApiException as e: - print "Exception when calling FakeApi->test_enum_query_parameters: %s\n" % e + print "Exception when calling FakeApi->test_enum_parameters: %s\n" % e ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + **enum_form_string_array** | [**list[str]**](str.md)| Form parameter enum test (string array) | [optional] + **enum_form_string** | **str**| Form parameter enum test (string) | [optional] [default to -efg] + **enum_header_string_array** | [**list[str]**](str.md)| Header parameter enum test (string array) | [optional] + **enum_header_string** | **str**| Header parameter enum test (string) | [optional] [default to -efg] + **enum_query_string_array** | [**list[str]**](str.md)| Query parameter enum test (string array) | [optional] **enum_query_string** | **str**| Query parameter enum test (string) | [optional] [default to -efg] **enum_query_integer** | **float**| Query parameter enum test (double) | [optional] **enum_query_double** | **float**| Query parameter enum test (double) | [optional] diff --git a/samples/client/petstore/python/petstore_api/__init__.py b/samples/client/petstore/python/petstore_api/__init__.py index 18d1b8f52374..8f043d8a1ad6 100644 --- a/samples/client/petstore/python/petstore_api/__init__.py +++ b/samples/client/petstore/python/petstore_api/__init__.py @@ -36,6 +36,7 @@ from .models.cat import Cat from .models.category import Category from .models.client import Client from .models.dog import Dog +from .models.enum_arrays import EnumArrays from .models.enum_class import EnumClass from .models.enum_test import EnumTest from .models.format_test import FormatTest diff --git a/samples/client/petstore/python/petstore_api/apis/fake_api.py b/samples/client/petstore/python/petstore_api/apis/fake_api.py index c0cc973fc06d..76cf960c6e90 100644 --- a/samples/client/petstore/python/petstore_api/apis/fake_api.py +++ b/samples/client/petstore/python/petstore_api/apis/fake_api.py @@ -322,7 +322,7 @@ class FakeApi(object): select_header_content_type(['application/xml; charset=utf-8', 'application/json; charset=utf-8']) # Authentication setting - auth_settings = [] + auth_settings = ['http_basic_test'] return self.api_client.call_api(resource_path, 'POST', path_params, @@ -336,9 +336,9 @@ class FakeApi(object): callback=params.get('callback'), _return_http_data_only=params.get('_return_http_data_only')) - def test_enum_query_parameters(self, **kwargs): + def test_enum_parameters(self, **kwargs): """ - To test enum query parameters + To test enum parameters This method makes a synchronous HTTP request by default. To make an @@ -347,10 +347,15 @@ class FakeApi(object): >>> def callback_function(response): >>> pprint(response) >>> - >>> thread = api.test_enum_query_parameters(callback=callback_function) + >>> thread = api.test_enum_parameters(callback=callback_function) :param callback function: The callback function for asynchronous request. (optional) + :param list[str] enum_form_string_array: Form parameter enum test (string array) + :param str enum_form_string: Form parameter enum test (string) + :param list[str] enum_header_string_array: Header parameter enum test (string array) + :param str enum_header_string: Header parameter enum test (string) + :param list[str] enum_query_string_array: Query parameter enum test (string array) :param str enum_query_string: Query parameter enum test (string) :param float enum_query_integer: Query parameter enum test (double) :param float enum_query_double: Query parameter enum test (double) @@ -360,14 +365,14 @@ class FakeApi(object): """ kwargs['_return_http_data_only'] = True if kwargs.get('callback'): - return self.test_enum_query_parameters_with_http_info(**kwargs) + return self.test_enum_parameters_with_http_info(**kwargs) else: - (data) = self.test_enum_query_parameters_with_http_info(**kwargs) + (data) = self.test_enum_parameters_with_http_info(**kwargs) return data - def test_enum_query_parameters_with_http_info(self, **kwargs): + def test_enum_parameters_with_http_info(self, **kwargs): """ - To test enum query parameters + To test enum parameters This method makes a synchronous HTTP request by default. To make an @@ -376,10 +381,15 @@ class FakeApi(object): >>> def callback_function(response): >>> pprint(response) >>> - >>> thread = api.test_enum_query_parameters_with_http_info(callback=callback_function) + >>> thread = api.test_enum_parameters_with_http_info(callback=callback_function) :param callback function: The callback function for asynchronous request. (optional) + :param list[str] enum_form_string_array: Form parameter enum test (string array) + :param str enum_form_string: Form parameter enum test (string) + :param list[str] enum_header_string_array: Header parameter enum test (string array) + :param str enum_header_string: Header parameter enum test (string) + :param list[str] enum_query_string_array: Query parameter enum test (string array) :param str enum_query_string: Query parameter enum test (string) :param float enum_query_integer: Query parameter enum test (double) :param float enum_query_double: Query parameter enum test (double) @@ -388,7 +398,7 @@ class FakeApi(object): returns the request thread. """ - all_params = ['enum_query_string', 'enum_query_integer', 'enum_query_double'] + all_params = ['enum_form_string_array', 'enum_form_string', 'enum_header_string_array', 'enum_header_string', 'enum_query_string_array', 'enum_query_string', 'enum_query_integer', 'enum_query_double'] all_params.append('callback') all_params.append('_return_http_data_only') @@ -397,7 +407,7 @@ class FakeApi(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method test_enum_query_parameters" % key + " to method test_enum_parameters" % key ) params[key] = val del params['kwargs'] @@ -406,15 +416,25 @@ class FakeApi(object): path_params = {} query_params = {} + if 'enum_query_string_array' in params: + query_params['enum_query_string_array'] = params['enum_query_string_array'] + if 'enum_query_string' in params: + query_params['enum_query_string'] = params['enum_query_string'] if 'enum_query_integer' in params: query_params['enum_query_integer'] = params['enum_query_integer'] header_params = {} + if 'enum_header_string_array' in params: + header_params['enum_header_string_array'] = params['enum_header_string_array'] + if 'enum_header_string' in params: + header_params['enum_header_string'] = params['enum_header_string'] form_params = [] local_var_files = {} - if 'enum_query_string' in params: - form_params.append(('enum_query_string', params['enum_query_string'])) + if 'enum_form_string_array' in params: + form_params.append(('enum_form_string_array', params['enum_form_string_array'])) + if 'enum_form_string' in params: + form_params.append(('enum_form_string', params['enum_form_string'])) if 'enum_query_double' in params: form_params.append(('enum_query_double', params['enum_query_double'])) diff --git a/samples/client/petstore/python/petstore_api/configuration.py b/samples/client/petstore/python/petstore_api/configuration.py index 45cfef154721..82d233a9f6b7 100644 --- a/samples/client/petstore/python/petstore_api/configuration.py +++ b/samples/client/petstore/python/petstore_api/configuration.py @@ -221,13 +221,6 @@ class Configuration(object): :return: The Auth Settings information dict. """ return { - 'api_key': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'api_key', - 'value': self.get_api_key_with_prefix('api_key') - }, 'petstore_auth': { @@ -236,6 +229,20 @@ class Configuration(object): 'key': 'Authorization', 'value': 'Bearer ' + self.access_token }, + 'http_basic_test': + { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + }, + 'api_key': + { + 'type': 'api_key', + 'in': 'header', + 'key': 'api_key', + 'value': self.get_api_key_with_prefix('api_key') + }, } diff --git a/samples/client/petstore/python/petstore_api/models/__init__.py b/samples/client/petstore/python/petstore_api/models/__init__.py index d2289156d992..ac0530ef1904 100644 --- a/samples/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/client/petstore/python/petstore_api/models/__init__.py @@ -36,6 +36,7 @@ from .cat import Cat from .category import Category from .client import Client from .dog import Dog +from .enum_arrays import EnumArrays from .enum_class import EnumClass from .enum_test import EnumTest from .format_test import FormatTest diff --git a/samples/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python/petstore_api/models/additional_properties_class.py index 8686db9210f9..ff0a35651354 100644 --- a/samples/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -54,6 +54,7 @@ class AdditionalPropertiesClass(object): self._map_property = map_property self._map_of_map_property = map_of_map_property + @property def map_property(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/animal.py b/samples/client/petstore/python/petstore_api/models/animal.py index 6c20ff3208f5..fb902912fbea 100644 --- a/samples/client/petstore/python/petstore_api/models/animal.py +++ b/samples/client/petstore/python/petstore_api/models/animal.py @@ -54,6 +54,7 @@ class Animal(object): self._class_name = class_name self._color = color + @property def class_name(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/animal_farm.py b/samples/client/petstore/python/petstore_api/models/animal_farm.py index 3a3a40ccea46..b14127d636e1 100644 --- a/samples/client/petstore/python/petstore_api/models/animal_farm.py +++ b/samples/client/petstore/python/petstore_api/models/animal_farm.py @@ -49,6 +49,7 @@ class AnimalFarm(object): } + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/petstore_api/models/api_response.py b/samples/client/petstore/python/petstore_api/models/api_response.py index 7540b7a323c4..76595db023b1 100644 --- a/samples/client/petstore/python/petstore_api/models/api_response.py +++ b/samples/client/petstore/python/petstore_api/models/api_response.py @@ -57,6 +57,7 @@ class ApiResponse(object): self._type = type self._message = message + @property def code(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 0cbf47edc36d..15c57560625d 100644 --- a/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -51,6 +51,7 @@ class ArrayOfArrayOfNumberOnly(object): self._array_array_number = array_array_number + @property def array_array_number(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python/petstore_api/models/array_of_number_only.py index 27e60c1808f8..9a8576f070d9 100644 --- a/samples/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -51,6 +51,7 @@ class ArrayOfNumberOnly(object): self._array_number = array_number + @property def array_number(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/array_test.py b/samples/client/petstore/python/petstore_api/models/array_test.py index a8e15c0207e5..3066c365cadb 100644 --- a/samples/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/client/petstore/python/petstore_api/models/array_test.py @@ -57,6 +57,7 @@ class ArrayTest(object): self._array_array_of_integer = array_array_of_integer self._array_array_of_model = array_array_of_model + @property def array_of_string(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/cat.py b/samples/client/petstore/python/petstore_api/models/cat.py index 77fdc9e23bf5..7bd40711c595 100644 --- a/samples/client/petstore/python/petstore_api/models/cat.py +++ b/samples/client/petstore/python/petstore_api/models/cat.py @@ -57,6 +57,7 @@ class Cat(object): self._color = color self._declawed = declawed + @property def class_name(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/category.py b/samples/client/petstore/python/petstore_api/models/category.py index c1c4cb3937c4..f33e0254c1ec 100644 --- a/samples/client/petstore/python/petstore_api/models/category.py +++ b/samples/client/petstore/python/petstore_api/models/category.py @@ -54,6 +54,7 @@ class Category(object): self._id = id self._name = name + @property def id(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/client.py b/samples/client/petstore/python/petstore_api/models/client.py index 1621eb5ea42d..af00af6d6071 100644 --- a/samples/client/petstore/python/petstore_api/models/client.py +++ b/samples/client/petstore/python/petstore_api/models/client.py @@ -51,6 +51,7 @@ class Client(object): self._client = client + @property def client(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/dog.py b/samples/client/petstore/python/petstore_api/models/dog.py index 065be5b2e1ef..5e84656c958f 100644 --- a/samples/client/petstore/python/petstore_api/models/dog.py +++ b/samples/client/petstore/python/petstore_api/models/dog.py @@ -57,6 +57,7 @@ class Dog(object): self._color = color self._breed = breed + @property def class_name(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/client/petstore/python/petstore_api/models/enum_arrays.py new file mode 100644 index 000000000000..855f26cbef69 --- /dev/null +++ b/samples/client/petstore/python/petstore_api/models/enum_arrays.py @@ -0,0 +1,164 @@ +# 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 + + 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 pprint import pformat +from six import iteritems +import re + + +class EnumArrays(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self, just_symbol=None, array_enum=None): + """ + EnumArrays - 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 = { + 'just_symbol': 'str', + 'array_enum': 'list[str]' + } + + self.attribute_map = { + 'just_symbol': 'just_symbol', + 'array_enum': 'array_enum' + } + + self._just_symbol = just_symbol + self._array_enum = array_enum + + + @property + def just_symbol(self): + """ + Gets the just_symbol of this EnumArrays. + + + :return: The just_symbol of this EnumArrays. + :rtype: str + """ + return self._just_symbol + + @just_symbol.setter + def just_symbol(self, just_symbol): + """ + Sets the just_symbol of this EnumArrays. + + + :param just_symbol: The just_symbol of this EnumArrays. + :type: str + """ + allowed_values = [">=", "$"] + if just_symbol not in allowed_values: + raise ValueError( + "Invalid value for `just_symbol` ({0}), must be one of {1}" + .format(just_symbol, allowed_values) + ) + + self._just_symbol = just_symbol + + @property + def array_enum(self): + """ + Gets the array_enum of this EnumArrays. + + + :return: The array_enum of this EnumArrays. + :rtype: list[str] + """ + return self._array_enum + + @array_enum.setter + def array_enum(self, array_enum): + """ + Sets the array_enum of this EnumArrays. + + + :param array_enum: The array_enum of this EnumArrays. + :type: list[str] + """ + allowed_values = ["fish", "crab"] + if array_enum not in allowed_values: + raise ValueError( + "Invalid value for `array_enum` ({0}), must be one of {1}" + .format(array_enum, allowed_values) + ) + + self._array_enum = array_enum + + 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/petstore_api/models/enum_class.py b/samples/client/petstore/python/petstore_api/models/enum_class.py index c15a1a25aadd..930ec53b2ab8 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python/petstore_api/models/enum_class.py @@ -49,6 +49,7 @@ class EnumClass(object): } + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/petstore_api/models/enum_test.py b/samples/client/petstore/python/petstore_api/models/enum_test.py index 087c102a9c55..f405459389b0 100644 --- a/samples/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python/petstore_api/models/enum_test.py @@ -57,6 +57,7 @@ class EnumTest(object): self._enum_integer = enum_integer self._enum_number = enum_number + @property def enum_string(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/format_test.py b/samples/client/petstore/python/petstore_api/models/format_test.py index 37b7e975f26d..bbc14daa13ca 100644 --- a/samples/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/client/petstore/python/petstore_api/models/format_test.py @@ -87,6 +87,7 @@ class FormatTest(object): self._uuid = uuid self._password = password + @property def integer(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python/petstore_api/models/has_only_read_only.py index 1a7943841b58..05dffbbfdacc 100644 --- a/samples/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -32,7 +32,7 @@ class HasOnlyReadOnly(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self): + def __init__(self, bar=None, foo=None): """ HasOnlyReadOnly - a model defined in Swagger @@ -51,8 +51,9 @@ class HasOnlyReadOnly(object): 'foo': 'foo' } - self._bar = None - self._foo = None + self._bar = bar + self._foo = foo + @property def bar(self): @@ -65,6 +66,18 @@ class HasOnlyReadOnly(object): """ return self._bar + @bar.setter + def bar(self, bar): + """ + Sets the bar of this HasOnlyReadOnly. + + + :param bar: The bar of this HasOnlyReadOnly. + :type: str + """ + + self._bar = bar + @property def foo(self): """ @@ -76,6 +89,18 @@ class HasOnlyReadOnly(object): """ return self._foo + @foo.setter + def foo(self, foo): + """ + Sets the foo of this HasOnlyReadOnly. + + + :param foo: The foo of this HasOnlyReadOnly. + :type: str + """ + + self._foo = foo + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/petstore_api/models/list.py b/samples/client/petstore/python/petstore_api/models/list.py index 927aca7091fc..d51f73cc35cc 100644 --- a/samples/client/petstore/python/petstore_api/models/list.py +++ b/samples/client/petstore/python/petstore_api/models/list.py @@ -51,6 +51,7 @@ class List(object): self.__123_list = _123_list + @property def _123_list(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/map_test.py b/samples/client/petstore/python/petstore_api/models/map_test.py index f7eb30f8286b..58ad0d7ac3ef 100644 --- a/samples/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/client/petstore/python/petstore_api/models/map_test.py @@ -54,6 +54,7 @@ class MapTest(object): self._map_map_of_string = map_map_of_string self._map_of_enum_string = map_of_enum_string + @property def map_map_of_string(self): """ @@ -97,7 +98,7 @@ class MapTest(object): :param map_of_enum_string: The map_of_enum_string of this MapTest. :type: dict(str, str) """ - allowed_values = [] + allowed_values = ["UPPER", "lower"] if map_of_enum_string not in allowed_values: raise ValueError( "Invalid value for `map_of_enum_string` ({0}), must be one of {1}" diff --git a/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index 94c94fe494c0..b2e6f4714c36 100644 --- a/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -57,6 +57,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(object): self._date_time = date_time self._map = map + @property def uuid(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/model_200_response.py b/samples/client/petstore/python/petstore_api/models/model_200_response.py index 9c323a85bfd8..3793ec001749 100644 --- a/samples/client/petstore/python/petstore_api/models/model_200_response.py +++ b/samples/client/petstore/python/petstore_api/models/model_200_response.py @@ -54,6 +54,7 @@ class Model200Response(object): self._name = name self.__class = _class + @property def name(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/model_return.py b/samples/client/petstore/python/petstore_api/models/model_return.py index 9dc6000526a5..31369097694f 100644 --- a/samples/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/client/petstore/python/petstore_api/models/model_return.py @@ -51,6 +51,7 @@ class ModelReturn(object): self.__return = _return + @property def _return(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/name.py b/samples/client/petstore/python/petstore_api/models/name.py index df4eae8c7653..cb5c08f3736d 100644 --- a/samples/client/petstore/python/petstore_api/models/name.py +++ b/samples/client/petstore/python/petstore_api/models/name.py @@ -32,7 +32,7 @@ class Name(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self, name=None, _property=None): + def __init__(self, name=None, snake_case=None, _property=None, _123_number=None): """ Name - a model defined in Swagger @@ -55,10 +55,11 @@ class Name(object): '_123_number': '123Number' } - self._snake_case = None - self.__123_number = None self._name = name + self._snake_case = snake_case self.__property = _property + self.__123_number = _123_number + @property def name(self): @@ -94,6 +95,18 @@ class Name(object): """ return self._snake_case + @snake_case.setter + def snake_case(self, snake_case): + """ + Sets the snake_case of this Name. + + + :param snake_case: The snake_case of this Name. + :type: int + """ + + self._snake_case = snake_case + @property def _property(self): """ @@ -128,6 +141,18 @@ class Name(object): """ 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/petstore_api/models/number_only.py b/samples/client/petstore/python/petstore_api/models/number_only.py index 61ade0309e3c..44928b2ea974 100644 --- a/samples/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/client/petstore/python/petstore_api/models/number_only.py @@ -51,6 +51,7 @@ class NumberOnly(object): self._just_number = just_number + @property def just_number(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/order.py b/samples/client/petstore/python/petstore_api/models/order.py index 52c90b2c8129..9d2d2370e0c8 100644 --- a/samples/client/petstore/python/petstore_api/models/order.py +++ b/samples/client/petstore/python/petstore_api/models/order.py @@ -66,6 +66,7 @@ class Order(object): self._status = status self._complete = complete + @property def id(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/pet.py b/samples/client/petstore/python/petstore_api/models/pet.py index cf644e5a8e12..be58ba7af95f 100644 --- a/samples/client/petstore/python/petstore_api/models/pet.py +++ b/samples/client/petstore/python/petstore_api/models/pet.py @@ -66,6 +66,7 @@ class Pet(object): self._tags = tags self._status = status + @property def id(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/read_only_first.py b/samples/client/petstore/python/petstore_api/models/read_only_first.py index 4dc49463a5cd..c54d7aca5f63 100644 --- a/samples/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python/petstore_api/models/read_only_first.py @@ -32,7 +32,7 @@ class ReadOnlyFirst(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self, baz=None): + def __init__(self, bar=None, baz=None): """ ReadOnlyFirst - a model defined in Swagger @@ -51,9 +51,10 @@ class ReadOnlyFirst(object): 'baz': 'baz' } - self._bar = None + self._bar = bar self._baz = baz + @property def bar(self): """ @@ -65,6 +66,18 @@ class ReadOnlyFirst(object): """ return self._bar + @bar.setter + def bar(self, bar): + """ + Sets the bar of this ReadOnlyFirst. + + + :param bar: The bar of this ReadOnlyFirst. + :type: str + """ + + self._bar = bar + @property def baz(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/special_model_name.py b/samples/client/petstore/python/petstore_api/models/special_model_name.py index 237f6d7ceebb..ca969d09df1d 100644 --- a/samples/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python/petstore_api/models/special_model_name.py @@ -51,6 +51,7 @@ class SpecialModelName(object): self._special_property_name = special_property_name + @property def special_property_name(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/tag.py b/samples/client/petstore/python/petstore_api/models/tag.py index cb5b0ea93ac2..b898b80e4010 100644 --- a/samples/client/petstore/python/petstore_api/models/tag.py +++ b/samples/client/petstore/python/petstore_api/models/tag.py @@ -54,6 +54,7 @@ class Tag(object): self._id = id self._name = name + @property def id(self): """ diff --git a/samples/client/petstore/python/petstore_api/models/user.py b/samples/client/petstore/python/petstore_api/models/user.py index 93dbd5884d86..2f504292ff82 100644 --- a/samples/client/petstore/python/petstore_api/models/user.py +++ b/samples/client/petstore/python/petstore_api/models/user.py @@ -72,6 +72,7 @@ class User(object): self._phone = phone self._user_status = user_status + @property def id(self): """ diff --git a/samples/client/petstore/python/test/test_enum_arrays.py b/samples/client/petstore/python/test/test_enum_arrays.py new file mode 100644 index 000000000000..ba9c899530b1 --- /dev/null +++ b/samples/client/petstore/python/test/test_enum_arrays.py @@ -0,0 +1,53 @@ +# 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 + + 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 os +import sys +import unittest + +import petstore_api +from petstore_api.rest import ApiException +from petstore_api.models.enum_arrays import EnumArrays + + +class TestEnumArrays(unittest.TestCase): + """ EnumArrays unit test stubs """ + + def setUp(self): + pass + + def tearDown(self): + pass + + def testEnumArrays(self): + """ + Test EnumArrays + """ + model = petstore_api.models.enum_arrays.EnumArrays() + + +if __name__ == '__main__': + unittest.main()