为什么导入OpenAPI定义时“模式”会从“响应”对象中消失?

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

我可以成功将以下OpenAPI定义导入Azure API Management。

但是,当我导出OpenAPI定义时,“模式”名称已从“响应”对象中删除。因此,我的门户中的开发人员未显示此操作的架构或示例。

如果添加到the official editor,我的API定义有效且功能正常。

如何防止模式被删除?

{
  "swagger": "2.0",
  "info": {
    "title": "Foo",
    "description": "Foo",
    "version": "1"
  },
  "host": "example.org",
  "schemes": [
    "https"
  ],
  "paths": {
    "/foo": {
      "get": {
        "summary": "List all foo.",
        "responses": {
          "200": {
            "description": "Success.",
            "schema": {
              "$ref": "#/definitions/Foo"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "Foo": {
      "type": "object",
      "properties": {
        "example": {
          "type": "string",
          "description": "An example."
        }
      }
    }
  }
}
azure-api-management openapi
1个回答
1
投票

当定义在根对象或操作对象中缺少“生成”名称时,似乎会出现此问题。

例如,以下定义应成功导入,然后导出而不删除“模式”。请注意,“产生”名称已添加到根对象中,在“方案”和“路径”之间

{
  "swagger": "2.0",
  "info": {
    "title": "Foo",
    "description": "Foo",
    "version": "1"
  },
  "host": "example.org",
  "schemes": [
    "https"
  ],
  "produces": ["application/json"]
  "paths": {
    "/foo": {
      "get": {
        "summary": "List all foo.",
        "responses": {
          "200": {
            "description": "Success.",
            "schema": {
              "$ref": "#/definitions/Foo"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "Foo": {
      "type": "object",
      "properties": {
        "example": {
          "type": "string",
          "description": "An example."
        }
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.