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

Currently, the parameters are generated by traversing fields. Is it possible to change this to generate them by traversing set methods instead? #510

Open
LeeMeo opened this issue May 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@LeeMeo
Copy link

LeeMeo commented May 25, 2023

Your Environment(您的使用环境)

  • smart-doc version: 2.6.9
  • plugin version (e.g. smart-doc-maven-plugin or smart-doc-gradle-plugin): smart-doc-maven-plugin-2.6.9
  • build tool version(maven or gradle): maven

Expected Behavior(您期望的结果)

The parameters should be: aName, aCode, bName, bCode.
入参应该是:aName, aCode, bName, bCode

Current Behavior(当前结果)

The current result's parameters are: testA.aName, testA.aCode, testB.bName, testB.bCode.
当前结果的入参是:testA.aName, testA.aCode, testB.bName, testB.bCode
image

Possible Solution(bug解决建议)

In Spring MVC, parameter assignment actually calls the set method, not directly setting the field's value. However, Smart-Doc generates documentation by traversing the fields of the parameters, which is inconsistent with how it actually runs.

spring mvc 的入参赋值,其实是调用的set方法,并不是直接设置field的值,而smart-doc则是遍历入参的field并生成文档,这与实际运行情况不符。

Steps to Reproduce (Bug产生步骤,请尽量提供用例代码)

eg:
image
image

Context(Bug影响描述)

@LeeMeo LeeMeo added the bug Something isn't working label May 25, 2023
@shalousun
Copy link
Collaborator

shalousun commented May 26, 2023

@LeeMeo
This has nothing to do with Spring MVC. The native Java parsing is correct. Your approach mainly uses Lombok's @DeleGate for forced delegation, which modifies the code during compilation. Smart-Doc currently does not support these kinds of changes made by Lombok to the source code. The community hasn't had the capacity to work on this recently. If you're interested, you could submit a PR to enhance it.
这个和springmvc没什么关系,原生java写法这样解析是对的,你们这个主要是用了lombok的@DeleGate强制委派,代码编译的时候被修改了,smart-doc目前是不支持lombok这些对源代码的改变的。社区最近没有精力搞,有兴趣可以提pr增强下

@LeeMeo
Copy link
Author

LeeMeo commented May 26, 2023

@shalousun It's not about using or not using Lombok; the result is the same even without Lombok. The example code is as follows:
image
Spring MVC automatically sets parameters through set methods, which is slightly different from the way Smart-Doc does it.

This has been verified; actually, there are two request methods that can be used, for example:

http://localhost:8080/testConstants2?testA.aName=a
http://localhost:8080/testConstants2?aName=a

If you're interested, you can submit a PR to support the second method. It's rare not to use delegation when writing set methods separately, and currently, JSON is the mainstream for parameter input.

@shalousun shalousun changed the title 入参目前是遍历field生成,能否改为遍历set方法来生成? Currently, the parameters are generated by traversing fields. Is it possible to change this to generate them by traversing set methods instead? Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants