Skip to content

Commit 1ea8bf1

Browse files
authored
Merge pull request #15 from eggplants/improve
Improve codebase
2 parents c3c1486 + 3a7b83b commit 1ea8bf1

12 files changed

Lines changed: 690 additions & 141 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Package
2+
3+
# need to setup:
4+
# secrets.PYPI_API_TOKEN (See: https://pypi.org/help/#apitoken)
5+
# secrets.TESTPYPI_API_TOKEN (See: https://test.pypi.org/help/#apitoken)
6+
7+
on:
8+
# TODO: enable scheduled run
9+
# schedule:
10+
# - cron: 0 0 * * *
11+
workflow_dispatch:
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install poetry
19+
run: pipx install poetry
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.13'
23+
cache: poetry
24+
- name: Setup Poetry to publish
25+
run: |
26+
poetry install --no-interaction
27+
poetry config pypi-token.testpypi '${{ secrets.TESTPYPI_API_TOKEN }}'
28+
poetry config pypi-token.pypi '${{ secrets.PYPI_API_TOKEN }}'
29+
- name: Publish package
30+
run: python publish.py

.pre-commit-config.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
args: [--maxkb=2000]
7+
- id: check-ast
8+
- id: check-case-conflict
9+
- id: check-executables-have-shebangs
10+
- id: check-merge-conflict
11+
- id: check-symlinks
12+
- id: check-toml
13+
- id: check-yaml
14+
- id: debug-statements
15+
- id: destroyed-symlinks
16+
- id: end-of-file-fixer
17+
files: \.(py|sh|rst|yml|yaml)$
18+
- id: mixed-line-ending
19+
- id: trailing-whitespace
20+
files: \.(py|sh|rst|yml|yaml)$
21+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
22+
rev: v2.14.0
23+
hooks:
24+
- id: pretty-format-yaml
25+
args: [--autofix, --indent, '2']
26+
- repo: https://github.com/tox-dev/pyproject-fmt
27+
rev: v2.5.0
28+
hooks:
29+
- id: pyproject-fmt
30+
- repo: https://github.com/psf/black
31+
rev: 24.10.0
32+
hooks:
33+
- id: black
34+
- repo: https://github.com/astral-sh/ruff-pre-commit
35+
rev: v0.8.1
36+
hooks:
37+
- id: ruff
38+
args: [--fix]
39+
- repo: https://github.com/pre-commit/mirrors-mypy
40+
rev: v1.13.0
41+
hooks:
42+
- id: mypy
43+
files: ^openapi_generator_cli/
44+
args: [--strict]
45+
# additional_dependencies:
46+
- repo: https://github.com/igorshubovych/markdownlint-cli
47+
rev: v0.43.0
48+
hooks:
49+
- id: markdownlint
50+
exclude: ^.github/PULL_REQUEST_TEMPLATE.md
51+
args: [--disable=MD013]

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

LICENSE

100755100644
File mode changed.

README.md

100755100644
Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
# OpenApi Generator PIP Package Generator
22

3-
[![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g)
4-
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
5-
6-
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and
7-
configuration automatically given an OpenAPI Spec (both 2.0 and 3.0 are supported). Please see
8-
[OpenAPITools/openapi-generator](https://github.com/OpenAPITools/openapi-generator)
3+
[![Join the Slack chat room](
4+
<https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange>
5+
)](
6+
<https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g>
7+
) [![Code style: black](
8+
<https://img.shields.io/badge/code%20style-black-000000.svg>
9+
)](
10+
<https://github.com/psf/black>
11+
) [![Ruff](
12+
<https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json>
13+
)](
14+
<https://github.com/astral-sh/ruff>
15+
)
16+
17+
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (both 2.0 and 3.0 are supported). Please see [OpenAPITools/openapi-generator]
918

1019
---
1120

12-
This project checks the [maven repository](https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli)
13-
once a day for a new version and will publish this new version automatically as a python package.
21+
This project checks the [maven repository] once a day for a new version and will publish this new version automatically as a python package.
1422

1523
## Installation
1624

25+
You must have the `java` binary executable available on your PATH for this to work. (JDK 11 is the minimal version supported. To install OpenJDK, please visit <https://adoptium.net/>)
26+
1727
You can install the package either in a virtual environment or globally.
1828

1929
```sh
@@ -24,20 +34,18 @@ pip install openapi-generator-cli
2434
pip install openapi-generator-cli==4.3.1
2535
```
2636

27-
After installation `openapi-generator` command will be available in your virtual environment or globally
28-
depending on your installation
37+
After installation `openapi-generator-cli` command will be available in your virtual environment or globally depending on your installation.
2938

3039
To check the version, for example. Type the following command
3140

3241
```sh
3342
# this will print the correct version number
34-
openapi-generator version
43+
openapi-generator-cli version
3544
```
3645

3746
## Further Documentation
3847

39-
Please refer to the [official openapi-generator docs](https://github.com/OpenAPITools/openapi-generator#3---usage) for
40-
more information about the possible arguments and a detailed usage manual of the command line interface.
48+
Please refer to the [official openapi-generator docs] for more information about the possible arguments and a detailed usage manual of the command line interface.
4149

4250
## Like the package?
4351

@@ -46,3 +54,7 @@ Please leave a star.
4654
## Have suggestions or feedback?
4755

4856
Please raise an issue, happy to hear from you :)
57+
58+
[OpenAPITools/openapi-generator]: <https://github.com/OpenAPITools/openapi-generator>
59+
[maven repository]: <https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli>
60+
[official openapi-generator docs]: <https://github.com/OpenAPITools/openapi-generator#3---usage>

openapi_generator_cli/__init__.py

100755100644
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# coding=utf-8
2-
# !/usr/bin/env python
1+
from __future__ import annotations
2+
3+
import importlib.resources
34
import os
45
import subprocess
56
import sys
67

78

8-
def run(args=None):
9+
def run(args: list[str] | None = None) -> None:
910
arguments = ["java"]
1011

11-
if os.getenv("JAVA_OPTS"):
12-
arguments.append(os.getenv("JAVA_OPTS"))
12+
java_opts = os.getenv("JAVA_OPTS")
13+
if java_opts:
14+
arguments.append(java_opts)
1315

1416
arguments.append("-jar")
1517

16-
jar_path = os.path.join(
17-
os.path.dirname(os.path.realpath(__file__)), "openapi-generator.jar"
18-
)
19-
arguments.append(jar_path)
18+
jar_path = importlib.resources.files("openapi_generator_cli") / "openapi-generator.jar"
19+
arguments.append(str(jar_path))
2020

2121
if args and type(args) == list:
2222
arguments.extend(args)
2323

24-
subprocess.call(" ".join(arguments), shell=True)
24+
subprocess.call(arguments) # noqa: S603
2525

2626

27-
def cli():
27+
def cli() -> None:
2828
args = []
2929
if len(sys.argv) > 1:
3030
args = sys.argv[1:]

openapi_generator_cli/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)