如果要限定"object"的properties不能是其他字段,则可用"additionalProperties":False来指定, 如:
schema = {
"type": "object",
"additionalProperties":False,
"properties": {
"onlyone": {
"type": "string"
}
}
}
data1 = {"onlyone":"22"} (能通过验证)
data2 = {"onlyone":"22", "onlytwo":"33}(无法通过验证)