这是一个创建于 2242 天前的主题,其中的信息可能已经有所发展或是发生改变。
可以用过下面方式定义不同的类型——
A= news_api.model('A', {
'content': fields.Integer(required=True, description=''),
'type': fields.String(required=True, default='a'),
})
B= news_api.model('B', {
'content': fields.Integer(required=True, description=''),
'type': fields.String(required=True, default='b''),
})
C= news_api.model('C', {
'content': fields.Integer(required=True, description=''),
'type': fields.String(required=True, default='c'),
})
A B C 类型的主要区别在 ‘ type ’字段,type 分别指定是 a b c
我的问题是,如何定义一个类,可以校验如下的 json 数据:
{
"data":[
{A},
{B},
{C}
]
}
3 条回复 • 2020-04-20 19:12:52 +08:00
|
|
1
dengqianyi 2018-08-21 22:52:31 +08:00
没有人在开发中使用 marshmallow 吗?
|