Ibm cloud Bluemix:API管理-错误“;大摇大摆的jsonReference";。这是不受支持的。我怎么修理它?

Ibm cloud Bluemix:API管理-错误“;大摇大摆的jsonReference";。这是不受支持的。我怎么修理它?,ibm-cloud,swagger,api-management,Ibm Cloud,Swagger,Api Management,我尝试导入json格式的swagger文档。我弄错了 字段路径[“/namespaces”].get.responses[“401”]使用了一种夸张的方式 jsonReference。这是不受支持的。删除此字段,或删除内联字段 而不是引用JSON,并重新提交请求 (我还附上了截图以防万一)。可能导致错误的代码段如下所示: "401": { "$ref": "#/responses/UnauthorizedRequest" }, "500": { "$ref": "#/respon

我尝试导入json格式的swagger文档。我弄错了

字段路径[“/namespaces”].get.responses[“401”]使用了一种夸张的方式 jsonReference。这是不受支持的。删除此字段,或删除内联字段 而不是引用JSON,并重新提交请求

(我还附上了截图以防万一)。可能导致错误的代码段如下所示:

"401": {
    "$ref": "#/responses/UnauthorizedRequest"
},
"500": {
    "$ref": "#/responses/ServerError"
}
"responses": {
    "200": {
        "description": "Task retrieved",
        "schema": {
          "type": "object",
          "required": [
              "deadline",
              "description",
              "status"
          ],
          "properties": {
              "description": {
                  "type": "string",
                  "example": "Make an app for Demo"
              },
              "status": {
                  "type": "string",
                  "example": "Created"
              },
              "deadline": {
                  "type": "string",
                  "format": "date",
                  "example": "01/15/16"
              }
          }
        }
    },
    "404": {
        "description": "Task not found"
    }
}
这些内容有什么问题?如果你能告诉我如何解决这个问题,我将不胜感激

谢谢

参考:截图

此错误看起来像是一个限制/错误,但正如错误描述所示,您可以通过内联定义来绕过它。下面是一个在Swagger文档中内联引用的示例

下面的招摇过市文档有一个
$ref

"responses": {
    "200": {
        "description": "Task retrieved",
        "schema": {
            "$ref": "#/definitions/Task"
        }
    },
    "404": {
        "description": "Task not found"
    }
}

...

"definitions": {
    "Task": {
        "type": "object",
        "required": [
            "deadline",
            "description",
            "status"
        ],
        "properties": {
            "description": {
                "type": "string",
                "example": "Make an app for Demo"
            },
            "status": {
                "type": "string",
                "example": "Created"
            },
            "deadline": {
                "type": "string",
                "format": "date",
                "example": "01/15/16"
            }
        }
    }
内联
$ref
定义后,Swagger文档如下所示:

"401": {
    "$ref": "#/responses/UnauthorizedRequest"
},
"500": {
    "$ref": "#/responses/ServerError"
}
"responses": {
    "200": {
        "description": "Task retrieved",
        "schema": {
          "type": "object",
          "required": [
              "deadline",
              "description",
              "status"
          ],
          "properties": {
              "description": {
                  "type": "string",
                  "example": "Make an app for Demo"
              },
              "status": {
                  "type": "string",
                  "example": "Created"
              },
              "deadline": {
                  "type": "string",
                  "format": "date",
                  "example": "01/15/16"
              }
          }
        }
    },
    "404": {
        "description": "Task not found"
    }
}

谢谢我会尝试。我会考虑完全导入一个符合OpenAPI的规范,一个普通的“特性”。我知道这可能被视为一种“便利功能”,但在某些客户场景中,仅仅为了在API管理平台中导入而手动“优化”一个招摇过市的规范可能是不可接受的。OpenAPI规范文件应该对所有常见的API用例普遍有效,例如文档、客户端存根生成、服务器存根生成,当然还有API管理。我将为此“功能”打开RFE。