azure - 验证的开放 API 规范无法上传到 Azure API 管理
问题描述
我正在尝试在我的 azure api 管理服务上导入与https://github.com/ccouzens/keycloak-openapi/blob/master/keycloak/9.0.json非常相似的 OpenAPI 规范 json。我在http://editor.swagger.io/上验证了我的 openapi.json 版本 。当我尝试使用上述 json 创建 API 资源时,出现错误:
{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"templateParameters","message":"All template parameters used in the UriTemplate must be defined in the Operation, and vice-versa."}]}}
请帮忙
解决方案
发现问题。json API 规范文件有多个 API URL,其中 {id} 在同一个 URL 中出现两次,这是 azure 的 API 管理不允许的,并且没有两个路径参数的“参数”定义。例如,参考下面的 URL 和 api 规范文件中的相应参数定义
/{realm}/client-scopes/{id}/protocol-mappers/models/{id}
"parameters": [
{
"in": "path",
"name": "realm",
"description": "realm name (not id!)",
"required": true,
"schema": {
"type": "string"
},
"style": "simple"
},
{
"in": "path",
"name": "id",
"description": "Mapper id",
"required": true,
"schema": {
"type": "string"
},
"style": "simple"
}
]
swagger 编辑器 不考虑这些约束违规
因此,总而言之,要在 Azure api 管理服务上上传开放 API 规范,您需要考虑以下约束以及 azure 文档中存在的约束
- 您不能有两个具有相同标识字符串的路径参数
- 所有路径参数都应该在规范 json 中有一个“参数”定义
PS:我的 api 规范 json 与 json文件非常相似,但不一样。它还有其他问题,例如使用请求正文删除 API。
推荐阅读
- python - 再问:Flask-Bootstrap 有什么问题?
- javascript - 如何访问 Firebase 快照的元素?
- arrays - 如何有效地将项目附加到 Swift 中的大型数组?
- deployment - 应用程序部署在 SCCM 中显示为 0MB
- python-3.x - 从“widget.after”脚本调用“widget.destroy”时出现奇怪的非法 tkinter 状态
- python - 从 Python 解释器运行脚本文件
- html - 在 vs 代码上使用烧瓶时链接到静态 css 文件不起作用
- python-3.x - Python3 从子进程读取标准输出
- javascript - NodeJS 性能方面 - 运行具有多个必需的单个节点文件 VS 运行多个节点文件
- apache - .htaccess 在我的 Ubuntu droplet 上不起作用,但在我的个人 PC 上正常工作。我忘记更改一些 Apache 设置了吗?