Skip to content

Commit 8692ed7

Browse files
authored
Merge branch 'master' into patch-1
2 parents d27f0b2 + b31bd79 commit 8692ed7

File tree

4 files changed

+177
-2
lines changed

4 files changed

+177
-2
lines changed

CHANGELOG.rst

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
Flask-RestX Changelog
2+
=====================
3+
4+
Basic structure is
5+
6+
::
7+
8+
ADD LINK (..) _section-VERSION
9+
VERSION
10+
-------
11+
ADD LINK (..) _bug_fixes-VERSION OR _enhancments-VERSION
12+
Bug Fixes or Enchancements
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
* Message (TICKET) [CONTRIBUTOR]
15+
16+
Opening a release
17+
-----------------
18+
19+
If you’re the first contributor, add a new semver release to the
20+
document. Place your addition in the correct category, giving a short
21+
description (matching something in a git commit), the issue ID (or PR ID
22+
if no issue opened), and your Github username for tracking contributors!
23+
24+
Releases prior to 0.3.0 were “best effort” filled out, but are missing
25+
some info. If you see your contribution missing info, please open a PR
26+
on the Changelog!
27+
28+
.. _section-0.3.0:
29+
30+
0.3.0
31+
-----
32+
33+
.. _bug_fixes-0.3.0:
34+
35+
Bug Fixes
36+
~~~~~~~~~
37+
38+
::
39+
40+
* Make error handlers order of registration respected when handling errors (#202) [avilaton]
41+
* add prefix to config setting (#114) [heeplr]
42+
* Doc fixes [openbrian, mikhailpashkov, rich0rd, Rich107, kashyapm94, SteadBytes, ziirish]
43+
* Use relative path for `api.specs_url` (#188) [jslay88]
44+
* Allow example=False (#203) [ogenstad]
45+
* Add support for recursive models (#110) [peterjwest, buggyspace, Drarok, edwardfung123]
46+
* generate choices schema without collectionFormat (#164) [leopold-p]
47+
* Catch TypeError in marshalling (#75) [robyoung]
48+
* Unable to access nested list propert (#91) [arajkumar]
49+
50+
.. _enhancements-0.3.0:
51+
52+
Enhancements
53+
~~~~~~~~~~~~
54+
55+
::
56+
57+
* Update Python versions [johnthagen]
58+
* allow strict mode when validating model fields (#186) [maho]
59+
* Make it possible to include "unused" models in the generated swagger documentation (#90)[volfpeter]
60+
61+
.. _section-0.2.0:
62+
63+
0.2.0
64+
-----
65+
66+
This release properly fixes the issue raised by the release of werkzeug
67+
1.0.
68+
69+
.. _bug-fixes-0.2.0:
70+
71+
Bug Fixes
72+
~~~~~~~~~
73+
74+
::
75+
76+
* Remove deprecated werkzeug imports (#35)
77+
* Fix OrderedDict imports (#54)
78+
* Fixing Swagger Issue when using @api.expect() on a request parser (#20)
79+
80+
.. _enhancements-0.2.0:
81+
82+
Enhancements
83+
~~~~~~~~~~~~
84+
85+
::
86+
87+
* use black to enforce a formatting codestyle (#60)
88+
* improve test workflows
89+
90+
.. _section-0.1.1:
91+
92+
0.1.1
93+
-----
94+
95+
This release is mostly a hotfix release to address incompatibility issue
96+
with the recent release of werkzeug 1.0.
97+
98+
.. _bug-fixes-0.1.1:
99+
100+
Bug Fixes
101+
~~~~~~~~~
102+
103+
::
104+
105+
* pin werkzeug version (#39)
106+
* register wildcard fields in docs (#24)
107+
* update package.json version accordingly with the flask-restx version and update the author (#38)
108+
109+
.. _enhancements-0.1.1:
110+
111+
Enhancements
112+
~~~~~~~~~~~~
113+
114+
::
115+
116+
* use github actions instead of travis-ci (#18)
117+
118+
.. _section-0.1.0:
119+
120+
0.1.0
121+
-----
122+
123+
.. _bug-fixes-0.1.0:
124+
125+
Bug Fixes
126+
~~~~~~~~~
127+
128+
::
129+
130+
* Fix exceptions/error handling bugs https://github.com/noirbizarre/flask-restplus/pull/706/files noirbizarre/flask-restplus#741
131+
* Fix illegal characters in JSON references to model names noirbizarre/flask-restplus#653
132+
* Support envelope parameter in Swagger documentation noirbizarre/flask-restplus#673
133+
* Fix polymorph field ambiguity noirbizarre/flask-restplus#691
134+
* Fix wildcard support for fields.Nested and fields.List noirbizarre/flask-restplus#739
135+
136+
.. _enhancements-0.1.0:
137+
138+
Enhancements
139+
~~~~~~~~~~~~
140+
141+
::
142+
143+
* Api/Namespace individual loggers noirbizarre/flask-restplus#708
144+
* Various deprecated import changes noirbizarre/flask-restplus#732 noirbizarre/flask-restplus#738
145+
* Start the Flask-RESTX fork!
146+
* Rename all the things (#2 #9)
147+
* Set up releases from CI (#12)
148+
* Not a library enhancement but this was much needed - thanks @ziirish !

flask_restx/fields.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def is_indexable_but_not_string(obj):
6666
return not hasattr(obj, "strip") and hasattr(obj, "__iter__")
6767

6868

69+
def is_integer_indexable(obj):
70+
return isinstance(obj, list) or isinstance(obj, tuple)
71+
72+
6973
def get_value(key, obj, default=None):
7074
"""Helper for pulling a keyed value off various types of objects"""
7175
if isinstance(key, int):
@@ -91,6 +95,11 @@ def _get_value_for_key(key, obj, default):
9195
return obj[key]
9296
except (IndexError, TypeError, KeyError):
9397
pass
98+
if is_integer_indexable(obj):
99+
try:
100+
return obj[int(key)]
101+
except (IndexError, TypeError, ValueError):
102+
pass
94103
return getattr(obj, key, default)
95104

96105

requirements/develop.pip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
tox==3.13.2
2-
black==19.10b0; python_version >= '3.6'
1+
tox
2+
black; python_version >= '3.6'

tests/test_fields.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,3 +1385,21 @@ def __getitem__(self, n):
13851385

13861386
obj = Test("hi")
13871387
assert fields.get_value("value", obj) == "hi"
1388+
1389+
def test_get_value_int_indexable_list(self):
1390+
assert fields.get_value('bar.0', {'bar': [42]}) == 42
1391+
1392+
def test_get_value_int_indexable_list_with_str(self):
1393+
assert fields.get_value('bar.abc', {'bar': [42]}) is None
1394+
1395+
def test_get_value_int_indexable_nested_list(self):
1396+
assert fields.get_value('bar.0.val', {'bar': [{'val': 42}]}) == 42
1397+
1398+
def test_get_value_int_indexable_tuple_with_str(self):
1399+
assert fields.get_value('bar.abc', {'bar': (42, 43)}) is None
1400+
1401+
def test_get_value_int_indexable_tuple(self):
1402+
assert fields.get_value('bar.0', {'bar': (42, 43)}) == 42
1403+
1404+
def test_get_value_int_indexable_nested_tuple(self):
1405+
assert fields.get_value('bar.0.val', {'bar': [{'val': 42}]}) == 42

0 commit comments

Comments
 (0)