mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 16:40:56 +00:00
Merge pull request #3591 from scottrw93/read-only-fix
Create setter for models inline with Issue 3210
This commit is contained in:
commit
7a49f96a03
@ -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):
|
||||
"""
|
||||
|
@ -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
|
||||
|
||||
|
11
samples/client/petstore/python/docs/EnumArrays.md
Normal file
11
samples/client/petstore/python/docs/EnumArrays.md
Normal file
@ -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)
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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']))
|
||||
|
||||
|
@ -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')
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -54,6 +54,7 @@ class Animal(object):
|
||||
self._class_name = class_name
|
||||
self._color = color
|
||||
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
"""
|
||||
|
@ -49,6 +49,7 @@ class AnimalFarm(object):
|
||||
|
||||
}
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
|
@ -57,6 +57,7 @@ class ApiResponse(object):
|
||||
self._type = type
|
||||
self._message = message
|
||||
|
||||
|
||||
@property
|
||||
def code(self):
|
||||
"""
|
||||
|
@ -51,6 +51,7 @@ class ArrayOfArrayOfNumberOnly(object):
|
||||
|
||||
self._array_array_number = array_array_number
|
||||
|
||||
|
||||
@property
|
||||
def array_array_number(self):
|
||||
"""
|
||||
|
@ -51,6 +51,7 @@ class ArrayOfNumberOnly(object):
|
||||
|
||||
self._array_number = array_number
|
||||
|
||||
|
||||
@property
|
||||
def array_number(self):
|
||||
"""
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -57,6 +57,7 @@ class Cat(object):
|
||||
self._color = color
|
||||
self._declawed = declawed
|
||||
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
"""
|
||||
|
@ -54,6 +54,7 @@ class Category(object):
|
||||
self._id = id
|
||||
self._name = name
|
||||
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
|
@ -51,6 +51,7 @@ class Client(object):
|
||||
|
||||
self._client = client
|
||||
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
"""
|
||||
|
@ -57,6 +57,7 @@ class Dog(object):
|
||||
self._color = color
|
||||
self._breed = breed
|
||||
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
"""
|
||||
|
@ -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
|
@ -49,6 +49,7 @@ class EnumClass(object):
|
||||
|
||||
}
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Returns the model properties as a dict
|
||||
|
@ -57,6 +57,7 @@ class EnumTest(object):
|
||||
self._enum_integer = enum_integer
|
||||
self._enum_number = enum_number
|
||||
|
||||
|
||||
@property
|
||||
def enum_string(self):
|
||||
"""
|
||||
|
@ -87,6 +87,7 @@ class FormatTest(object):
|
||||
self._uuid = uuid
|
||||
self._password = password
|
||||
|
||||
|
||||
@property
|
||||
def integer(self):
|
||||
"""
|
||||
|
@ -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
|
||||
|
@ -51,6 +51,7 @@ class List(object):
|
||||
|
||||
self.__123_list = _123_list
|
||||
|
||||
|
||||
@property
|
||||
def _123_list(self):
|
||||
"""
|
||||
|
@ -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}"
|
||||
|
@ -57,6 +57,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(object):
|
||||
self._date_time = date_time
|
||||
self._map = map
|
||||
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
"""
|
||||
|
@ -54,6 +54,7 @@ class Model200Response(object):
|
||||
self._name = name
|
||||
self.__class = _class
|
||||
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
|
@ -51,6 +51,7 @@ class ModelReturn(object):
|
||||
|
||||
self.__return = _return
|
||||
|
||||
|
||||
@property
|
||||
def _return(self):
|
||||
"""
|
||||
|
@ -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
|
||||
|
@ -51,6 +51,7 @@ class NumberOnly(object):
|
||||
|
||||
self._just_number = just_number
|
||||
|
||||
|
||||
@property
|
||||
def just_number(self):
|
||||
"""
|
||||
|
@ -66,6 +66,7 @@ class Order(object):
|
||||
self._status = status
|
||||
self._complete = complete
|
||||
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
|
@ -66,6 +66,7 @@ class Pet(object):
|
||||
self._tags = tags
|
||||
self._status = status
|
||||
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -51,6 +51,7 @@ class SpecialModelName(object):
|
||||
|
||||
self._special_property_name = special_property_name
|
||||
|
||||
|
||||
@property
|
||||
def special_property_name(self):
|
||||
"""
|
||||
|
@ -54,6 +54,7 @@ class Tag(object):
|
||||
self._id = id
|
||||
self._name = name
|
||||
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
|
@ -72,6 +72,7 @@ class User(object):
|
||||
self._phone = phone
|
||||
self._user_status = user_status
|
||||
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
|
53
samples/client/petstore/python/test/test_enum_arrays.py
Normal file
53
samples/client/petstore/python/test/test_enum_arrays.py
Normal file
@ -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()
|
Loading…
x
Reference in New Issue
Block a user