TongchengOpenSource / smart-doc

Smart-doc is a java restful api document generation tool. Smart-doc is based on interface source code analysis to generate interface documentation, completely zero-injection.
https://smart-doc-group.github.io/#/
Apache License 2.0
1.43k stars 278 forks source link

Incorrect Parameter Location for Unannotated Parameters in API Documentation #965

Closed linwumingshi closed 2 days ago

linwumingshi commented 2 days ago

Contact Details

No response

Version

3.0.9

Plugin

smart-doc-maven-plugin

Build tool version

3.9.6

Jdk version

17

Describe the bug (Bug描述,社区已开启国际化推广,请用文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

When a request contains both a @RequestBody parameter and an unannotated form parameter (e.g., BasePager), the generated API documentation incorrectly places the unannotated parameter (BasePager) in the request body. However, it should be documented as part of the query parameters instead.

Example

Consider the following API method:

/**
 * Accept query parameters and JSON data in the request body.
 *
 * @param pager 分页对象 Pagination object
 * @param car   汽车对象 Car object
 * @return 包含分页信息的通用结果 Common result with pagination details
 */
@PostMapping("/query-and-body")
public CommonResult<BasePager> receiveQueryAndBody(BasePager pager, @RequestBody Car car) {
    return CommonResult.ok(pager);
}

In this case:

However, the current behavior places both pager and car in the Request Body, which is incorrect.

Expected Behavior (您期望的结果,社区已开启国际化推广,请用文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

The generated API documentation should:

  1. List BasePager parameters under Query Parameters.
  2. Only include Car in the Request Body.

Current Behavior (当前结果,社区已开启国际化推广,请用文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

Body-parameters:

Parameter Type Required Description Since
concurrentPage int32 false 当前页 -
pageSize int32 false 当前page -
name string false 车名称 -
length double false 长度 -
pager object false 分页 -
└─concurrentPage int32 false 当前页 -
└─pageSize int32 false 当前page -
└─total int32 false 记录总数 -

Steps to Reproduce (Bug产生步骤,请尽量提供用例代码。社区已开启国际化推广,请用文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

  1. Define an API method with both a @RequestBody parameter and an unannotated form parameter.
  2. Generate API documentation using Smart-Doc.
  3. Observe the incorrect parameter placement in the generated documentation.

Possible Solution (Bug解决建议,社区已开启国际化推广,请用文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

No response

Context (Bug影响描述,社区已开启国际化推广,请用文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

No response

Validations