marshmallow-jsonschema icon indicating copy to clipboard operation
marshmallow-jsonschema copied to clipboard

fix: use data_key from field if available to set property name

Open jgroth opened this issue 5 years ago • 5 comments

#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.

jgroth avatar Dec 11 '19 12:12 jgroth

Coverage Status

Coverage remained the same at 99.149% when pulling 160c85aa688c8dae80a0260e96d9381f9e7c68d8 on Lundalogik:field_data_key into c032d1a5842de31de6dcf01fe41f6736a13e1f17 on fuhrysteve:master.

coveralls avatar Dec 11 '19 12:12 coveralls

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

jgroth avatar Feb 22 '21 12:02 jgroth

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

martijnthe avatar Mar 02 '21 19:03 martijnthe

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.

fuhrysteve avatar Mar 10 '21 00:03 fuhrysteve

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

jgroth avatar Mar 10 '21 07:03 jgroth