Repository: coding-kitties/flask-swagger-generator (language: python)

Issue:
Feature/#10



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..e1f1a52
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,41 @@
+# This workflow will create a pypi package and upload it with twine
+
+name: Build
+
+on:
+  push:
+    tags:
+      - "v*"
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python 3.8
+      uses: actions/setup-python@v2
+      with:
+        python-version: 3.8
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+        if [ -f requirements-build.txt ]; then pip install -r requirements-build.txt; fi
+    - name: Set Environment
+      env:
+        ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
+      run: |
+        raw=$(git branch -r --contains ${{ github.ref }})
+        branch=${raw/origin\/}
+        echo $branch
+        echo "::set-env name=BRANCH_NAME::$branch"
+    - name: Build
+      run: |
+        pip install wheel
+        python ./setup.py sdist bdist_wheel
+    - name: Upload
+      if: github.event.base_ref == 'refs/heads/master' && ${{ env.BRANCH_NAME == 'master' }}
+      uses: pypa/gh-action-pypi-publish@release/v1
+      with:
+        user: __token__
+        password: ${{ secrets.PYPI_TOKEN }}
\ No newline at end of file
diff --git a/AUTHORS.md b/AUTHORS.md
new file mode 100644
index 0000000..a56cb86
--- /dev/null
+++ b/AUTHORS.md
@@ -0,0 +1,8 @@
+# Marc van Duyn | Mod and Contributor
+<a href="https://linkedin.com/in/marc-van-duyn">
+  <img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" width="200px" />
+</a>
+<br/>
+<a href="https://github.com/MDUYN">
+  <img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white" width="200px" />
+</a>
\ No newline at end of file
diff --git a/ci/__init__.py b/ci/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/ci/upload_package.py b/ci/upload_package.py
deleted file mode 100644
index 211ee17..0000000
--- a/ci/upload_package.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import os
-import shutil
-from yolk.pypi import CheeseShop
-
-PACKAGE_NAME = 'flask-swagger-generator'
-
-
-def get_latest_version_number(package_name):
-    pkg, all_versions = CheeseShop().query_versions_pypi(package_name)
-    if len(all_versions):
-        return all_versions[0]
-    return None
-
-
-if __name__ == "__main__":
-    import sys
-
-    sys.path.append('../')
-
-    from flask_swagger_generator import get_version
-    released_version = get_latest_version_number(PACKAGE_NAME)
-
-    if released_version != get_version():
-        os.chdir("../")
-
-        # Remove distribution directory if exists
-        if os.path.isdir('dist'):
-            shutil.rmtree('dist')
-
-        os.system("python setup.py sdist bdist_wheel")
-        os.system("twine upload -r {} dist/*".format(PACKAGE_NAME))
-        os.system("twine upload -p $pipy_password -u $pipy_username dist/*")
diff --git a/flask_swagger_generator/__init__.py b/flask_swagger_generator/__init__.py
index 44fdba0..e69de29 100644
--- a/flask_swagger_generator/__init__.py
+++ b/flask_swagger_generator/__init__.py
@@ -1,5 +0,0 @@
-from flask_swagger_generator.utils.version import get_version
-
-VERSION = (0, 3, 1, 'alpha', 0)
-
-__all__ = ['get_version']
diff --git a/flask_swagger_generator/generators/generator.py b/flask_swagger_generator/generators/generator.py
index 17dac6a..0d4bbc4 100644
--- a/flask_swagger_generator/generators/generator.py
+++ b/flask_swagger_generator/generators/generator.py
@@ -1,17 +1,14 @@
-import re
 import os
-import inspect
-from random import randint
-from datetime import datetime
 from functools import wraps
 
 from flask import Flask
+
+from flask_swagger_generator.exceptions import SwaggerGeneratorException
 from flask_swagger_generator.specifiers import SwaggerVersion, \
     SwaggerThreeSpecifier
-from flask_swagger_generator.exceptions import SwaggerGeneratorException
 from flask_swagger_generator.specifiers.swagger_specifier \
     import SwaggerSpecifier
-from flask_swagger_generator.utils import SecurityType, RequestType
+from flask_swagger_generator.utils import SecurityType
 
 
 class Generator:
diff --git a/requirements.txt b/requirements.txt
index 9132196..3131d17 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,3 @@
-Flask==1.1.1
-
+Flask>=1.1.1
 marshmallow>=3.0.0
 setuptools~=51.0.0
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..224a779
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[metadata]
+description-file = README.md
\ No newline at end of file
diff --git a/setup.py b/setup.py
index a2af5a8..d397d8d 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
 import setuptools
-from flask_swagger_generator import get_version
+from version import get_version
 
 VERSION = get_version()
 
diff --git a/flask_swagger_generator/utils/version.py b/version.py
similarity index 72%
rename from flask_swagger_generator/utils/version.py
rename to version.py
index 7410a3f..ebf8b1f 100644
--- a/flask_swagger_generator/utils/version.py
+++ b/version.py
@@ -1,3 +1,6 @@
+VERSION = (0, 3, 2, 'alpha', 0)
+
+
 def get_version(version=None):
     version = get_complete_version(version)
     main = get_main_version(version)
@@ -17,10 +20,4 @@ def get_complete_version(version=None):
     argument is non-empty,
     check for correctness of the tuple provided.
     """
-    if version is None:
-        from flask_swagger_generator import VERSION as version
-    else:
-        assert len(version) == 5
-        assert version[3] in ('alpha', 'beta', 'rc', 'final')
-
-    return version
+    return VERSION


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..0e73c84
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,42 @@
+# This workflow will install Python dependencies, run tests and lint
+# with a single version of Python
+
+name: Tests
+
+on:
+  push:
+    branches:
+      - '*'         # matches every branch that doesn't contain a '/'
+      - '*/*'       # matches every branch containing a single '/'
+      - '**'        # matches every branch
+  pull_request:
+    branches:
+      - '*'         # matches every branch that doesn't contain a '/'
+      - '*/*'       # matches every branch containing a single '/'
+      - '**'        # matches every branch
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python 3.8
+      uses: actions/setup-python@v2
+      with:
+        python-version: 3.8
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install flake8
+        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+        if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
+    - name: Lint with flake8
+      run: |
+        # stop the build if there are Python syntax errors or undefined names
+        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
+        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+    - name: Test
+      run: |
+        python -m unittest discover -s tests/
\ No newline at end of file
diff --git a/requirements-test.txt b/requirements-test.txt
index 4552300..3698036 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,4 +1,4 @@
-Flask-Testing==0.8.0
+Flask-Testing==0.8.1
 marshmallow==3.10.0
 PyYAML==5.3.1
 deepdiff==5.2.1