Skip to content

Commit c320090

Browse files
committed
Introspect load behavior for request parsing.
1 parent 237b9f4 commit c320090

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

flask_smore/apidoc.py

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def get_parameters(self, rule, view, docs, parent=None):
105105
options['default_in'] = locations[0]
106106
return converter(
107107
args.get('args', {}),
108+
dump=False,
108109
**options
109110
) + rule_to_params(rule, docs.get('params'))
110111

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'flask>=0.10.1',
1010
'marshmallow>=2.0',
1111
'webargs>=0.18.0',
12-
'apispec>=0.3.0',
12+
'apispec>=0.4.1',
1313
]
1414

1515
def find_version(fname):

tests/test_swagger.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TestFunctionView:
2727
def function_view(self, app, models, schemas):
2828
@app.route('/bands/<int:band_id>/')
2929
@doc(tags=['band'])
30-
@use_kwargs({'name': fields.Str()}, locations=('query', ))
30+
@use_kwargs({'name': fields.Str(missing='queen')}, locations=('query', ))
3131
@marshal_with(schemas.BandSchema, description='a band')
3232
def get_band(band_id):
3333
return models.Band(name='slowdive', genre='spacerock')
@@ -45,8 +45,13 @@ def test_params(self, app, path):
4545
params = path['get']['parameters']
4646
rule = app.url_map._rules_by_endpoint['get_band'][0]
4747
expected = (
48-
swagger.fields2parameters({'name': fields.Str()}, default_in='query') +
49-
rule_to_params(rule)
48+
[{
49+
'in': 'query',
50+
'name': 'name',
51+
'type': 'string',
52+
'required': False,
53+
'default': 'queen',
54+
}] + rule_to_params(rule)
5055
)
5156
assert params == expected
5257

0 commit comments

Comments
 (0)