验证开放 API 规范无法上传到 Azure API 管理
Validated Open API spec fails to upload on Azure API Management
我正在尝试在我的天蓝色 api 管理服务上导入与 https://github.com/ccouzens/keycloak-openapi/blob/master/keycloak/9.0.json 非常相似的 OpenAPI 规范 json。
我验证了我的 openapi.json 版本
http://editor.swagger.io/
.
当我尝试使用上述 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 规范 file 有多个 API URLs,其中 {id} 在同一个 URL 中出现两次,而天蓝色的 API管理不允许,两个路径参数没有"parameter"定义。
例如,参考下面的 URL 和 api 规范中相应的参数定义 file
/{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 editor 不考虑这些约束违规
因此,总而言之,要在 Azure api 管理服务上上传开放 API 规范,您需要考虑以下限制以及 azure 文档中存在的限制
- 不能有两个具有相同标识字符串的路径参数
- 所有路径参数都应在规范中有一个 "parameter" 定义 json
PS :我的 api 规格 json 与 json file 大致相似,但不相同。它还有其他问题,例如使用请求正文删除 API。
我正在尝试在我的天蓝色 api 管理服务上导入与 https://github.com/ccouzens/keycloak-openapi/blob/master/keycloak/9.0.json 非常相似的 OpenAPI 规范 json。 我验证了我的 openapi.json 版本 http://editor.swagger.io/ . 当我尝试使用上述 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 规范 file 有多个 API URLs,其中 {id} 在同一个 URL 中出现两次,而天蓝色的 API管理不允许,两个路径参数没有"parameter"定义。 例如,参考下面的 URL 和 api 规范中相应的参数定义 file
/{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 editor 不考虑这些约束违规
因此,总而言之,要在 Azure api 管理服务上上传开放 API 规范,您需要考虑以下限制以及 azure 文档中存在的限制
- 不能有两个具有相同标识字符串的路径参数
- 所有路径参数都应在规范中有一个 "parameter" 定义 json
PS :我的 api 规格 json 与 json file 大致相似,但不相同。它还有其他问题,例如使用请求正文删除 API。