Skip to content

Commit

Permalink
feat: generate with new openapi client
Browse files Browse the repository at this point in the history
  • Loading branch information
iharthi committed Nov 3, 2023
1 parent 04ecadf commit aabd9f7
Show file tree
Hide file tree
Showing 182 changed files with 11,062 additions and 16,826 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# NOTE: This file is auto generated by OpenAPI Generator.
# URL: https://openapi-generator.tech
#
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: openapi_client Python package

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
poetry run pytest
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
.openapi

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -105,5 +106,6 @@ ENV/
.idea/

# Files for patching
openapi/openapi-generator-compatible-patched.json
openapi/openapi-generator-compatible.json
pyevr/openapi/openapi-generator-compatible-patched.json
pyevr/openapi/openapi-generator-compatible.json
pyevr/openapi/openapi-generator-compatible.json.orig
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
=========

0.7.0.dev1
----------

**Generic**

* Update openapi generator to latest version
* Move to poetry

0.6.0.dev4
----------

Expand Down
87 changes: 17 additions & 70 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,60 +1,17 @@
.PHONY: clean clean-test clean-pyc clean-build docs help openapi
.DEFAULT_GOAL := help

define BROWSER_PYSCRIPT
import os, webbrowser, sys
OPENAPI_GENERATOR_VERSION ?= v7.0.1

try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
lint:
poetry run flake8 --select=E9,F63,F7,F82 pyevr

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT

define PRINT_HELP_PYSCRIPT
import re, sys

for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT

BROWSER := python -c "$$BROWSER_PYSCRIPT"

help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache

lint: ## check style with flake8
flake8 pyevr tests
fmt:
poetry run black pyevr
poetry run black test

test: ## run tests quickly with the default Python
pytest
poetry run pytest

test-all: ## run tests on every Python version with tox
tox
Expand All @@ -63,44 +20,34 @@ coverage: ## check code coverage quickly with the default Python
coverage run --source pyevr -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/pyevr.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ pyevr
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html

servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: dist ## package and upload a release
# todo
twine upload dist/*

dist: clean ## builds source and wheel package
# todo
python setup.py sdist
python setup.py bdist_wheel
ls -l dist

install: clean ## install the package to the active Python's site-packages
$ todo
python setup.py install

openapi-patch: ## create patch for openapi schema
curl https://evr.veoseleht.ee/api/openapi-generator-compatible.json -o openapi/openapi-generator-compatible.json
diff -Naur ./openapi/openapi-generator-compatible.json ./openapi/openapi-generator-compatible-patched.json > ./openapi/patches/schema-fixes.patch || echo "Patch created"
curl https://evr.veoseleht.ee/api/openapi-generator-compatible.json -o pyevr/openapi/openapi-generator-compatible.json
diff -Naur ./pyevr/openapi/openapi-generator-compatible.json ./pyevr/openapi/openapi-generator-compatible-patched.json > ./pyevr/openapi/patches/schema-fixes.patch || echo "Patch created"

openapi: ## generate new API client based on the OpenAPI specification
sudo chown -R ${USER} pyevr
rm -rf .openapi
rm -rf pyevr/openapi_client
rm -rf pyevr/docs
curl https://evr.veoseleht.ee/api/openapi-generator-compatible.json -o openapi/openapi-generator-compatible.json
patch -p0 < openapi/patches/schema-fixes.patch
docker build -t pyevr_openapi -f openapi/Dockerfile-openapi openapi
docker run --rm --ulimit nofile=122880:122880 -v ${PWD}/.openapi/:/openapi pyevr_openapi
sudo chown -R ${USER} .openapi pyevr
curl https://evr.veoseleht.ee/api/openapi-generator-compatible.json -o pyevr/openapi/openapi-generator-compatible.json
patch -p0 < pyevr/openapi/patches/schema-fixes.patch
docker run --rm --ulimit nofile=122880:122880 -v ${PWD}/pyevr/openapi/update_schema.sh:/helpers/update_schema.sh -v ${PWD}/pyevr/openapi/openapi-generator-compatible.json:/openapi-generator-compatible.json -v ${PWD}/.openapi/:/openapi openapitools/openapi-generator-cli:$(OPENAPI_GENERATOR_VERSION) /bin/bash /helpers/update_schema.sh /openapi-generator-compatible.json
sudo chown -R ${USER} .openapi
cp -r .openapi/openapi_client pyevr/openapi_client
cp -r .openapi/docs pyevr/docs
rm -rf .openapi
poetry run black pyevr
26 changes: 3 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,16 @@ pyevr
=====


Python client for EVR
Python client for EVR (estonian e-waybill registry for forestry, https://evr.veoseleht.ee).


.. image:: https://img.shields.io/pypi/v/pyevr.svg
:target: https://pypi.python.org/pypi/pyevr

.. image:: https://travis-ci.org/thorgate/pyevr.svg?branch=master
:target: https://travis-ci.org/thorgate/pyevr

.. image:: https://readthedocs.org/projects/pyevr/badge/?version=latest
:target: https://pyevr.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://pyup.io/repos/github/thorgate/pyevr/shield.svg
:target: https://pyup.io/repos/github/thorgate/pyevr/
:alt: Updates

.. image:: https://coveralls.io/repos/github/thorgate/pyevr/badge.svg?branch=master
:target: https://coveralls.io/github/thorgate/pyevr?branch=master
:alt: Test coverage



* Free software: MIT license
* Documentation: https://pyevr.readthedocs.io.
Free software: MIT license

Credits
-------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
This package is created with openapi generator - https://hub.docker.com/r/openapitools/openapi-generator-cli
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion docs/authors.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/changelog.rst

This file was deleted.

Loading

0 comments on commit aabd9f7

Please sign in to comment.