-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
New feature for iterating over fields_dict in marshalling/unmarshalling #718
Comments
Have you tested this with https://github.com/marshmallow-code/apispec? If that is part of the 2.0 spec and it isn't compliant we might get more traction over there. |
Maybe, apispec's motivation is reversed for me.
(in my project https://github.com/podhmo/swagger-marshmallow-codegen, supporting additionalProperties, but this code is not good for me (maybe this is not comprehensive support)) |
I imagine it could be implemented with a schema Meta attribute named This feature might also be needed to fix an incompatibility in apispec. Maybe they only implemented the subset of OpenAPI features that marshmallow could already express though. |
Ah, yes, it is better that supporting this via Meta attribute, instead of class's hook. |
Yes, absolutely. If this feature is added to marshmallow, apispec can be modified to expose |
It is decided that supporting |
jsonschema(and swagger) have specific options for unexpected additional fields.
And, I want to translate this feature to marshmallow schema.
marshmallow's current implementation
The way of iteration in marshmallow's current implementation, is just calling
iteritems()
with fields_dict. So, it is difficult that define schema allowing unexpected field.for examples, in swagger (openAPI2.0) the schema definition, like bellow.
Then, about person schema, passing
{"name": "foo"}
is ok, and{"name": "foo", "x": 20, "y": 10}
is also ok(unexpected field is treated as integer).it is a bit difficult, making marshmallow's version of this.
(schema meta's additional is candidate of expected field names, ... and so on.)
proposal
If marshmallow has new hook point that changing the way of iteration, it is enable to implement marshmallow's version, more easily.
For example,
get_marshalling_iterator()
(this is not good name), is existed in Schema class.The text was updated successfully, but these errors were encountered: