Skip to content

Commit 0569423

Browse files
committed
feat(openapi): write openapi generator template
The template is mostly canibalized from the openapi-generator repository so full credits to them: https://github.com/OpenAPITools/openapi-generator.
0 parents  commit 0569423

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+5624
-0
lines changed

.openapi-generator/config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"packageName": "pollination_sdk",
3+
"projectName": "pollination-sdk",
4+
"packageUrl": "https://github.com/pollination/python-sdk"
5+
}

.openapi-generator/generate.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
npx openapi-generator generate \
4+
-i https://api.pollination.cloud/sdk_openapi.json \
5+
-t .openapi-generator/templates/python \
6+
-g python \
7+
-o . \
8+
--skip-validate-spec \
9+
-c .openapi-generator/config.json
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CD
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
name: "Deploy to PyPi server"
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v1
14+
# - name: Publish package to TestPyPI
15+
# uses: pypa/gh-action-pypi-publish@master
16+
# with:
17+
# user: ${{ secrets.PYPI_USER }}
18+
# password: ${{ secrets.PYPI_PASSWORD }}
19+
# repository_url: https://some.private.repo.org/legacy/
20+
21+
# Change values above once a private repo has been set up
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# {{{projectName}}}
2+
3+
{{#appDescription}}
4+
{{{appDescription}}}
5+
{{/appDescription}}
6+
7+
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
8+
9+
- API version: {{appVersion}}
10+
{{^hideGenerationTimestamp}}
11+
- Build date: {{generatedDate}}
12+
{{/hideGenerationTimestamp}}
13+
- Build package: {{generatorClass}}
14+
{{#infoUrl}}
15+
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
16+
{{/infoUrl}}
17+
18+
## Requirements
19+
20+
Python 2.7 and 3.4+
21+
22+
## Installation & Usage
23+
24+
### pip install
25+
26+
The default way to install `{{{projectName}}}` is through PyPi as follows:
27+
28+
```sh
29+
pip install {{{projectName}}}
30+
```
31+
32+
If you need a specific branch you can install straight from the repository using:
33+
34+
```sh
35+
pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git
36+
```
37+
(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`)
38+
39+
Then import the package:
40+
```python
41+
import {{{packageName}}}
42+
```
43+
44+
### Setuptools
45+
46+
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
47+
48+
```sh
49+
python setup.py install --user
50+
```
51+
(or `sudo python setup.py install` to install the package for all users)
52+
53+
Then import the package:
54+
```python
55+
import {{{packageName}}}
56+
```
57+
58+
## Getting Started
59+
60+
Please follow the [installation procedure](#installation--usage) and then run the following:
61+
62+
{{> common_README }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# {{{projectName}}}
2+
{{#appDescription}}
3+
{{{appDescription}}}
4+
{{/appDescription}}
5+
6+
The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
7+
8+
- API version: {{appVersion}}
9+
- Package version: {{packageVersion}}
10+
{{^hideGenerationTimestamp}}
11+
- Build date: {{generatedDate}}
12+
{{/hideGenerationTimestamp}}
13+
- Build package: {{generatorClass}}
14+
{{#infoUrl}}
15+
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
16+
{{/infoUrl}}
17+
18+
## Requirements.
19+
20+
Python 2.7 and 3.4+
21+
22+
## Installation & Usage
23+
24+
This python library package is generated without supporting files like setup.py or requirements files
25+
26+
To be able to use it, you will need these dependencies in your own package that uses this library:
27+
28+
* urllib3 >= 1.15
29+
* six >= 1.10
30+
* certifi
31+
* python-dateutil
32+
{{#asyncio}}
33+
* aiohttp
34+
{{/asyncio}}
35+
{{#tornado}}
36+
* tornado>=4.2,<5
37+
{{/tornado}}
38+
39+
## Getting Started
40+
41+
In your own code, to use this library to connect and interact with {{{projectName}}},
42+
you can run the following:
43+
44+
{{> common_README }}

.openapi-generator/templates/python/__init__.mustache

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import absolute_import
2+
3+
# flake8: noqa
4+
5+
# import apis into api package
6+
{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}}
7+
{{/apis}}{{/apiInfo}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# coding: utf-8
2+
3+
# flake8: noqa
4+
{{>partial_header}}
5+
6+
from __future__ import absolute_import
7+
8+
# import models into model package
9+
{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}}
10+
{{/models}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# coding: utf-8
2+
3+
# flake8: noqa
4+
5+
{{>partial_header}}
6+
7+
from __future__ import absolute_import
8+
9+
__version__ = "{{packageVersion}}"
10+
11+
# import apis into sdk package
12+
{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}}
13+
{{/apis}}{{/apiInfo}}
14+
# import ApiClient
15+
from {{packageName}}.api_client import ApiClient
16+
from {{packageName}}.configuration import Configuration
17+
from {{packageName}}.exceptions import OpenApiException
18+
from {{packageName}}.exceptions import ApiTypeError
19+
from {{packageName}}.exceptions import ApiValueError
20+
from {{packageName}}.exceptions import ApiKeyError
21+
from {{packageName}}.exceptions import ApiException
22+
# import models into sdk package
23+
{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}
24+
{{/model}}{{/models}}

0 commit comments

Comments
 (0)