marshmallow-jsonschema
marshmallow-jsonschema copied to clipboard
fix: use data_key from field if available to set property name
#88 introduced the ability to customize the name of the fields when serializing, which is great! However, Marshmallow already has a way to customize the name of fields when serializing through the data_key
property. The JSONSchema should use the same property when serializing the schema to json instead of inventing its own thing.
Coverage remained the same at 99.149% when pulling 160c85aa688c8dae80a0260e96d9381f9e7c68d8 on Lundalogik:field_data_key into c032d1a5842de31de6dcf01fe41f6736a13e1f17 on fuhrysteve:master.
Ping @fuhrysteve I have rebased this on master, it would be great to get this merged it's been a PR for a while now
I’m only finding this PR now. I did more or less the same thing in https://github.com/fuhrysteve/marshmallow-jsonschema/pull/139#event-4395798383
thanks @martijnthe and @jgroth ! Apologies for not having seen this before now.
It looks like this changeset prefers data_key over metadata. Do either of you have a sense for which one follows the standard better? Seems like data_key should take precedence, however I'm not sure off the top of my head.
I removed the use if metadata in this PR since Marshmallow already had the the data_key
concept and I thought it would only be confusing having two concepts doing the same thing. I you still want to keep it I think it is fine since this would be a breaking change, but I think supporting data_key
is the most important part of this