在Swagger UI中呈现为空数组的对象数组
我在OpenAPI/Swagger规范中有以下模型定义:在Swagger UI中呈现为空数组的对象数组,swagger,swagger-ui,Swagger,Swagger Ui,我在OpenAPI/Swagger规范中有以下模型定义: "definitions": { "models.Equipment": { "title": "Equipment", "type": "object", "properties": { "Features": { "type": "array", "items": {
"definitions": {
"models.Equipment": {
"title": "Equipment",
"type": "object",
"properties": {
"Features": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Feature"
}
},
"Id": {
"type": "integer",
"format": "int64"
},
"IdType": {
"type": "string"
},
"Name": {
"type": "string"
},
"Price": {
"type": "integer",
"format": "int32"
}
}
},
"models.Feature": {
"title": "Feature",
"type": "object",
"properties": {
"Equipments": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Equipment"
}
},
"Id": {
"type": "integer",
"format": "int64"
},
"IdFeature": {
"$ref": "#/definitions/models.Feature"
},
"Name": {
"type": "string"
}
}
}
}
在功能
模型中,设备
属性被定义为设备
模型的数组,但Swagger UI 3.x将其呈现为空数组[]
。到处都使用Feature
模型,例如Feature
中的POST
方法,我有这种显示
这个定义在某种程度上是不正确的吗
完整的规范如下:这似乎是Swagger UI中的一个缺陷,很可能是由模型中的循环引用引起的-
模型。设备
引用<代码>模型。功能和<代码>模型。功能引用<代码>模型。设备。您可以在GitHub上的中打开问题
您的规范还包含响应定义中的错误:
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/models.Equipment"
}
},
"403": {}
}
每个响应,因此正确的版本为:
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.Equipment"
}
},
"403": {
"description": "Oops"
}
}
非常感谢你重新表述了一切,我对这个问题一直很懒散,很抱歉。再次感谢您发现错误!:)以下是我报告的问题: