Comments (1)
in marshmallow ?
class AdditionalPropertiesOpts(SchemaOpts):
def __init__(self, meta, **kwargs):
super().__init__(meta, **kwargs)
self.additional_field = getattr(meta, "additional_field", fields.Field)
class AdditionalPropertiesSchema(Schema):
"""
support addtionalProperties
class MySchema(AdditionalPropertiesSchema):
class Meta:
additional
"""
OPTIONS_CLASS = AdditionalPropertiesOpts
@pre_load
@pre_dump
def wrap_dynamic_additionals(self, data):
diff = set(data.keys()).difference(self.fields.keys())
for name in diff:
f = self.opts.additional_field
self.fields[name] = f() if callable(f) else f
return data
def dumps(self, obj, many=None, update_fields=False, *args, **kwargs):
return super().dumps(obj, many=many, update_fields=update_fields, *args, **kwargs)
def dump(self, obj, many=None, update_fields=False, *args, **kwargs):
return super().dump(obj, many=many, update_fields=update_fields, *args, **kwargs)
from swagger-marshmallow-codegen.
Related Issues (20)
- get version info from module HOT 1
- Question: Is it possible to set "emit_schema_even_primitive_type" from command line? HOT 9
- Dependency `dictknife` is broken HOT 3
- ItemsRange validator causes exception with flask-apispec doc.register
- 📝 careless schema definitions (memo) HOT 4
- nested field using lambda HOT 4
- using UnknownField, Include for additionalProperties HOT 1
- treating AdditionalProperties only schema as Dict field HOT 2
- handle additionalProperties correctly HOT 5
- use pytest
- use dict not OrderedDict
- customization example (x-default-now)
- use readme.md instead of readme.rst
- additionalProperties with ref is broken HOT 3
- nested additionalProperties is not supported yet HOT 2
- handling nullable and x-nullable correctly? HOT 2
- strict option
- rewriting the handle way of paths part HOT 1
- Does not support minItems on array (generate ItemsRange validator instead of Length) HOT 3
- Ability to use as a Python module HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-marshmallow-codegen.