forked from loafle/openapi-generator-original
Merge pull request #3034 from taxpon/issue-3029-python-constructor
Update python constrouctor to provide arguments for instance initialization
This commit is contained in:
@@ -44,6 +44,8 @@ nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
venv/
|
||||
.python-version
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
@@ -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):
|
||||
def __init__(self{{#readWriteVars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/readWriteVars}}):
|
||||
"""
|
||||
{{classname}} - a model defined in Swagger
|
||||
|
||||
@@ -33,9 +33,12 @@ class {{classname}}(object):
|
||||
{{/hasMore}}{{/vars}}
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
{{#readOnlyVars}}
|
||||
self._{{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}
|
||||
{{/vars}}
|
||||
{{/readOnlyVars}}
|
||||
{{#readWriteVars}}
|
||||
self._{{name}} = {{name}}
|
||||
{{/readWriteVars}}
|
||||
{{#vars}}{{#-first}}
|
||||
{{/-first}}
|
||||
@property
|
||||
@@ -49,6 +52,7 @@ class {{classname}}(object):
|
||||
"""
|
||||
return self._{{name}}
|
||||
|
||||
{{^isReadOnly}}
|
||||
@{{name}}.setter
|
||||
def {{name}}(self, {{name}}):
|
||||
"""
|
||||
@@ -96,6 +100,7 @@ class {{classname}}(object):
|
||||
|
||||
self._{{name}} = {{name}}
|
||||
|
||||
{{/isReadOnly}}
|
||||
{{/vars}}
|
||||
def to_dict(self):
|
||||
"""
|
||||
|
||||
2
samples/client/petstore/python/.gitignore
vendored
2
samples/client/petstore/python/.gitignore
vendored
@@ -44,6 +44,8 @@ nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
venv/
|
||||
.python-version
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# swagger_client
|
||||
# petstore_api
|
||||
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-06-08T10:26:51.066+08:00
|
||||
- Build date: 2016-06-09T08:00:02.342+09:00
|
||||
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
|
||||
|
||||
## Requirements.
|
||||
@@ -24,7 +24,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import swagger_client
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
@@ -38,7 +38,7 @@ python setup.py install --user
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import swagger_client
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
@@ -47,11 +47,11 @@ Please follow the [installation procedure](#installation--usage) and then run th
|
||||
|
||||
```python
|
||||
import time
|
||||
import swagger_client
|
||||
from swagger_client.rest import ApiException
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# create an instance of the API class
|
||||
api_instance = swagger_client.FakeApi
|
||||
api_instance = petstore_api.FakeApi
|
||||
number = 3.4 # float | None
|
||||
double = 1.2 # float | None
|
||||
string = 'string_example' # str | None
|
||||
@@ -130,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
|
||||
@@ -145,6 +139,12 @@ Class | Method | HTTP request | Description
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
## api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
@@ -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,13 @@ class Configuration(object):
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
},
|
||||
'api_key':
|
||||
{
|
||||
'type': 'api_key',
|
||||
'in': 'header',
|
||||
'key': 'api_key',
|
||||
'value': self.get_api_key_with_prefix('api_key')
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class AdditionalPropertiesClass(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, map_property=None, map_of_map_property=None):
|
||||
"""
|
||||
AdditionalPropertiesClass - a model defined in Swagger
|
||||
|
||||
@@ -51,8 +51,8 @@ class AdditionalPropertiesClass(object):
|
||||
'map_of_map_property': 'map_of_map_property'
|
||||
}
|
||||
|
||||
self._map_property = None
|
||||
self._map_of_map_property = None
|
||||
self._map_property = map_property
|
||||
self._map_of_map_property = map_of_map_property
|
||||
|
||||
@property
|
||||
def map_property(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Animal(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, class_name=None, color='red'):
|
||||
"""
|
||||
Animal - a model defined in Swagger
|
||||
|
||||
@@ -51,8 +51,8 @@ class Animal(object):
|
||||
'color': 'color'
|
||||
}
|
||||
|
||||
self._class_name = None
|
||||
self._color = 'red'
|
||||
self._class_name = class_name
|
||||
self._color = color
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class ApiResponse(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, code=None, type=None, message=None):
|
||||
"""
|
||||
ApiResponse - a model defined in Swagger
|
||||
|
||||
@@ -53,9 +53,9 @@ class ApiResponse(object):
|
||||
'message': 'message'
|
||||
}
|
||||
|
||||
self._code = None
|
||||
self._type = None
|
||||
self._message = None
|
||||
self._code = code
|
||||
self._type = type
|
||||
self._message = message
|
||||
|
||||
@property
|
||||
def code(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class ArrayTest(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, array_of_string=None, array_array_of_integer=None, array_array_of_model=None):
|
||||
"""
|
||||
ArrayTest - a model defined in Swagger
|
||||
|
||||
@@ -53,9 +53,9 @@ class ArrayTest(object):
|
||||
'array_array_of_model': 'array_array_of_model'
|
||||
}
|
||||
|
||||
self._array_of_string = None
|
||||
self._array_array_of_integer = None
|
||||
self._array_array_of_model = None
|
||||
self._array_of_string = array_of_string
|
||||
self._array_array_of_integer = array_array_of_integer
|
||||
self._array_array_of_model = array_array_of_model
|
||||
|
||||
@property
|
||||
def array_of_string(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Cat(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, class_name=None, color='red', declawed=None):
|
||||
"""
|
||||
Cat - a model defined in Swagger
|
||||
|
||||
@@ -53,9 +53,9 @@ class Cat(object):
|
||||
'declawed': 'declawed'
|
||||
}
|
||||
|
||||
self._class_name = None
|
||||
self._color = 'red'
|
||||
self._declawed = None
|
||||
self._class_name = class_name
|
||||
self._color = color
|
||||
self._declawed = declawed
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Category(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, id=None, name=None):
|
||||
"""
|
||||
Category - a model defined in Swagger
|
||||
|
||||
@@ -51,8 +51,8 @@ class Category(object):
|
||||
'name': 'name'
|
||||
}
|
||||
|
||||
self._id = None
|
||||
self._name = None
|
||||
self._id = id
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Dog(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, class_name=None, color='red', breed=None):
|
||||
"""
|
||||
Dog - a model defined in Swagger
|
||||
|
||||
@@ -53,9 +53,9 @@ class Dog(object):
|
||||
'breed': 'breed'
|
||||
}
|
||||
|
||||
self._class_name = None
|
||||
self._color = 'red'
|
||||
self._breed = None
|
||||
self._class_name = class_name
|
||||
self._color = color
|
||||
self._breed = breed
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class EnumTest(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, enum_string=None, enum_integer=None, enum_number=None):
|
||||
"""
|
||||
EnumTest - a model defined in Swagger
|
||||
|
||||
@@ -53,9 +53,9 @@ class EnumTest(object):
|
||||
'enum_number': 'enum_number'
|
||||
}
|
||||
|
||||
self._enum_string = None
|
||||
self._enum_integer = None
|
||||
self._enum_number = None
|
||||
self._enum_string = enum_string
|
||||
self._enum_integer = enum_integer
|
||||
self._enum_number = enum_number
|
||||
|
||||
@property
|
||||
def enum_string(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class FormatTest(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, integer=None, int32=None, int64=None, number=None, float=None, double=None, string=None, byte=None, binary=None, date=None, date_time=None, uuid=None, password=None):
|
||||
"""
|
||||
FormatTest - a model defined in Swagger
|
||||
|
||||
@@ -73,19 +73,19 @@ class FormatTest(object):
|
||||
'password': 'password'
|
||||
}
|
||||
|
||||
self._integer = None
|
||||
self._int32 = None
|
||||
self._int64 = None
|
||||
self._number = None
|
||||
self._float = None
|
||||
self._double = None
|
||||
self._string = None
|
||||
self._byte = None
|
||||
self._binary = None
|
||||
self._date = None
|
||||
self._date_time = None
|
||||
self._uuid = None
|
||||
self._password = None
|
||||
self._integer = integer
|
||||
self._int32 = int32
|
||||
self._int64 = int64
|
||||
self._number = number
|
||||
self._float = float
|
||||
self._double = double
|
||||
self._string = string
|
||||
self._byte = byte
|
||||
self._binary = binary
|
||||
self._date = date
|
||||
self._date_time = date_time
|
||||
self._uuid = uuid
|
||||
self._password = password
|
||||
|
||||
@property
|
||||
def integer(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(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, uuid=None, date_time=None, map=None):
|
||||
"""
|
||||
MixedPropertiesAndAdditionalPropertiesClass - a model defined in Swagger
|
||||
|
||||
@@ -53,9 +53,9 @@ class MixedPropertiesAndAdditionalPropertiesClass(object):
|
||||
'map': 'map'
|
||||
}
|
||||
|
||||
self._uuid = None
|
||||
self._date_time = None
|
||||
self._map = None
|
||||
self._uuid = uuid
|
||||
self._date_time = date_time
|
||||
self._map = map
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Model200Response(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, name=None):
|
||||
"""
|
||||
Model200Response - a model defined in Swagger
|
||||
|
||||
@@ -49,7 +49,7 @@ class Model200Response(object):
|
||||
'name': 'name'
|
||||
}
|
||||
|
||||
self._name = None
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class ModelReturn(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, _return=None):
|
||||
"""
|
||||
ModelReturn - a model defined in Swagger
|
||||
|
||||
@@ -49,7 +49,7 @@ class ModelReturn(object):
|
||||
'_return': 'return'
|
||||
}
|
||||
|
||||
self.__return = None
|
||||
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):
|
||||
def __init__(self, name=None, _property=None):
|
||||
"""
|
||||
Name - a model defined in Swagger
|
||||
|
||||
@@ -55,10 +55,10 @@ class Name(object):
|
||||
'_123_number': '123Number'
|
||||
}
|
||||
|
||||
self._name = None
|
||||
self._snake_case = None
|
||||
self.__property = None
|
||||
self.__123_number = None
|
||||
self._name = name
|
||||
self.__property = _property
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -94,18 +94,6 @@ 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):
|
||||
"""
|
||||
@@ -140,18 +128,6 @@ 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
|
||||
|
||||
@@ -32,7 +32,7 @@ class Order(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, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False):
|
||||
"""
|
||||
Order - a model defined in Swagger
|
||||
|
||||
@@ -59,12 +59,12 @@ class Order(object):
|
||||
'complete': 'complete'
|
||||
}
|
||||
|
||||
self._id = None
|
||||
self._pet_id = None
|
||||
self._quantity = None
|
||||
self._ship_date = None
|
||||
self._status = None
|
||||
self._complete = False
|
||||
self._id = id
|
||||
self._pet_id = pet_id
|
||||
self._quantity = quantity
|
||||
self._ship_date = ship_date
|
||||
self._status = status
|
||||
self._complete = complete
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Pet(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, id=None, category=None, name=None, photo_urls=None, tags=None, status=None):
|
||||
"""
|
||||
Pet - a model defined in Swagger
|
||||
|
||||
@@ -59,12 +59,12 @@ class Pet(object):
|
||||
'status': 'status'
|
||||
}
|
||||
|
||||
self._id = None
|
||||
self._category = None
|
||||
self._name = None
|
||||
self._photo_urls = None
|
||||
self._tags = None
|
||||
self._status = None
|
||||
self._id = id
|
||||
self._category = category
|
||||
self._name = name
|
||||
self._photo_urls = photo_urls
|
||||
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):
|
||||
def __init__(self, baz=None):
|
||||
"""
|
||||
ReadOnlyFirst - a model defined in Swagger
|
||||
|
||||
@@ -52,7 +52,7 @@ class ReadOnlyFirst(object):
|
||||
}
|
||||
|
||||
self._bar = None
|
||||
self._baz = None
|
||||
self._baz = baz
|
||||
|
||||
@property
|
||||
def bar(self):
|
||||
@@ -65,18 +65,6 @@ 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):
|
||||
"""
|
||||
|
||||
@@ -32,7 +32,7 @@ class SpecialModelName(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, special_property_name=None):
|
||||
"""
|
||||
SpecialModelName - a model defined in Swagger
|
||||
|
||||
@@ -49,7 +49,7 @@ class SpecialModelName(object):
|
||||
'special_property_name': '$special[property.name]'
|
||||
}
|
||||
|
||||
self._special_property_name = None
|
||||
self._special_property_name = special_property_name
|
||||
|
||||
@property
|
||||
def special_property_name(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class Tag(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, id=None, name=None):
|
||||
"""
|
||||
Tag - a model defined in Swagger
|
||||
|
||||
@@ -51,8 +51,8 @@ class Tag(object):
|
||||
'name': 'name'
|
||||
}
|
||||
|
||||
self._id = None
|
||||
self._name = None
|
||||
self._id = id
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class User(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, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None):
|
||||
"""
|
||||
User - a model defined in Swagger
|
||||
|
||||
@@ -63,14 +63,14 @@ class User(object):
|
||||
'user_status': 'userStatus'
|
||||
}
|
||||
|
||||
self._id = None
|
||||
self._username = None
|
||||
self._first_name = None
|
||||
self._last_name = None
|
||||
self._email = None
|
||||
self._password = None
|
||||
self._phone = None
|
||||
self._user_status = None
|
||||
self._id = id
|
||||
self._username = username
|
||||
self._first_name = first_name
|
||||
self._last_name = last_name
|
||||
self._email = email
|
||||
self._password = password
|
||||
self._phone = phone
|
||||
self._user_status = user_status
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
|
||||
Reference in New Issue
Block a user