forked from loafle/openapi-generator-original
* add project name to setup.py in python client * update python README to use project name * add cli option project name for python
126 lines
4.4 KiB
Plaintext
126 lines
4.4 KiB
Plaintext
# {{{projectName}}}
|
|
{{#appDescription}}
|
|
{{{appDescription}}}
|
|
{{/appDescription}}
|
|
|
|
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
|
|
|
- API version: {{appVersion}}
|
|
- Package version: {{packageVersion}}
|
|
{{^hideGenerationTimestamp}}
|
|
- Build date: {{generatedDate}}
|
|
{{/hideGenerationTimestamp}}
|
|
- Build package: {{generatorClass}}
|
|
{{#infoUrl}}
|
|
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
|
{{/infoUrl}}
|
|
|
|
## Requirements.
|
|
|
|
Python 2.7 and 3.4+
|
|
|
|
## Installation & Usage
|
|
### pip install
|
|
|
|
If the python package is hosted on Github, you can install directly from Github
|
|
|
|
```sh
|
|
pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git
|
|
```
|
|
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`)
|
|
|
|
Then import the package:
|
|
```python
|
|
import {{{packageName}}}
|
|
```
|
|
|
|
### Setuptools
|
|
|
|
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
|
|
|
|
```sh
|
|
python setup.py install --user
|
|
```
|
|
(or `sudo python setup.py install` to install the package for all users)
|
|
|
|
Then import the package:
|
|
```python
|
|
import {{{packageName}}}
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
Please follow the [installation procedure](#installation--usage) and then run the following:
|
|
|
|
```python
|
|
from __future__ import print_function
|
|
import time
|
|
import {{{packageName}}}
|
|
from {{{packageName}}}.rest import ApiException
|
|
from pprint import pprint
|
|
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
|
# Configure HTTP basic authorization: {{{name}}}
|
|
{{{packageName}}}.configuration.username = 'YOUR_USERNAME'
|
|
{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}}
|
|
# Configure API key authorization: {{{name}}}
|
|
{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
|
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
|
|
# Configure OAuth2 access token for authorization: {{{name}}}
|
|
{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}}
|
|
{{/hasAuthMethods}}
|
|
# create an instance of the API class
|
|
api_instance = {{{packageName}}}.{{{classname}}}()
|
|
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
{{/allParams}}
|
|
|
|
try:
|
|
{{#summary}} # {{{.}}}
|
|
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
|
|
pprint(api_response){{/returnType}}
|
|
except ApiException as e:
|
|
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
|
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
|
```
|
|
|
|
## Documentation for API Endpoints
|
|
|
|
All URIs are relative to *{{basePath}}*
|
|
|
|
Class | Method | HTTP request | Description
|
|
------------ | ------------- | ------------- | -------------
|
|
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
|
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
|
|
|
## Documentation For Models
|
|
|
|
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
|
{{/model}}{{/models}}
|
|
|
|
## Documentation For Authorization
|
|
|
|
{{^authMethods}} All endpoints do not require authorization.
|
|
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
|
{{#authMethods}}## {{{name}}}
|
|
|
|
{{#isApiKey}}- **Type**: API key
|
|
- **API key parameter name**: {{{keyParamName}}}
|
|
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
|
{{/isApiKey}}
|
|
{{#isBasic}}- **Type**: HTTP basic authentication
|
|
{{/isBasic}}
|
|
{{#isOAuth}}- **Type**: OAuth
|
|
- **Flow**: {{{flow}}}
|
|
- **Authorization URL**: {{{authorizationUrl}}}
|
|
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
|
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
|
{{/scopes}}
|
|
{{/isOAuth}}
|
|
|
|
{{/authMethods}}
|
|
|
|
## Author
|
|
|
|
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
|
{{/hasMore}}{{/apis}}{{/apiInfo}}
|