Skip to content

Commit 322357d

Browse files
Merge branch 'master' into fix_typo
2 parents 231000e + 88497ce commit 322357d

File tree

8 files changed

+44
-76
lines changed

8 files changed

+44
-76
lines changed

.github/workflows/release.yml

-72
Original file line numberDiff line numberDiff line change
@@ -26,75 +26,3 @@ jobs:
2626
run: |
2727
python setup.py sdist bdist_wheel
2828
twine upload dist/*
29-
feedstock:
30-
needs: build
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Set up Python 3.8
34-
uses: actions/setup-python@v1
35-
with:
36-
python-version: 3.8
37-
- name: Checkout flask-restx code
38-
uses: actions/checkout@v2
39-
with:
40-
path: base
41-
- name: Checkout flask-restx-feedstock code
42-
uses: actions/checkout@v2
43-
with:
44-
repository: python-restx/flask-restx-feedstock.git
45-
path: feedstock
46-
token: ${{ secrets.BOT_TOKEN }}
47-
- name: Set Variables
48-
id: vars
49-
run: |
50-
echo "::set-output name=version::$(echo ${{ github.ref }} | cut -d'/' -f3)"
51-
- name: Create a release branch
52-
run: |
53-
cd feedstock
54-
git remote add forge https://github.com/conda-forge/flask-restx-feedstock.git
55-
git fetch forge
56-
git checkout forge/master -b release-${{ steps.vars.outputs.version }}
57-
- name: Update meta.yml
58-
shell: python
59-
run: |
60-
from http import client
61-
from pkg_resources import parse_requirements
62-
import re
63-
VERSION = "${{ steps.vars.outputs.version }}"
64-
with open("feedstock/recipe/meta.yaml") as f:
65-
meta = f.read()
66-
requirements = []
67-
with open("base/requirements/install.pip") as f:
68-
for req in parse_requirements(f):
69-
name = req.project_name
70-
versions = ",".join(["".join(spec) for spec in req.specs])
71-
if versions:
72-
name += " " + versions
73-
requirements.append(name)
74-
requirements = '"' + '", "'.join(requirements) + '"'
75-
conn = client.HTTPSConnection("pypi.org")
76-
conn.request("GET", "/simple/flask-restx/")
77-
resp = conn.getresponse()
78-
content = str(resp.read(), "utf-8")
79-
conn.close()
80-
m = re.findall(r'flask-restx-%s.tar.gz#sha256=([A-Za-z0-9]+)"' % VERSION, content)
81-
if not m:
82-
raise Exception("sha256 not found in: %s" % content)
83-
sha256 = m[0]
84-
meta = re.sub(r'({% set version = )".+"( %})', r'\1"%s"\2' % VERSION, meta)
85-
meta = re.sub(r'({% set sha256 = )".+"( %})', r'\1"%s"\2' % sha256, meta)
86-
meta = re.sub(r"({% set requirements = \[).+(] %})", r"\1%s\2" % requirements, meta)
87-
meta = re.sub(r"(number:) \d+", r"\1 0", meta)
88-
with open("feedstock/recipe/meta.yaml", "w") as f:
89-
f.write(meta)
90-
- name: Push
91-
run: |
92-
cd feedstock
93-
git config user.name "${{ secrets.BOT_USERNAME }}"
94-
git config user.email "[email protected]"
95-
git add recipe/meta.yaml
96-
git commit -m"Release version ${{ steps.vars.outputs.version }}"
97-
git push origin release-${{ steps.vars.outputs.version }}
98-
- name: Create Pull Request
99-
run: |
100-
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}'

CHANGELOG.rst

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ Releases prior to 0.3.0 were “best effort” filled out, but are missing
2525
some info. If you see your contribution missing info, please open a PR
2626
on the Changelog!
2727

28+
.. _section-0.5.1:
29+
0.5.1
30+
-----
31+
32+
.. _bug_fixes-0.5.1
33+
34+
Bug Fixes
35+
~~~~~~~~~
36+
37+
::
38+
39+
* Optimize email regex (#372) [kevinbackhouse]
40+
2841
.. _section-0.5.0:
2942
0.5.0
3043
-----

examples/zoo_app/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ aniso8601==9.0.1
22
attrs==21.2.0
33
click==7.1.2
44
Flask==1.1.4
5-
flask-restx==0.4.0
5+
flask-restx==0.5.1
66
itsdangerous==1.1.0
77
Jinja2==2.11.3
88
jsonschema==3.2.0

flask_restx/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "0.5.1.dev"
2+
__version__ = "0.5.2.dev"
33
__description__ = (
44
"Fully featured framework for fast, easy and documented API development with Flask"
55
)

flask_restx/api.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class Api(object):
106106
:param url_scheme: If set to a string (e.g. http, https), then the specs_url and base_url will explicitly use this
107107
scheme regardless of how the application is deployed. This is necessary for some deployments behind a reverse
108108
proxy.
109+
:param str default_swagger_filename: The default swagger filename.
109110
"""
110111

111112
def __init__(
@@ -136,6 +137,7 @@ def __init__(
136137
serve_challenge_on_401=False,
137138
format_checker=None,
138139
url_scheme=None,
140+
default_swagger_filename="swagger.json",
139141
**kwargs
140142
):
141143
self.version = version
@@ -166,6 +168,7 @@ def __init__(
166168
self._refresolver = None
167169
self.format_checker = format_checker
168170
self.namespaces = []
171+
self.default_swagger_filename = default_swagger_filename
169172

170173
self.ns_paths = dict()
171174

@@ -308,7 +311,7 @@ def _register_specs(self, app_or_blueprint):
308311
app_or_blueprint,
309312
SwaggerView,
310313
self.default_namespace,
311-
"/swagger.json",
314+
"/" + self.default_swagger_filename,
312315
endpoint=endpoint,
313316
resource_class_args=(self,),
314317
)

flask_restx/inputs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def my_type(value):
4848

4949

5050
email_regex = re.compile(
51-
r"^" "(?P<local>[^@]*[^@.])" r"@" r"(?P<server>[^@]+(?:\.[^@]+)*)" r"$",
51+
r"^" "(?P<local>[^@]*[^@.])" r"@" r"(?P<server>[^@\.]+(?:\.[^@\.]+)*)" r"$",
5252
re.IGNORECASE,
5353
)
5454

tests/test_inputs.py

+2
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ def test_valid_value_default(self, value):
584584
"me@::1",
585585
586586
"me@2001:db8:85a3::8a2e:370:7334",
587+
"foo@bar.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?" +
588+
".?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?@",
587589
],
588590
)
589591
def test_invalid_value_default(self, value):

tests/test_swagger.py

+22
Original file line numberDiff line numberDiff line change
@@ -3323,3 +3323,25 @@ def get(self):
33233323

33243324
path = data["paths"]["/with-parser/"]
33253325
assert "parameters" not in path
3326+
3327+
def test_nondefault_swagger_filename(self, app, client):
3328+
api = restx.Api(doc="/doc/test", default_swagger_filename="test.json")
3329+
ns = restx.Namespace("ns1")
3330+
3331+
@ns.route("/test1")
3332+
class Ns(restx.Resource):
3333+
@ns.doc("Docs")
3334+
def get(self):
3335+
pass
3336+
3337+
api.add_namespace(ns)
3338+
api.init_app(app)
3339+
3340+
resp = client.get("/test.json")
3341+
assert resp.status_code == 200
3342+
assert resp.content_type == "application/json"
3343+
resp = client.get("/doc/test")
3344+
assert resp.status_code == 200
3345+
assert resp.content_type == "text/html; charset=utf-8"
3346+
resp = client.get("/ns1/test1")
3347+
assert resp.status_code == 200

0 commit comments

Comments
 (0)