Open Star-Forever-007 opened 1 year ago
@Star-Forever-007 This is too complex. I think it would be sufficient to support the time type annotations of the JSON library. For interfaces, time can only be of two types: string/long. As for the intermediate class casting, we do not have the technology to support it, which makes it complex for users and also complicates the maintenance of Smart-Doc's code. 这样太复杂了,我觉得也就是支持下json库时间类型注解就可以了,时间对于接口就只能是string/long两种类型。至于中间写类强转的我们没有支持的技术,用户用起来复杂,smart-doc代码维护也复杂
下图是我们使用spring boot默认继承的jackson下对全局日期类型的配置,但仅对java.util.Date有效,为此我们也进行了独立的补充,补充这里就不再做赘述了, json库时间类型的注解,如果这样的话,所有的bean实体都需要加注解,实际上我们更期望有一个默认的,注解是特殊场景下标注的,这样能够满足默认和独立双重需要 个人的想法不知道是否符合你们的要求, 即: smart-doc.json 中增加如下配置,可选,文档输出时有则优先使用,没有则走原始逻辑 dateFormat:{ type: "timestamp / string", fortmat: "yyyy/MM/dd HH:mm:ss" } 格式优先级: bean上的jackson/fastjson日期类型注解 > smart-doc.json#dateFormat > 兜底默认 个人感觉:最高级别的实施复杂度高于后两个次两级的,具体你们在这里更有经验,看看是否可以规划版本进行实施。
Summary(关于这个pr的描述)
When the request and response parameters include Date types, regardless of java.sql.Date, joda.DateTime, LocalDate, LocalDateTime, or other date types, they are currently all returned as Strings in the yyyy-MM-dd HH:mm:ss format. 当请求参数以及响应参数中有Date类型,不论java.sql.Date , joda.DateTime, LocalDate, LocalDateTime 等日期类型,现在均返回string及 yyyy-MM-dd HH:mm:ss 格式
Basic example(pr的用例)
@Data public class RequestUserParam{ private Date createTime; private Date updateTime; }
@Data public class ResponseUserVo{ private Date createTime; private Date updateTime; } All date types are String and cannot be changed. 所有日期类型均为string并不可变更
Motivation(提出这个pr目的)
During implementation, we support various inputs such as yDuring implementation, we support various inputs such as y-dd HH:mm while the response parameter date types are uniformly standardized to be returned as timestamps. Therefore, there is a discrepancy between the generated documentation's response parameters and the actual requests.
It is expected that the date type can be customized with user-defined types and formats. Example: 我们在实施的过程中,输入支持 yyyy-MM-dd HH:mm:ss 或时间戳等多种输入,而响应参数的日期类型则统一规范了返回为时间戳,故而生成文档的响应参数与真实请求出现了差异
期望日期类型可以自定义类型及格式 例:
When the dateFormat type is set to timestamp, it should return a long type; other formats can be customized. 当dateFormat type为 timestamp时,则返回long类型,其他可以自定义格式