You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We may want to avoid imposing a BaseJsonSchema (unless we use mixins, which also seem like something we should avoid unless there are compelling reasons to) since Marhmallow-sqlalchemy uses them and this library needs to be compatible with that library.
However, I'm struggling to think of another way to inject this functionality into marshmallow without doing something funky like monkey patching.
Maybe we could suggest a metaclass sort of plugin system in marshmallow?
Mixin style
frommarshmallow_sqlalchemyimportModelSchemafrommarshmallow_jsonschemaimportJSONSchemaMixinfrom .modelsimportBook# some sqlalchemy modelclassBookSchema(ModelSchema, JSONSchemaMixin):
classMeta:
model=Bookbs=BookSchema()
bs.jsonschema()
Metaclass "plugin" style
frommarshmallowimportregister_plugin# this doesn't actually existfrommarshmallow_jsonschemaimportJSONSchemaPluginregister_plugin(JSONSchemaPlugin)
frommarshmallow_sqlalchemyimportModelSchemafrom .modelsimportBook# some sqlalchemy modelclassBookSchema(ModelSchema):
plugins= ['jsonschema']
classMeta:
model=Bookbs=BookSchema()
bs.jsonschema()
The text was updated successfully, but these errors were encountered:
We may want to avoid imposing a
BaseJsonSchema
(unless we use mixins, which also seem like something we should avoid unless there are compelling reasons to) since Marhmallow-sqlalchemy uses them and this library needs to be compatible with that library.However, I'm struggling to think of another way to inject this functionality into marshmallow without doing something funky like monkey patching.
Maybe we could suggest a metaclass sort of plugin system in marshmallow?
Mixin style
Metaclass "plugin" style
The text was updated successfully, but these errors were encountered: