Bluemix:API 管理 - 错误 "Swagger jsonReference"。这是不支持的。我如何解决它?
Bluemix : API Management - error "Swagger jsonReference". This is not supported. How do I fix it?
我尝试以 json 格式导入 swagger 文档。我收到错误
The field paths["/namespaces"].get.responses["401"] uses a Swagger
jsonReference. This is not supported. Remove this field, or in-line
the referenced JSON instead, and resubmit the request.
(为了以防万一,我还附上了屏幕截图)。可能导致错误的代码片段是这样的:
"401": {
"$ref": "#/responses/UnauthorizedRequest"
},
"500": {
"$ref": "#/responses/ServerError"
}
这个内容有什么问题?如果您能指出如何解决问题,我们将不胜感激。
谢谢!
参考:截图
此错误看起来像 limitation/bug,但正如错误描述所暗示的那样,您可以内联定义来绕过它。这是一个在 Swagger 文档中内联引用的示例。
以下 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 文档将如下所示:
"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"
}
}
我尝试以 json 格式导入 swagger 文档。我收到错误
The field paths["/namespaces"].get.responses["401"] uses a Swagger jsonReference. This is not supported. Remove this field, or in-line the referenced JSON instead, and resubmit the request.
(为了以防万一,我还附上了屏幕截图)。可能导致错误的代码片段是这样的:
"401": {
"$ref": "#/responses/UnauthorizedRequest"
},
"500": {
"$ref": "#/responses/ServerError"
}
这个内容有什么问题?如果您能指出如何解决问题,我们将不胜感激。
谢谢!
参考:截图
此错误看起来像 limitation/bug,但正如错误描述所暗示的那样,您可以内联定义来绕过它。这是一个在 Swagger 文档中内联引用的示例。
以下 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 文档将如下所示:
"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"
}
}