update python samples

This commit is contained in:
wing328 2015-08-23 17:20:30 +08:00
parent 2251a2f892
commit a7c08e680c
18 changed files with 126 additions and 48 deletions

Binary file not shown.

View File

@ -0,0 +1,15 @@
Collecting nose (from -r dev-requirements.txt (line 1))
Using cached nose-1.3.7-py2-none-any.whl
Collecting tox (from -r dev-requirements.txt (line 2))
Using cached tox-2.1.1-py2.py3-none-any.whl
Collecting coverage (from -r dev-requirements.txt (line 3))
Collecting randomize (from -r dev-requirements.txt (line 4))
Using cached randomize-0.13-py2.py3-none-any.whl
Collecting virtualenv>=1.11.2 (from tox->-r dev-requirements.txt (line 2))
Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Collecting py>=1.4.17 (from tox->-r dev-requirements.txt (line 2))
Using cached py-1.4.30-py2.py3-none-any.whl
Collecting pluggy<0.4.0,>=0.3.0 (from tox->-r dev-requirements.txt (line 2))
Using cached pluggy-0.3.0-py2.py3-none-any.whl
Installing collected packages: nose, virtualenv, py, pluggy, tox, coverage, randomize
Successfully installed coverage-3.7.1 nose-1.3.7 pluggy-0.3.0 py-1.4.30 randomize-0.13 tox-2.1.1 virtualenv-13.1.2

View File

@ -8,13 +8,11 @@ VERSION = "1.0.0"
# To install the library, open a Terminal shell, then run this
# file by typing:
# To install the library, run the following
#
# python setup.py install
#
# You need to have the setuptools module installed.
# Try reading the setuptools documentation:
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi", "python-dateutil"]

View File

@ -0,0 +1,12 @@
Metadata-Version: 1.0
Name: swagger-client
Version: 1.0.0
Summary: Swagger Petstore
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: apiteam@swagger.io
License: UNKNOWN
Description: This is a sample server Petstore server. You can find out more about Swagger at &lt;a href=\&quot;http://swagger.io\&quot;&gt;http://swagger.io&lt;/a&gt; or on irc.freenode.net, #swagger. For this sample, you can use the api key \&quot;special-key\&quot; to test the authorization filters
Keywords: Swagger,Swagger Petstore
Platform: UNKNOWN

View File

@ -0,0 +1,29 @@
setup.cfg
setup.py
swagger_client/__init__.py
swagger_client/api_client.py
swagger_client/configuration.py
swagger_client/rest.py
swagger_client.egg-info/PKG-INFO
swagger_client.egg-info/SOURCES.txt
swagger_client.egg-info/dependency_links.txt
swagger_client.egg-info/requires.txt
swagger_client.egg-info/top_level.txt
swagger_client/apis/__init__.py
swagger_client/apis/pet_api.py
swagger_client/apis/store_api.py
swagger_client/apis/user_api.py
swagger_client/models/__init__.py
swagger_client/models/category.py
swagger_client/models/order.py
swagger_client/models/pet.py
swagger_client/models/tag.py
swagger_client/models/user.py
tests/__init__.py
tests/test_api_client.py
tests/test_api_exception.py
tests/test_deserialization.py
tests/test_order_model.py
tests/test_pet_api.py
tests/test_pet_model.py
tests/test_store_api.py

View File

@ -0,0 +1,4 @@
urllib3 >= 1.10
six >= 1.9
certifi
python-dateutil

View File

@ -0,0 +1,2 @@
swagger_client
tests

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -56,7 +58,7 @@ class ApiClient(object):
templates.
NOTE: This class is auto generated by the swagger code generator program.
https://github.com/swagger-api/swagger-codegen
Ref: https://github.com/swagger-api/swagger-codegen
Do not edit the class manually.
:param host: The base path for the server to call.
@ -75,7 +77,7 @@ class ApiClient(object):
self.host = host
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Python-Swagger'
self.user_agent = 'Python-Swagger/1.0.0'
@property
def user_agent(self):
@ -280,7 +282,8 @@ class ApiClient(object):
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, callback=None):
"""
Makes the HTTP request and return the deserialized data.
Makes the HTTP request (synchronous) and return the deserialized data.
To make an async request, define a function for callback.
:param resource_path: Path to method endpoint.
:param method: Method to call.
@ -450,9 +453,8 @@ class ApiClient(object):
def __deserialize_file(self, response):
"""
Saves response body into a file in (the defined) temporary folder,
using the filename from the `Content-Disposition` header if provided,
otherwise a random filename.
Saves response body into a file in a temporary folder,
using the filename from the `Content-Disposition` header if provided.
:param response: RESTResponse.
:return: file path.

View File

@ -33,6 +33,7 @@ class PetApi(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
@ -49,7 +50,7 @@ class PetApi(object):
Update an existing pet
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -124,7 +125,7 @@ class PetApi(object):
Add a new pet to the store
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -199,7 +200,7 @@ class PetApi(object):
Finds Pets by status
Multiple status values can be provided with comma seperated strings
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -274,7 +275,7 @@ class PetApi(object):
Finds Pets by tags
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -349,7 +350,7 @@ class PetApi(object):
Find pet by ID
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -427,7 +428,7 @@ class PetApi(object):
Updates a pet in the store with form data
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -511,7 +512,7 @@ class PetApi(object):
Deletes a pet
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -592,7 +593,7 @@ class PetApi(object):
uploads an image
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):

View File

@ -33,6 +33,7 @@ class StoreApi(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
@ -49,7 +50,7 @@ class StoreApi(object):
Returns pet inventories by status
Returns a map of status codes to quantities
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -121,7 +122,7 @@ class StoreApi(object):
Place an order for a pet
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -196,7 +197,7 @@ class StoreApi(object):
Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -274,7 +275,7 @@ class StoreApi(object):
Delete purchase order by ID
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):

View File

@ -33,6 +33,7 @@ class UserApi(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
@ -49,7 +50,7 @@ class UserApi(object):
Create user
This can only be done by the logged in user.
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -124,7 +125,7 @@ class UserApi(object):
Creates list of users with given input array
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -199,7 +200,7 @@ class UserApi(object):
Creates list of users with given input array
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -274,7 +275,7 @@ class UserApi(object):
Logs user into the system
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -352,7 +353,7 @@ class UserApi(object):
Logs out current logged in user session
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -424,7 +425,7 @@ class UserApi(object):
Get user by user name
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -502,7 +503,7 @@ class UserApi(object):
Updated user
This can only be done by the logged in user.
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
@ -583,7 +584,7 @@ class UserApi(object):
Delete user
This can only be done by the logged in user.
This method makes a synchronous HTTP request by default.To make an
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -44,7 +46,7 @@ def singleton(cls, *args, **kw):
class Configuration(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
https://github.com/swagger-api/swagger-codegen
Ref: https://github.com/swagger-api/swagger-codegen
Do not edit the class manually.
"""
@ -56,7 +58,7 @@ class Configuration(object):
self.host = "http://petstore.swagger.io/v2"
# Default api client
self.api_client = None
# Temp file folder for download
# Temp file folder for downloading files
self.temp_folder_path = None
# Authentication Settings
@ -139,7 +141,7 @@ class Configuration(object):
def get_basic_auth_token(self):
"""
Gets basic auth header string.
Gets HTTP basic authentication header (string).
:return: The token for basic HTTP authentication.
"""

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -27,7 +29,7 @@ class Category(object):
"""
def __init__(self):
"""
Swagger model
Category - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
@ -93,7 +95,7 @@ class Category(object):
def to_dict(self):
"""
Return model properties dict
Returns the model properties as a dict
"""
result = {}
@ -113,7 +115,7 @@ class Category(object):
def to_str(self):
"""
Return model properties str
Returns the string representation of the model
"""
return pformat(self.to_dict())

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -27,7 +29,7 @@ class Order(object):
"""
def __init__(self):
"""
Swagger model
Order - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
@ -199,7 +201,7 @@ class Order(object):
def to_dict(self):
"""
Return model properties dict
Returns the model properties as a dict
"""
result = {}
@ -219,7 +221,7 @@ class Order(object):
def to_str(self):
"""
Return model properties str
Returns the string representation of the model
"""
return pformat(self.to_dict())

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -27,7 +29,7 @@ class Pet(object):
"""
def __init__(self):
"""
Swagger model
Pet - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
@ -199,7 +201,7 @@ class Pet(object):
def to_dict(self):
"""
Return model properties dict
Returns the model properties as a dict
"""
result = {}
@ -219,7 +221,7 @@ class Pet(object):
def to_str(self):
"""
Return model properties str
Returns the string representation of the model
"""
return pformat(self.to_dict())

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -27,7 +29,7 @@ class Tag(object):
"""
def __init__(self):
"""
Swagger model
Tag - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
@ -93,7 +95,7 @@ class Tag(object):
def to_dict(self):
"""
Return model properties dict
Returns the model properties as a dict
"""
result = {}
@ -113,7 +115,7 @@ class Tag(object):
def to_str(self):
"""
Return model properties str
Returns the string representation of the model
"""
return pformat(self.to_dict())

View File

@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software
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
@ -27,7 +29,7 @@ class User(object):
"""
def __init__(self):
"""
Swagger model
User - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
@ -243,7 +245,7 @@ class User(object):
def to_dict(self):
"""
Return model properties dict
Returns the model properties as a dict
"""
result = {}
@ -263,7 +265,7 @@ class User(object):
def to_str(self):
"""
Return model properties str
Returns the string representation of the model
"""
return pformat(self.to_dict())