Schema with a JSON object with undefined fields


I have something like the following:

class EmailBody(schema.Object):
    properties = {
        'application_id': schema.String(max_length=36),
        'template_id': schema.String(max_length=36),
        'subject': schema.String(min_length=3),
        'to_name': schema.String(min_length=3),
        'to_email': schema.String(min_length=3),
        'additional_fields': schema.Object(default=None)

The additional fields are unspecified, and can contain any number of key value pairs but I can’t figure out how to define this properly so it shows up after validation (usually just is an empty dict)


Yup - that’s just missing functionality right now. Currently objects always expect a fixed set of fields. Welcome to raise an issue for it to make sure we get that gap filled in shortly.


gotcha. I’ve captured that here:


Hi, I ran into maybe related issue


class ProjectParams(Object):
    description = 'Project params',
    default = {}

class Project(Object):
    properties = {
        'name': string(description='Project name'),
        'params': ProjectParams,

And when I convert it to dict:

{"name": "Test", "params": ({},)}

But expect:

{"name": "Test", "params": {}}