I have two different JSON responses, each with different field names, however both validate successfully with the defined schema using jsonschema library.
Here is the defined schema
query_schema = {
"type": "object",
"properties" : {
"pltfrm_nm": {"type" : "string"},
"srvr_nm": {"type": "string"},
"db_nm": {"type": "string"},
"tbl_nm": {"type": "string"},
"ip_addr_id": {"type": "string"},
"usr_id": {"type": "string"},
"sql_txt": {"type": "string"},
"timestmp": {"type": "string"},
},
}
and here is two different responses:
input = {'pltfrm_nm': 'p1', 'srvr_nm': 'server', 'db_nm': 'some db', 'tbl_nm': 'some table',
'ip_addr_id': '999.999.9999', 'usr_id': 'my id', 'sql_txt': "sql text here", 'timestmp': 'aaaa)'}
validate(instance=input, schema=query_schema)
input = {'why': 'p1', 'does': 'server', 'this': 'some db', 'still': 'some table',
'validate': '999.999.9999', 'i': 'my id', 'do': "sql text here", 'not': 'aaaa',
'understand': 'hello'}
validate(instance=input, schema=query_schema)
in the second input I named all the fields different and added a new field understand
as well. Neither of these throw a ValidationError. Here is the library: https://pypi.org/project/jsonschema/. Why does the second one not throw an error?