xiaoymin / knife4j

Knife4j is a set of Swagger2 and OpenAPI3 All-in-one enhancement solution
https://doc.xiaominfo.com
Apache License 2.0
4.08k stars 614 forks source link

实体类属性字段都是大写的时候,使用4.2.0版本springdoc注解@Schema没有生成参数说明 #633

Open wangran99 opened 1 year ago

wangran99 commented 1 year ago

Describe the bug 使用springdoc注解@Schema(description = "用户名") 实体类,controller返回实体对象,但是文档没有显示实体对象属性的参数说明。

To Reproduce Steps to reproduce the behavior:

  1. 定时实体对象SysUserinfo.JAVA,并用spingdoc注解@Schema(description = "用户名") :

2.controller返回该类的对象 image

Expected behavior 期望doc.html文档生成该接口返回数据的字段说明,但是没有生成字段说明。

Screenshots If applicable, add screenshots to help explain your problem.

Knife4j Version (please complete the following information): `

com.github.xiaoymin knife4j-openapi3-jakarta-spring-boot-starter 4.2.0

`

Additional context springboot版本: 3.1.2

用户信息实体类(属性字段都是大写):

`import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size;

import java.io.Serializable; import java.time.LocalDateTime; import lombok.Data;

import java.time.LocalDateTime; import io.swagger.v3.oas.annotations.media.Schema; import org.hibernate.validator.constraints.Length;

/**

} `

配置文件:

`

mybatis数据库配置

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver spring.datasource.url=jdbc:oracle:thin:@192.168.0.143:1521:ITARGE spring.datasource.username=itarge spring.datasource.password=itarge

#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射 address_book ---> addressBook mybatis-plus.configuration.map-underscore-to-camel-case=false

显示mybatis-plus查询sql(如果不需要显示sql,可以注释该行)

mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

redis配置

spring.data.redis.host=192.168.0.44 spring.data.redis.port=6379

springdoc.packagesToScan=com.laowang.springboot3template, com.package2 springdoc.swagger-ui.path=/swagger-ui.html `

doc.html页面截图: image

wangran99 commented 1 year ago

是不是跟Userinfo.java属性字段都是大写字母有关或者跟Jackson序列化到前端的字母都是小写有关,谢谢~~

wangran99 commented 1 year ago

如果 @Schema(description = "用户ID") 注解到实体类的get,set方法,就可以产生文档说明。 经过测试发现,实体类的属性字段都是大写,配置文件的Jackson未使用驼峰。如果实体类属性都是小写可以生成文档。配置的Mybatis-Plus:

#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射 address_book ---> addressBook
mybatis-plus.configuration.map-underscore-to-camel-case=false