Azure API管理在导入开放API规范时不遵守operationId

问题描述 投票:0回答:1

我有从Swashbuckle生成的swagger.json。将开放API规范导入Azure API管理时,它不会将operationId用作操作的名称。相反,它使用描述。我附上了一个产生问题的JSON示例。

{
  "swagger": "2.0",
  "info": {
    "version": "v1",
    "title": "Route Manager API"
  },
  "paths": {
    "/api/account/Logout": {
      "post": {
        "tags": [ "Account" ],
        "summary": "Logs the current user out of the system.",
        "operationId": "ApiAccountLogoutPost",
        "consumes": [],
        "produces": [],
        "parameters": [],
        "responses": { "200": { "description": "Logout successfully performed" } }
      }
    }
  }
}

enter image description here

下面的示例是在导入Open API规范时从Microsoft文档中获取的,并且似乎使用OperationId作为名称(GetSessions)显示为API管理中函数的标题。

  "paths": {
    "/sessions": {
      "get": {
        "description": "A list of sessions.  Optional parameters work as filters to reduce the listed sessions.",
        "operationId": "GetSessions",
        "parameters": [
          {
            "name": "speakername",
            "in": "query",
            "type": "string"
          },
          {
            "name": "dayno",
            "in": "query",
            "description": "Format - int32.",
            "type": "integer"
          },
          {
            "name": "keyword",
            "in": "query",
            "type": "string"
          }
        ],
        "responses": { "200": { "description": "OK" } },
        "produces": [ "application/vnd.collection+json" ]
      }
    }

enter image description here

azure-api-management
1个回答
0
投票

APIM确实遵循operationId,它的值用于将操作ID形成为Azure资源。您在UI上看到的是操作标题。使用operationId作为标题是错误的,因为Open API规范说:

用于标识操作的唯一字符串。 id必须在API中描述的所有操作中是唯一的。工具和库可以使用operationId来唯一标识操作,因此,建议遵循常见的编程命名约定。

人们不希望遵循具有操作标题的通用编程命名约定。因此,“摘要”字段用于操作标题。

更多细节在这里:https://blogs.msdn.microsoft.com/apimanagement/2018/04/11/important-changes-to-openapi-import-and-export/

© www.soinside.com 2019 - 2024. All rights reserved.