diff --git a/marshmallow_jsonschema/base.py b/marshmallow_jsonschema/base.py index ec0cb57..49184b6 100644 --- a/marshmallow_jsonschema/base.py +++ b/marshmallow_jsonschema/base.py @@ -108,7 +108,7 @@ def get_properties(self, obj): for field_name, field in sorted(obj.fields.items()): schema = self._get_schema_for_field(obj, field) - properties[field.name] = schema + properties[field.metadata.get("name") or field.name] = schema return properties @@ -140,7 +140,7 @@ def _from_python_type(self, obj, field, pytype): metadata.update(field.metadata) for md_key, md_val in metadata.items(): - if md_key == "metadata": + if md_key in ("metadata", "name"): continue json_schema[md_key] = md_val @@ -219,7 +219,7 @@ def _from_nested_schema(self, obj, field): metadata.update(field.metadata) for md_key, md_val in metadata.items(): - if md_key == "metadata": + if md_key in ("metadata", "name"): continue schema[md_key] = md_val