package python sdk using setuptools

This commit is contained in:
geekerzp
2015-04-09 17:56:49 +08:00
parent 70c14092f9
commit e6bf58a707
17 changed files with 154 additions and 56 deletions

View File

@@ -1,25 +1,42 @@
# Swagger Generated Python client
## Requirements.
Python 2.7 and later.
## Setuptools
You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools).
Usage example, based on the swagger petstore:
```sh
python setup.py install
```
Or you can install from Github via pip:
```sh
pip install git+https://github.com/geekerzp/SwaggerPetstore-python.git
```
To use the bindings, import the pacakge:
```python
# include the client module
from client import *
# build a client connection. In this example, we are passing the hostname as arg0, and
# sending a header with name `api_key` and value `special-key` on each call to the api.
client = swagger.ApiClient('http://petstore.swagger.io/v2', 'api_key', 'special-key')
# create the PetApi class with the client we just created
petApi = PetApi.PetApi(client)
# call the API and fetch a pet, with petId=3
pet = petApi.getPetById(petId=3)
# write it into pretty JSON
json = client.sanitizeForSerialization(pet)
print json
{'category': {'category': None, 'status': None, 'name': 'string', 'tags': None, 'photoUrls': None, 'id': 0L}, 'status': {'category': None, 'status': None, 'name': None, 'tags': None, 'photoUrls': None, 'id': None}, 'name': 'foogly', 'tags': [{'id': 0L, 'name': 'string'}], 'photoUrls': ['string'], 'id': 3L}
import SwaggerPetstore
```
## Manual Installation
If you do not wish to use setuptools, you can download the latest release.
Then, to use the bindings, import the package:
```python
import path.to.SwaggerPetstore-python.SwaggerPetstore
```
## Getting Started
TODO
## Documentation
TODO
## Tests
TODO

View File

@@ -0,0 +1,32 @@
import sys
from setuptools import setup, find_packages
{{#apiInfo}}{{#apis}}{{^hasMore}}
# To install the library, open a Terminal shell, then run this
# file by typing:
#
# python setup.py install
#
# You need to have the setuptools module installed.
# Try reading the setuptools documentation:
# http://pypi.python.org/pypi/setuptools
REQUIRES = []
setup(
name="{{module}}",
version="{{version}}",
description="{{appName}}",
author_email="{{infoEmail}}",
url="{{infoUrl}}",
keywords=["Swagger", "{{appName}}"],
install_requires=REQUIRES,
packages=find_packages(),
include_package_data=True,
long_description="""\
{{appDescription}}
"""
)
{{/hasMore}}{{/apis}}{{/apiInfo}}