jsonschema

JSON Schema with unknown property names

南笙酒味 提交于 2020-11-30 17:07:10
问题 I want to have a JSON Schema with unknown property names in an array of objects. A good example is the meta-data of a web page: "meta": { "type": "array", "items": { "type": "object", "properties": { "unknown-attribute-1": { "type": "string" }, "unknown-attribute-2": { "type": "string" }, ... } } } Any ideas please, or other way to reach the same? 回答1: Use patternProperties instead of properties . In the example below, the pattern match regex .* accepts any property name and I am allowing

Json Schema validation: do not allow fields other than those declared in schema [duplicate]

喜你入骨 提交于 2020-11-30 16:45:54
问题 This question already has answers here : Only allow properties that are declared in JSON schema (3 answers) Closed 10 months ago . Suppose that I have schema like fname: string lname: string age: string None of them are required. User can send me any of those attributes above but nothing else that is not declared. They can pass me fname , lname and age or all. But if they pass me all and additional property like middle_name the message should be rejected. How would I define a schema like this

python服务之flask

人走茶凉 提交于 2020-11-23 09:59:52
前言: 关于python flask 的介绍、指导、案例,网络上比比皆是。这里参考官网:http://www.pythondoc.com/flask/index.html 你可能不知道的flask服务: 曾经做过一个项目: A + A-server 目的: 提供给测试或开发数据,进行调试/测试 简单介绍: A:根据jsonschema定义生成合法/非法(遍历/非遍历)的数据 A-server:实现接口,获取服务器中的jsonschema定义后,传给A项目包进行处理 重点介绍 A-server: 1 @app.route( ' /jsonschema/r/<traversal> ' , methods=[ " POST " ]) 2 def legal_random(traversal= False): 3 # 通过判断传入的traversal参数的值,进行选择是否遍历 4 if traversal == 1 or traversal == " 1 " : 5 traversal = True 6 else : 7 traversal = False 8 9 data = {} # 这里的data是jsonschema的定义内容 10 11 client = A.Client() # 调用A项目的接口 12 legal_value = client.random(data,