import json
newFilePath = r"C:UsersDLZDesktop
ewApi211.json"
oldFilePath = r"C:UsersDLZDesktopoldApi241.json"
def readJsonFile(filePath): #获取到仅是接口的json数据
file = open(filePath, “rb”)
fileJson = json.load(file)
# 获取paths值,即接口定义信息
interfaces = fileJson[‘paths’]
bodys = fileJson[‘definitions’]
# print(apis)
return interfaces, bodys
将接口字典中的key转成list
def get_keys(dict):
keyList = []
for key in dict.keys():
keyList.append(key)
# 获取到的接口uri地址,去重的(如果一个接口有两种请求方式,只显示一个接口名称)
# print(keyList)
return keyList
找出变动的接口
def checkAPIs( ):
new_interface_infos, new_bodys = readJsonFile(newFilePath)
old_interface_infos, old_bodys = readJsonFile(oldFilePath)
new\_interface\_names = get\_keys(new\_interface\_info