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

Whether to support using @JsonProperty configuration name first when generating document properties #937

Open
3 tasks done
yangyf520 opened this issue Oct 30, 2024 · 12 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@yangyf520
Copy link

Is your feature request related to a problem? Please describe.(关于这个PR的描述,社区已开启国际化推广,请文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

老项目接口参数采用非驼峰式命名,生成文档属性时是否支持优先使用@JsonProperty配置名称

Basic example (PR的用例,社区已开启国际化推广,请文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

@JsonProperty("exp_from")
private LocalDate expirationFrom;

Describe the solution you'd like (描述您想要的解决方案,社区已开启国际化推广,请文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

生产的postman和doc里对应参数名是exp_from

Describe alternatives you've considered (描述你考虑过的替代方案,社区已开启国际化推广,请文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

No response

Additional context (其他背景信息,社区已开启国际化推广,请文心一言、讯飞星火等辅助翻译成英文,减少社区开发者的工作)

No response

Validations

  • Read the docs. (请先阅读官方文档)
  • Read the Contributing Guidelines. (请先阅读官方文档·贡献指南)
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. (检查是否存在报告相同错误的问题,以避免产生重复)
@linwumingshi linwumingshi changed the title 生成文档属性时是否支持优先使用@JsonProperty配置名称 Whether to support using ·@JsonProperty· configuration name first when generating document properties Oct 30, 2024
@linwumingshi linwumingshi changed the title Whether to support using ·@JsonProperty· configuration name first when generating document properties Whether to support using @JsonProperty configuration name first when generating document properties Oct 30, 2024
@linwumingshi
Copy link
Collaborator

@yangyf520 smart-doc has supported generating corresponding properties using the Jackson annotation @JsonProperty since version 2.1.8.

Releases 2.1.8


@yangyf520
Next time, if you need to write in Chinese, please use Qwen or other tools to translate it into English. The smart-doc community is currently a global open-source community, and we have invested a lot of effort into promoting it overseas. Community developers have also put in a great deal of work to do translations. Therefore, we appreciate understanding and respect for their efforts.

@linwumingshi linwumingshi added question Further information is requested help wanted Extra attention is needed labels Oct 30, 2024
@yangyf520
Copy link
Author

@yangyf520 smart-doc has supported generating corresponding properties using the Jackson annotation @JsonProperty since version 2.1.8.

Releases 2.1.8

@yangyf520 Next time, if you need to write in Chinese, please use Qwen or other tools to translate it into English. The smart-doc community is currently a global open-source community, and we have invested a lot of effort into promoting it overseas. Community developers have also put in a great deal of work to do translations. Therefore, we appreciate understanding and respect for their efforts.

需要配置么,我现在用的是3.0.1版本

@linwumingshi
Copy link
Collaborator

linwumingshi commented Oct 31, 2024

@yangyf520

Next time, if you need to write in Chinese, please use Qwen or other tools to translate it into English.

The smart-doc community is currently a global open-source community, and we have invested a lot of effort into promoting it overseas. Community developers have also put in a great deal of work to do translations. Therefore, we appreciate understanding and respect for their efforts.

No configuration is needed; smart-doc will automatically parse.

If you use the version is not the latest version, please upgrade to the latest version and try again!

@yangyf520
Copy link
Author

yangyf520 commented Oct 31, 2024

@yangyf520

Next time, if you need to write in Chinese, please use Qwen or other tools to translate it into English.

The smart-doc community is currently a global open-source community, and we have invested a lot of effort into promoting it overseas. Community developers have also put in a great deal of work to do translations. Therefore, we appreciate understanding and respect for their efforts.

No configuration is needed; smart-doc will automatically parse.

If you use the version is not the latest version, please upgrade to the latest version and try again!

But postman now displays expirationFrom not exp_from

built with mvn -X smart-doc:postman -Dfile.encoding=UTF-8 -pl :web-app -am

@shalousun
Copy link
Collaborator

@yangyf520 upgrade to the latest version and try again,If the latest version still has issues, you can use "requestFieldToUnderline": true, and "responseFieldToUnderline": true, to globally transform.

@yangyf520
Copy link
Author

@yangyf520 upgrade to the latest version and try again,If the latest version still has issues, you can use "requestFieldToUnderline": true, and "responseFieldToUnderline": true, to globally transform.

Just 5 interface methods

@linwumingshi
Copy link
Collaborator

@yangyf520 Please provide a minimal sample application that reproduces the issue to help us resolve it more efficiently. I have tested locally and was unable to reproduce your problem.

@yangyf520
Copy link
Author

yangyf520 commented Oct 31, 2024

Please provide a minimal sample application that reproduces the issue to help us resolve it more efficiently. I have tested locally and was unable to reproduce your problem.

Vo file like this:

@Data
public class SublicenseVo  implements Serializable {
    /**
     * 描述
     */
    private String description;

    /**
     * 开始日期,exp_from
     *
     * @mock 2024-10-18
     */
    @NotNull
    @JsonProperty("exp_from")
    @DateTimeFormat(pattern = Constants.FORMAT_DATE)
    private LocalDate expirationFrom;
}

controller file like this:

@PostMapping(value = "/sublicenses")
public LicenseDto sublicenses(@ModelAttribute SublicenseVo vo, HttpServletRequest request) {
    
}

@linwumingshi
Copy link
Collaborator

@yangyf520 Smart-doc currently does not support interface input parameters annotated with @ModelAttribute.

@yangyf520
Copy link
Author

thank u

@linwumingshi
Copy link
Collaborator

@yangyf520 In my demo project, the @JsonProperty annotation works correctly, and the generated documentation supports these annotations. Please check the attached demo
demo.zip

@linwumingshi
Copy link
Collaborator

test

Version Update Time Status Author Description
0.0.1-SNAPSHOT 2018-06-27 Create Smart-Doc Smart-Doc Example Project
0.0.1-SNAPSHOT 2024-01-01 Active Smart-Doc Smart-Doc Example Project

TestController

testUser

URL: http://127.0.0.1:8080

Type: POST

Content-Type: application/x-www-form-urlencoded

Description: testUser

Body-parameters:

Parameter Type Required Description Since
username string false username -
password string false password -
exp_from string false expiration from -

Request-example:

curl -X POST -i 'http://127.0.0.1:8080/' --data 'username=""&expirationFrom="yyyy-MM-dd"&password=""'

Response-fields:

Field Type Description Since
username string username -
password string password -
exp_from string expiration from -

Response-example:

{
  "username": "",
  "password": "",
  "exp_from": "yyyy-MM-dd"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants