I was wondering if I'm only one struggling with such problem.
Lets take dict for example:
data = {'totalSize': 3000, 'freq': 2400,
'distribution':
{'ram1': {'size': 200, 'status': 'OK'},
'ram2': {'size': 100, 'status': 'OK'}
}
}
Please not that ram1/2 is dynamic keys that can not be known in advance
Question, how should my api.model look like ? I have:
wild = {"*": fields.Wildcard(fields.String())}
hw_memory = api.model('Memory', {
'totalSize': fields.Integer(description='total memory size in MB',
example=1024),
'freq': fields.Integer(description='Speed of ram in mhz', example=800),
'distribution': fields.Nested(wild),
})
It is working, however it does not validate anything below "distribution", in other words, works like wildcard, anything there will be accepted. Is there a way to nest dicts in such way having wildcard dynamic key ?