From 037fe95617abb3592a715449c10973c7805e2a85 Mon Sep 17 00:00:00 2001 From: Magnus Tullberg Date: Thu, 6 Aug 2020 11:15:11 +0200 Subject: [PATCH 1/8] Add default swagger filename to Api, issue 191. https://github.com/python-restx/flask-restx/issues/191 --- flask_restx/api.py | 5 ++++- tests/test_swagger.py | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/flask_restx/api.py b/flask_restx/api.py index 60157088..f89deeb8 100644 --- a/flask_restx/api.py +++ b/flask_restx/api.py @@ -106,6 +106,7 @@ class Api(object): :param url_scheme: If set to a string (e.g. http, https), then the specs_url and base_url will explicitly use this scheme regardless of how the application is deployed. This is necessary for some deployments behind a reverse proxy. + :param str default_swagger_filename: The default swagger filename. """ def __init__( @@ -136,6 +137,7 @@ def __init__( serve_challenge_on_401=False, format_checker=None, url_scheme=None, + default_swagger_filename="swagger.json", **kwargs ): self.version = version @@ -166,6 +168,7 @@ def __init__( self._refresolver = None self.format_checker = format_checker self.namespaces = [] + self.default_swagger_filename = default_swagger_filename self.ns_paths = dict() @@ -308,7 +311,7 @@ def _register_specs(self, app_or_blueprint): app_or_blueprint, SwaggerView, self.default_namespace, - "/swagger.json", + "/" + self.default_swagger_filename, endpoint=endpoint, resource_class_args=(self,), ) diff --git a/tests/test_swagger.py b/tests/test_swagger.py index f52748a9..8b7af715 100644 --- a/tests/test_swagger.py +++ b/tests/test_swagger.py @@ -3323,3 +3323,25 @@ def get(self): path = data["paths"]["/with-parser/"] assert "parameters" not in path + + def test_nondefault_swagger_filename(self, app, client): + api = restx.Api(doc="/doc/test", default_swagger_filename="test.json") + ns = restx.Namespace("ns1") + + @ns.route("/test1") + class Ns(restx.Resource): + @ns.doc("Docs") + def get(self): + pass + + api.add_namespace(ns) + api.init_app(app) + + resp = client.get("/test.json") + assert resp.status_code == 200 + assert resp.content_type == "application/json" + resp = client.get("/doc/test") + assert resp.status_code == 200 + assert resp.content_type == "text/html; charset=utf-8" + resp = client.get("/ns1/test1") + assert resp.status_code == 200 From bab31e085f355dd73858fd3715f7ed71849656da Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 1 Sep 2021 21:53:02 +0200 Subject: [PATCH 2/8] optimize email regex (credits: @kevinbackhouse, fix: #372) --- flask_restx/inputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask_restx/inputs.py b/flask_restx/inputs.py index b05532f3..9c76d8a0 100644 --- a/flask_restx/inputs.py +++ b/flask_restx/inputs.py @@ -48,7 +48,7 @@ def my_type(value): email_regex = re.compile( - r"^" "(?P[^@]*[^@.])" r"@" r"(?P[^@]+(?:\.[^@]+)*)" r"$", + r"^" "(?P[^@]*[^@.])" r"@" r"(?P[^@\.]+(?:\.[^@\.]+)*)" r"$", re.IGNORECASE, ) From 7724538e66dd17b991bc0db6fd05922f011e6ae1 Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 1 Sep 2021 22:07:31 +0200 Subject: [PATCH 3/8] add test case for the reported issue --- tests/test_inputs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_inputs.py b/tests/test_inputs.py index 5a0133bc..9e705684 100644 --- a/tests/test_inputs.py +++ b/tests/test_inputs.py @@ -584,6 +584,8 @@ def test_valid_value_default(self, value): "me@::1", "me@200.8.9.10", "me@2001:db8:85a3::8a2e:370:7334", + "foo@bar.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?" + + ".?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?@", ], ) def test_invalid_value_default(self, value): From c574c7934c96a4ce96acfab14edaa941e4674e08 Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 1 Sep 2021 22:10:55 +0200 Subject: [PATCH 4/8] Bump version 0.5.1 --- README.rst | 6 +++--- flask_restx/__about__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index a8b64b7e..123b22a9 100644 --- a/README.rst +++ b/README.rst @@ -2,14 +2,14 @@ Flask RESTX =========== -.. image:: https://github.com/python-restx/flask-restx/workflows/Tests/badge.svg?branch=master&event=push +.. image:: https://github.com/python-restx/flask-restx/workflows/Tests/badge.svg?tag=0.5.1&event=push :target: https://github.com/python-restx/flask-restx/actions?query=workflow%3ATests :alt: Tests status .. image:: https://codecov.io/gh/python-restx/flask-restx/branch/master/graph/badge.svg :target: https://codecov.io/gh/python-restx/flask-restx :alt: Code coverage -.. image:: https://readthedocs.org/projects/flask-restx/badge/?version=latest - :target: https://flask-restx.readthedocs.io/en/latest/ +.. image:: https://readthedocs.org/projects/flask-restx/badge/?version=0.5.1 + :target: https://flask-restx.readthedocs.io/en/0.5.1/ :alt: Documentation status .. image:: https://img.shields.io/pypi/l/flask-restx.svg :target: https://pypi.org/project/flask-restx diff --git a/flask_restx/__about__.py b/flask_restx/__about__.py index 1a9fbad8..510c1766 100644 --- a/flask_restx/__about__.py +++ b/flask_restx/__about__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -__version__ = "0.5.1.dev" +__version__ = "0.5.1" __description__ = ( "Fully featured framework for fast, easy and documented API development with Flask" ) From d8c854eca962139df8477699b4463fe9f7c64a93 Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 1 Sep 2021 22:10:55 +0200 Subject: [PATCH 5/8] Update to version 0.5.2.dev for next development cycle --- README.rst | 6 +++--- flask_restx/__about__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 123b22a9..a8b64b7e 100644 --- a/README.rst +++ b/README.rst @@ -2,14 +2,14 @@ Flask RESTX =========== -.. image:: https://github.com/python-restx/flask-restx/workflows/Tests/badge.svg?tag=0.5.1&event=push +.. image:: https://github.com/python-restx/flask-restx/workflows/Tests/badge.svg?branch=master&event=push :target: https://github.com/python-restx/flask-restx/actions?query=workflow%3ATests :alt: Tests status .. image:: https://codecov.io/gh/python-restx/flask-restx/branch/master/graph/badge.svg :target: https://codecov.io/gh/python-restx/flask-restx :alt: Code coverage -.. image:: https://readthedocs.org/projects/flask-restx/badge/?version=0.5.1 - :target: https://flask-restx.readthedocs.io/en/0.5.1/ +.. image:: https://readthedocs.org/projects/flask-restx/badge/?version=latest + :target: https://flask-restx.readthedocs.io/en/latest/ :alt: Documentation status .. image:: https://img.shields.io/pypi/l/flask-restx.svg :target: https://pypi.org/project/flask-restx diff --git a/flask_restx/__about__.py b/flask_restx/__about__.py index 510c1766..c3c42221 100644 --- a/flask_restx/__about__.py +++ b/flask_restx/__about__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -__version__ = "0.5.1" +__version__ = "0.5.2.dev" __description__ = ( "Fully featured framework for fast, easy and documented API development with Flask" ) From 95f7cd23aed5b01665f7bb1125efcef2a734a68e Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 1 Sep 2021 22:22:17 +0200 Subject: [PATCH 6/8] update CHANGELOG --- CHANGELOG.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0d93146e..7c10fee8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -25,6 +25,19 @@ Releases prior to 0.3.0 were “best effort” filled out, but are missing some info. If you see your contribution missing info, please open a PR on the Changelog! +.. _section-0.5.1: +0.5.1 +----- + +.. _bug_fixes-0.5.1 + +Bug Fixes +~~~~~~~~~ + +:: + + * Optimize email regex (#372) [kevinbackhouse] + .. _section-0.5.0: 0.5.0 ----- From bc2a9a0fc575b1c6c38801310d342610ea2b4409 Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 1 Sep 2021 22:27:44 +0200 Subject: [PATCH 7/8] remove feedstock release pipeline since none of the remaining mainteners know anything about how this was setup and how to fix it now that it is broken --- .github/workflows/release.yml | 72 ----------------------------------- 1 file changed, 72 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dfe0d9f5..4e99d769 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,75 +26,3 @@ jobs: run: | python setup.py sdist bdist_wheel twine upload dist/* - feedstock: - needs: build - runs-on: ubuntu-latest - steps: - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Checkout flask-restx code - uses: actions/checkout@v2 - with: - path: base - - name: Checkout flask-restx-feedstock code - uses: actions/checkout@v2 - with: - repository: python-restx/flask-restx-feedstock.git - path: feedstock - token: ${{ secrets.BOT_TOKEN }} - - name: Set Variables - id: vars - run: | - echo "::set-output name=version::$(echo ${{ github.ref }} | cut -d'/' -f3)" - - name: Create a release branch - run: | - cd feedstock - git remote add forge https://github.com/conda-forge/flask-restx-feedstock.git - git fetch forge - git checkout forge/master -b release-${{ steps.vars.outputs.version }} - - name: Update meta.yml - shell: python - run: | - from http import client - from pkg_resources import parse_requirements - import re - VERSION = "${{ steps.vars.outputs.version }}" - with open("feedstock/recipe/meta.yaml") as f: - meta = f.read() - requirements = [] - with open("base/requirements/install.pip") as f: - for req in parse_requirements(f): - name = req.project_name - versions = ",".join(["".join(spec) for spec in req.specs]) - if versions: - name += " " + versions - requirements.append(name) - requirements = '"' + '", "'.join(requirements) + '"' - conn = client.HTTPSConnection("pypi.org") - conn.request("GET", "/simple/flask-restx/") - resp = conn.getresponse() - content = str(resp.read(), "utf-8") - conn.close() - m = re.findall(r'flask-restx-%s.tar.gz#sha256=([A-Za-z0-9]+)"' % VERSION, content) - if not m: - raise Exception("sha256 not found in: %s" % content) - sha256 = m[0] - meta = re.sub(r'({% set version = )".+"( %})', r'\1"%s"\2' % VERSION, meta) - meta = re.sub(r'({% set sha256 = )".+"( %})', r'\1"%s"\2' % sha256, meta) - meta = re.sub(r"({% set requirements = \[).+(] %})", r"\1%s\2" % requirements, meta) - meta = re.sub(r"(number:) \d+", r"\1 0", meta) - with open("feedstock/recipe/meta.yaml", "w") as f: - f.write(meta) - - name: Push - run: | - cd feedstock - git config user.name "${{ secrets.BOT_USERNAME }}" - git config user.email "python.restx.bot@gmail.com" - git add recipe/meta.yaml - git commit -m"Release version ${{ steps.vars.outputs.version }}" - git push origin release-${{ steps.vars.outputs.version }} - - name: Create Pull Request - run: | - curl --fail -u ${{ secrets.BOT_USERNAME }}:${{ secrets.BOT_TOKEN }} https://api.github.com/repos/conda-forge/flask-restx-feedstock/pulls -d '{"title": "Release version ${{ steps.vars.outputs.version }}", "head": "python-restx:release-${{ steps.vars.outputs.version }}", "base": "master", "maintainer_can_modify": true}' From 16bf540ee41d5a3ffc0f143dcd2e3baa2d04f496 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Sep 2021 15:43:42 +0000 Subject: [PATCH 8/8] Bump flask-restx from 0.4.0 to 0.5.1 in /examples/zoo_app Bumps [flask-restx](https://github.com/python-restx/flask-restx) from 0.4.0 to 0.5.1. - [Release notes](https://github.com/python-restx/flask-restx/releases) - [Changelog](https://github.com/python-restx/flask-restx/blob/master/CHANGELOG.rst) - [Commits](https://github.com/python-restx/flask-restx/compare/0.4.0...0.5.1) --- updated-dependencies: - dependency-name: flask-restx dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- examples/zoo_app/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/zoo_app/requirements.txt b/examples/zoo_app/requirements.txt index a72bb41d..4ba87b60 100644 --- a/examples/zoo_app/requirements.txt +++ b/examples/zoo_app/requirements.txt @@ -2,7 +2,7 @@ aniso8601==9.0.1 attrs==21.2.0 click==7.1.2 Flask==1.1.4 -flask-restx==0.4.0 +flask-restx==0.5.1 itsdangerous==1.1.0 Jinja2==2.11.3 jsonschema==3.2.0