761 Star 6.6K Fork 1.4K

GVP萧明 / knife4j

 / 详情

[2.0.5]返回值有引用相同实体.示例值没有全部渲染. 只有第一个实体的示例值.

已完成
创建于  
2020-09-17 17:58


输入图片说明
完整JSON

{
    "swagger": "2.0",
    "info": {
        "title": "在线文档",
        "description": "在线API文档",
        "termsOfService": "https://github.com/996icu/996.ICU/blob/master/LICENSE",
        "version": "1.0",
        "contact": {
            "name": "linBq",
            "email": "526509994@qq.com"
        },
        "license": {
            "name": "linBq",
            "url": "http://www.jfinal.com/user/43453"
        }
    },
    "host": "0.0.0.0:8088",
    "basePath": "/api",
    "schemes": [
        "http",
        "https"
    ],
    "externalDocs": {
        "description": "Find out more about Swagger",
        "url": "https://swagger.io/"
    },
    "definitions": {
        "SwaggerRes": {
            "type": "object",
            "title": "响应结果",
            "properties": {
                "success": {
                    "type": "boolean",
                    "description": "请求状态"
                },
                "data": {
                    "originalRef": "data",
                    "$ref": "#/definitions/data",
                    "description": "返回数据"
                },
                "errorCode": {
                    "type": "string",
                    "example": "-1",
                    "description": "错误码"
                },
                "errorMessage": {
                    "type": "string",
                    "example": "错误信息",
                    "description": "错误信息"
                },
                "showType": {
                    "type": "int",
                    "example": "2",
                    "description": "前端错误处理: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page"
                },
                "traceId": {
                    "type": "string",
                    "example": "someid",
                    "description": "方便后端故障排除:唯一请求ID"
                },
                "host": {
                    "type": "string",
                    "example": "127.0.0.1",
                    "description": "当前访问服务器的主机"
                }
            }
        },
        "DeviceParamBean": {
            "type": "object",
            "title": "网关附加数据",
            "properties": {
                "vobcId": {
                    "type": "integer",
                    "example": 1,
                    "description": "车载设备id"
                },
                "machineId": {
                    "type": "integer",
                    "example": 2,
                    "description": "机具id"
                },
                "machineStateThreshold": {
                    "type": "string",
                    "example": "20",
                    "description": "农机状态阈值"
                },
                "posReportRate": {
                    "type": "string",
                    "example": "3",
                    "description": "轨迹上报频率"
                }
            }
        },
        "EquipDto": {
            "type": "object",
            "title": "农机具",
            "properties": {
                "equipId": {
                    "type": "int",
                    "example": "11",
                    "description": "农机具id"
                },
                "equipCode": {
                    "type": "string",
                    "example": "2009080002",
                    "description": "农机具号"
                },
                "equipTypeId": {
                    "type": "string",
                    "example": "2009080002",
                    "description": "农机具号"
                },
                "status": {
                    "type": "int",
                    "example": "0",
                    "description": "状态 0 正常"
                },
                "taskWidth": {
                    "type": "string",
                    "example": "20",
                    "description": "作业宽幅"
                },
                "pointStateThresholdStart": {
                    "type": "string",
                    "example": "40",
                    "description": "点位状态阈值上限"
                },
                "pointStateThresholdEnd": {
                    "type": "string",
                    "example": "60",
                    "description": "点位状态阈值下限"
                },
                "createTime": {
                    "type": "string",
                    "example": "yyyy-MM-dd HH:mm:ss",
                    "description": "创建时间"
                },
                "updateTime": {
                    "type": "string",
                    "example": "yyyy-MM-dd HH:mm:ss",
                    "description": "创建时间"
                },
                "deviceParamBean": {
                    "originalRef": "DeviceParamBean",
                    "$ref": "#/definitions/DeviceParamBean",
                    "description": "网关附加数据"
                }
            }
        },
        "MachineDto": {
            "type": "object",
            "title": "农机",
            "properties": {
                "machineName": {
                    "type": "string",
                    "example": "1",
                    "description": "农机id"
                },
                "machineStatus": {
                    "type": "int",
                    "example": "0",
                    "description": "农机状态 0正常 -1报废"
                },
                "equipDto": {
                    "originalRef": "EquipDto",
                    "$ref": "#/definitions/EquipDto",
                    "description": "农机局"
                },
                "equipDtoList": {
                    "type": "array",
                    "items": {
                        "originalRef": "EquipDto",
                        "$ref": "#/definitions/EquipDto"
                    },
                    "description": "农机局集合"
                }
            }
        },
        "simple_test6": {
            "type": "object",
            "title": "",
            "properties": {
                "resA": {
                    "type": "string",
                    "example": "hello word1",
                    "description": "返回值A"
                },
                "resB": {
                    "type": "string",
                    "example": "hello word2",
                    "description": "返回值b"
                },
                "equip": {
                    "originalRef": "EquipDto",
                    "$ref": "#/definitions/EquipDto",
                    "description": "农机具信息"
                },
                "equipList": {
                    "type": "array",
                    "items": {
                        "originalRef": "EquipDto",
                        "$ref": "#/definitions/EquipDto"
                    },
                    "description": "农机具集合"
                },
                "machine": {
                    "originalRef": "MachineDto",
                    "$ref": "#/definitions/MachineDto",
                    "description": "农机信息"
                }
            }
        },
        "SwaggerRes«simple_test6»": {
            "type": "object",
            "title": "",
            "properties": {
                "success": {
                    "type": "boolean",
                    "description": "请求状态"
                },
                "data": {
                    "originalRef": "simple_test6",
                    "$ref": "#/definitions/simple_test6",
                    "description": "返回值"
                },
                "errorCode": {
                    "type": "string",
                    "example": "-1",
                    "description": "错误码"
                },
                "errorMessage": {
                    "type": "string",
                    "example": "错误信息",
                    "description": "错误信息"
                },
                "showType": {
                    "type": "int",
                    "example": "2",
                    "description": "前端错误处理: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page"
                },
                "traceId": {
                    "type": "string",
                    "example": "someid",
                    "description": "方便后端故障排除:唯一请求ID"
                },
                "host": {
                    "type": "string",
                    "example": "127.0.0.1",
                    "description": "当前访问服务器的主机"
                }
            }
        }
    },
    "securityDefinitions": {
        "token": {
            "type": "apiKey",
            "name": "token",
            "in": "header"
        },
        "testPara": {
            "type": "apiKey",
            "name": "testPara",
            "in": "query"
        }
    },
    "tags": [
        {
            "name": "最简用法",
            "description": "/api/simple (SimpleController)"
        }
    ],
    "paths": {
        "/simple/test6": {
            "get": {
                "tags": [
                    "最简用法"
                ],
                "summary": "返回值Object嵌套Object",
                "description": "递归实现",
                "operationId": "get_simple_test6",
                "produces": [
                    "*/*"
                ],
                "parameters": [
                    {
                        "name": "paramA",
                        "description": "参数a",
                        "in": "query",
                        "type": "String",
                        "default": "1111",
                        "required": false
                    },
                    {
                        "name": "paramB",
                        "description": "参数b",
                        "in": "query",
                        "type": "String",
                        "default": "222",
                        "required": false
                    }
                ],
                "responses": {
                    "200": {
                        "schema": {
                            "originalRef": "SwaggerRes«simple_test6»",
                            "$ref": "#/definitions/SwaggerRes«simple_test6»"
                        },
                        "description": "请求成功"
                    },
                    "400": {
                        "description": "服务器不理解请求的语法"
                    },
                    "403": {
                        "description": "服务器拒绝请求"
                    },
                    "404": {
                        "description": "服务器找不到请求的网页"
                    },
                    "405": {
                        "description": "禁用请求中指定的方法"
                    },
                    "500": {
                        "description": "服务器遇到错误,无法完成请求"
                    }
                }
            }
        }
    }
}

评论 (5)

l745230 创建了任务
l745230 关联仓库设置为萧明/knife4j
展开全部操作日志

是的,不然死循环么

这个就是递归,如果都要显示,那么怎么显示?

@萧明
确实有存在递归死循环的可能.
是否考虑支持下JSON最多展开到4-5级呢.

从这个示例来说.妥妥的被误伤了.并没有存在互相依赖的情况.(ps 尝试了下互相依赖的情况.在解析为ApiJson的时候java就抛出内存泄露了. 到不了UI渲染.)

@l745230 展开4-5 我觉得没什么必要,反而对看文档的人造成困扰

好吧,影响不大. 已经生成了返回值文档了. 示例JSON锦上添花倒也不是那么在意

萧明 任务状态待办的 修改为已完成
萧明 添加了
 
question
标签

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
118100 xiaoym 1578918321
Java
1
https://gitee.com/xiaoym/knife4j.git
git@gitee.com:xiaoym/knife4j.git
xiaoym
knife4j
knife4j

搜索帮助