Skip to content

Commit

Permalink
Closes marshmallow-code#95: fields2jsonschema warning about Shema Object
Browse files Browse the repository at this point in the history
Add extra check to show warning about fields ignoring only if there are some of them
  • Loading branch information
khorolets committed Nov 13, 2016
1 parent 9636670 commit 2d33d59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apispec/ext/marshmallow/swagger.py
Expand Up @@ -453,7 +453,10 @@ class Meta:
:rtype: dict, a JSON Schema Object
"""
Meta = getattr(schema, 'Meta', None)
if getattr(Meta, 'fields', None) or getattr(Meta, 'additional', None):
declared_fields = set(schema._declared_fields.keys())
if (set(getattr(Meta, 'fields', set())) > declared_fields
or
set(getattr(Meta, 'additional', set())) > declared_fields):
warnings.warn(
"Only explicitly-declared fields will be included in the Schema Object. "
"Fields defined in Meta.fields or Meta.additional are ignored."
Expand Down

0 comments on commit 2d33d59

Please sign in to comment.