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

Add a way to generate a Schema from a dictionary #1312

Closed
sloria opened this issue Jul 20, 2019 · 0 comments · Fixed by #1322

Comments

@sloria
Copy link
Member

commented Jul 20, 2019

Generating schemas at runtime is a fairly common use case that I've run into a handful of times at this point (webargs, environs , form builders...).

It might make sense to incorporate this into marshmallow core.

Proposed API

>>> MyDynamicSchema = Schema.from_dict({"foo": fields.Str()})
>>> MyDynamicSchema
<class 'marshmallow.schema.GeneratedSchema'>
class AlbumSchema(Schema):
     artist = fields.Nested(Schema.from_dict({"name": fields.Str()})
sloria added a commit that referenced this issue Jul 21, 2019

@sloria sloria closed this in #1322 Aug 11, 2019

sloria added a commit that referenced this issue Aug 11, 2019
Add Schema.from_dict for generating schemas from dicts (#1322)
* Add Schema.from_dict for generating schemas from dicts

close #1312

* Document Schema.from_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.