Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Contributors (chronological)
- Douglas Anderson `@djanderson <https://github.com/djanderson>`_
- Marat Sharafutdinov `@decaz <https://github.com/decaz>`_
- Daniel Radetsky `@dradetsky <https://github.com/dradetsky>`_
- Evgeny Seliverstov `@theirix <https://github.com/theirix>`_
7 changes: 5 additions & 2 deletions apispec/ext/marshmallow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,16 @@ def resolve_parameters(spec, parameters):
return resolved


def resolve_schema_dict(spec, schema, dump=True):
def resolve_schema_dict(spec, schema, dump=True, use_instances=False):
if isinstance(schema, dict):
if (schema.get('type') == 'array' and 'items' in schema):
schema['items'] = resolve_schema_dict(spec, schema['items'])
return schema
plug = spec.plugins[NAME] if spec else {}
schema_cls = resolve_schema_cls(schema)
if isinstance(schema, marshmallow.Schema) and use_instances:
schema_cls = schema
else:
schema_cls = resolve_schema_cls(schema)
if schema_cls in plug.get('refs', {}):
ref_schema = {'$ref': '#/definitions/{0}'.format(plug['refs'][schema_cls])}
if getattr(schema, 'many', False):
Expand Down
5 changes: 3 additions & 2 deletions apispec/ext/marshmallow/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ def schema2parameters(schema, **kwargs):


def fields2parameters(fields, schema=None, spec=None, use_refs=True,
default_in='body', name='body', required=False):
default_in='body', name='body', required=False,
use_instances=False):
"""Return an array of OpenAPI parameters given a mapping between field names and
:class:`Field <marshmallow.Field>` objects. If `default_in` is "body", then return an array
of a single parameter; else return an array of a parameter for each included field in
Expand All @@ -372,7 +373,7 @@ def fields2parameters(fields, schema=None, spec=None, use_refs=True,
if schema is not None:
# Prevent circular import
from apispec.ext.marshmallow import resolve_schema_dict
prop = resolve_schema_dict(spec, schema, dump=False)
prop = resolve_schema_dict(spec, schema, dump=False, use_instances=use_instances)
else:
prop = fields2jsonschema(fields, spec=spec, use_refs=use_refs, dump=False)

Expand Down