登录智能体应用开发平台
点击工具页面中右侧的创建工具按钮,点击OPENAPI Schema工具。
输入工具配置信息进行工具创建,完成创建的工具支持在应用中使用。
工具名称:用户可自定义工具名称
Schema:
工具列表:

部分服务商会直接提供



| URL | 请求方式 |
|---|---|
https://restapi.amap.com/v3/weather/weatherInfo?parameters |
GET |
| 参数名 | 含义 | 规则说明 | 是否必须 | 缺省值 |
|---|---|---|---|---|
key |
请求服务权限标识 | 用户在高德地图官网申请 web 服务 API 类型 KEY | 必填 | 无 |
city |
城市编码 | 输入城市的 adcode,adcode 信息可参考城市编码表 | 必填 | 无 |
extensions |
气象类型 | 可选值:base/all base: 返回实况天气 all: 返回预报天气 |
可选 | 无 |
output |
返回格式 | 可选值:JSON、XML |
可选 | JSON |
| 一级字段 | 二级字段 | 三级字段 | 含义 | 规则说明 |
|---|---|---|---|---|
status |
- | - | 返回状态 | 值为 0 或 1;1:成功;0:失败 |
count |
- | - | 返回结果总数目 | - |
info |
- | - | 返回的状态信息 | - |
infocode |
- | - | 返回状态说明, 10000 代表正确 | |
lives |
- | - | 实况天气数据信息 | - |
province |
- | 省份名 | - |
| | city | - | 城市名 | - |
| | adcode | - | 区域编码 | - |
| | weather | - | 天气现象(汉字描述) | - |
| | temperature | - | 实时气温,单位:摄氏度 | - |
| | winddirection | - | 风向描述 | - |
| | windpower | - | 风力级别,单位:级 | - |
| | humidity | - | 空气湿度 | - |
| | reporttime | - | 数据发布的时间 | - |
| forecast | - | - | 预报天气信息数据 | - |
| | city | - | 城市名称 | - |
| | adcode | - | 城市编码 | - |
| | province | - | 省份名称 | - |
| | reporttime | - | 预报发布时间 | - |
| | casts | - | 预报数据 list 结构,元素 cast,按顺序为当天、第二天、第三天的预报数据 | - |
| | | date | 日期 | - |
| | | week | 星期几 | - |
| | | dayweather | 白天天气现象 | - |
| | | nightweather | 晚上天气现象 | - |
| | | daytemp | 白天温度 | - |
| | | nighttemp | 晚上温度 | - |
| | | daywind | 白天风向 | - |
| | | nightwind | 晚上风向 | - |
| | | daypower | 白天风力 | - |
| | | nightpower | 晚上风力 | - |


````pip install pyyaml openapi-spec-validator** ** # npm install -g @stoplight/spectral-cli*** ** import os ** ** import yaml ** ** import subprocess ** ** from openapi_spec_validator ** ** import validate_spec ** ** from openapi_spec_validator.exceptions ** ** import OpenAPIValidationError ** ** def load_yaml_file(file_path): ** ** try : ** ** with open (file_path, 'r' , encoding = 'utf-8' ) ** ** as f: data = yaml.safe_load(f) print ( "✅ YAML 语法检查通过" ) ** ** return data ** ** except yaml.YAMLError ** ** as e: print ( "❌ YAML 格式错误:" , e) ** ** return None** ** except Exception** ** as e: print ( "❌ 加载 YAML 文件时发生错误:" , e) ** ** return None** ** def validate_openapi_spec(spec): ** ** try : validate_spec(spec) print ( "✅ OpenAPI 规范校验通过" ) ** ** except OpenAPIValidationError ** ** as e: print ( "❌ OpenAPI 规范校验失败:" , e) ** ** except Exception** ** as e: print ( "❌ 其他异常:" , e) ** ** def run_spectral_lint(file_path): ** ** try : result = subprocess.run( [ "spectral" , "lint" , file_path], stdout = subprocess.PIPE, stderr = subprocess.PIPE, text = True ) ** ** if result.returncode == 0 : print ( "✅ Spectral 规则检查通过" ) ** ** else : print ( "❌ Spectral 报告如下:\n" ) print (result.stdout) ** ** except FileNotFoundError : print ( "⚠️ 未找到 Spectral,请确保已安装 `@stoplight/spectral-cli`" ) ** ** def main(file_path): print ( f"�� 正在校验: { file_path }\n{'-' * 50 } " ) spec = load_yaml_file(file_path) ** ** if spec: validate_openapi_spec(spec) print ( "-" * 50 ) run_spectral_lint(file_path) ** ** if name == "__main__" : ** ** import argparse parser = argparse.ArgumentParser(description = "验证 OpenAPI YAML 文件" ) parser.add_argument( "file" , help = "要验证的 OpenAPI YAML 文件路径" ) args = parser.parse_args() main(args. file )

