Skip to content
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

Set MA_BASE_SCHEMA_CLS in Document / EmbeddedDocument #263

Merged
merged 5 commits into from Apr 29, 2020

Conversation

lafrech
Copy link
Collaborator

@lafrech lafrech commented Apr 29, 2020

This changes allows to set a base marshmallow schema class in the Document / EmbeddedDocument template.

It removes the complicated logic used to pass schema parameters (check_unknown_fields, meta, params) along the as_marshmallow_schema / as_marshmallow_field calls.

The former implementation passing params allows twisted cases like passing a specific parameter to a schema deeply nested in the document when calling as_marshmallow_schema, but in a way that is absolutely not practical: it takes a hugs unreadable dict as input.

In real life, schema parameters such as unknown are most often the same for all the application, so it makes sense to factorize them in a base schema.

Corner cases can always be addresses with this implementation. It might be a little bit more cumbersome, but it should be feasible and even more readable.

This PR also fixes the cache in as_marshmallow_schema that was broken in 3.0.0beta. The fix is in the first commit (set meta unknown in cache modifiers) but is obsoleted by subsequent commits.

@lafrech lafrech added this to the 3.0 milestone Apr 29, 2020
@coveralls
Copy link

coveralls commented Apr 29, 2020

Coverage Status

Coverage decreased (-0.2%) to 95.557% when pulling 32bd9b8 on base_schema_cls into 8a0aaf9 on master.

@lafrech lafrech merged commit e0305e8 into master Apr 29, 2020
@lafrech lafrech deleted the base_schema_cls branch April 29, 2020 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants