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

Knife4jUI 页面 DTO 模型显示问题 #52

Open
zfchai opened this issue Apr 28, 2023 · 0 comments
Open

Knife4jUI 页面 DTO 模型显示问题 #52

zfchai opened this issue Apr 28, 2023 · 0 comments

Comments

@zfchai
Copy link

zfchai commented Apr 28, 2023

FastEndpoint 框架中使用 Knife4jUIFastEndpoints.Swagger 的对比。

先定义 4 个 Endpoint ,分别如下:

- MyEndpoint : Endpoint<MyRequest, MyResponse>
- TheyEndpoint : Endpoint<UserRequest<TheyReqDto>, UserResponse<TheyInfo>>
- UserEndpoint : Endpoint<UserRequest<UserReqDto>, UserResponse<UserInfo>>
- YourEndpoint : Endpoint<YourRequest<YourReqDto>, YourResponse<YourInfo>>
  • MyEndpoint (get请求)可以正常显示参数说明(来自 DTO 模型 MyRequest 的属性注释)

image

  • TheyEndpoint (get请求)不能正常显示参数说明(来自 DTO 模型 UserRequest<TheyReqDto> 的属性注释)

image

  • UserEndpoint (get请求)也是类似的问题,但是注意和 TheyEndpoint 对比,在 UserEndpointUserReqDto 属性中还存在 UserFeatures 类型;

  • YourEndpoint (post请求)参数说明 "args": {} 也未能正常显示对应的 DTO 模型属性

image

项目环境配置说明:

<PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

注意:把 GenerateDocumentationFile 设置为 false 再对比查看,显示不一样的效果。

说明:AddSwaggerDoc 中设置了 settings.OperationProcessors.Add(new DefaultValueOperationProcessor());

这几个 Endpoint 注意仔细对比,都有对应参照,在原生 Swagger(FastEndpoints.Swagger) 显示相对正常,但是 Knife4jUI 中显示就不太符合预期。

完整 demo 请查看这里 => Solution1.zip

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