forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Python][Client] pure library client package (OpenAPITools#470)
* Python client pure library package * check onlyPackage CLI option * run /bin/python-petstore.sh, update the python samples for CI * onlyPackage local variable instead of classp property * fix CI: __future__ absolute_import must be first in file * update samples * generateSourceCodeOnly * updated samples
- Loading branch information
Showing
21 changed files
with
223 additions
and
140 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/openapi-generator/src/main/resources/python/README_onlypackage.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# {{{projectName}}} | ||
{{#appDescription}} | ||
{{{appDescription}}} | ||
{{/appDescription}} | ||
|
||
The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) 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 | ||
|
||
This python library package is generated without supporting files like setup.py or requirements files | ||
|
||
To be able to use it, you will need these dependencies in your own package that uses this library: | ||
|
||
* urllib3 >= 1.15 | ||
* six >= 1.10 | ||
* certifi | ||
* python-dateutil | ||
{{#asyncio}} | ||
* aiohttp | ||
{{/asyncio}} | ||
{{#tornado}} | ||
* tornado>=4.2,<5 | ||
{{/tornado}} | ||
|
||
## Getting Started | ||
|
||
In your own code, to use this library to connect and interact with {{{projectName}}}, | ||
you can run the following: | ||
|
||
{{> common_README }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
modules/openapi-generator/src/main/resources/python/common_README.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
```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}}} | ||
configuration = {{{packageName}}}.Configuration() | ||
configuration.username = 'YOUR_USERNAME' | ||
configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} | ||
# Configure API key authorization: {{{name}}} | ||
configuration = {{{packageName}}}.Configuration() | ||
configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' | ||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed | ||
# configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} | ||
# Configure OAuth2 access token for authorization: {{{name}}} | ||
configuration = {{{packageName}}}.Configuration() | ||
configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} | ||
{{/hasAuthMethods}} | ||
|
||
# create an instance of the API class | ||
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) | ||
{{#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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,3 +179,4 @@ Class | Method | HTTP request | Description | |
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.