Skip to content

Commit

Permalink
Improve support for JSON parameters
Browse files Browse the repository at this point in the history
When using api.parameters decorator, the locations parameter is now taken into account to generate the documentation ("@api.parameters(parameters.MyParameters(many=False), locations=('json',))".
  • Loading branch information
DurandA authored and frol committed Sep 10, 2016
1 parent 054b717 commit 5e5ac73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions flask_restplus_patched/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def decorator(func):
_locations = ('json', )
else:
_locations = locations
if _locations is not None:
parameters.context['in'] = _locations

return self.doc(params=parameters)(
self.response(code=http_exceptions.UnprocessableEntity.code)(
Expand Down
2 changes: 1 addition & 1 deletion flask_restplus_patched/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parameters_for(self, doc):
if isinstance(schema, dict) and all(isinstance(field, dict) for field in schema.values()):
return list(schema.values())

if schema.many:
if 'in' in schema.context and 'json' in schema.context['in']:
default_location = 'body'
else:
default_location = 'query'
Expand Down

0 comments on commit 5e5ac73

Please sign in to comment.