Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义数组不生效 #836

Open
lpzahd opened this issue Sep 3, 2024 · 0 comments
Open

自定义数组不生效 #836

lpzahd opened this issue Sep 3, 2024 · 0 comments

Comments

@lpzahd
Copy link

lpzahd commented Sep 3, 2024

ssue 标题:

@Schema 注解 type = "array" 不显示为数组类型的问题

Issue 内容:

尊敬的作者,您好!

在使用 Knife4j 时,我遇到了一个关于 @Schema 注解的问题。

问题描述
我在代码中定义了一个字段 tags,并希望通过 @Schema 注解将其描述为数组类型。具体代码如下:

/**
 * 标签
 */
@JsonStringToArray
@Schema(description = "标签列表", type = "array", example = "[热门]")
private String tags;

然而,当我在 Knife4j UI 上查看时,tags 字段仍然显示为 string 类型,而不是我期望的 array 类型。
WechatIMG772

预期行为
我希望 tags 字段能够在 UI 上正确显示为 array 类型,并且例子中可以显示为 ["热门"] 这样的数组格式。

实际行为
目前,tags 字段在 UI 上显示为 string 类型,而不是数组类型。

重现步骤
定义如上所示的字段和注解。
在 Knife4j UI 中查看生成的 API 文档。
相关环境
Knife4j 版本:4.3.0
Spring Boot 版本:2.7.15

可能的原因
我怀疑 @Schema 注解的 type = "array" 可能未正确应用,或者可能需要调整注解使用方式。

请求
希望您能提供一些建议或解决方案,以便在 UI 上正确显示 tags 字段为数组类型。如果需要我提供更多信息,请告知。

非常感谢您的帮助!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant