这个错误看起来像一个限制/错误,但正如错误描述所暗示的,您可以内联定义来解决它。这是一个在 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"
}
}