-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow providing custom fields mappings #22
Conversation
Wow this is great and thanks for adding the test case - sorry I didn't get around to this sooner. So I've been thinking about this a little, and while I like the new functionality, I'm a bit hesitant to encourage behavior that basically isn't thread-safe when it seems like there's a good alternative. What if the implementation looked more like this:
If you really want to have this globally, you can always do this somewhere global: JSONSchema.JSONSchemaTypesMapping[fields.Color] = text_type Or, you could simply extend the base class JSONSchemaExtended(JSONSchema):
pass
JSONSchemaExtended.JSONSchemaTypesMapping[fields.Color] = text_type Let me know what you think |
So, are you still OK of I remove the classmethod but rely on the class level attribute to either subclass or update the class attribute? |
Could you please take another look and consider this again? Thanks! |
This will allow sub-classing fields and allow marshmallow_jsonschema to render them as the parent class would.
Ok, this final solution seems like the least intrusive |
Polite ping. |
2 similar comments
Polite ping. |
Polite ping. |
Hi @s0undt3ch ! I would like to recommend using a different approach here. Have a look at how I think that decorator is a more convenient and readable solution. Could you please rework your PR to use the decorator instead and resolve the conflicts? See also apispec docs for custom fields. |
This will allow sub-classing fields and allow marshmallow_jsonschema to
render them as the parent class would.