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

Hope to be compatible with the comments in the "io.swagger" annotation #958

Open
3 tasks done
SugarFatFree opened this issue Nov 21, 2024 · 1 comment
Open
3 tasks done

Comments

@SugarFatFree
Copy link

SugarFatFree commented Nov 21, 2024

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

This plugin only supports java native comments, but since my project used the "io.swagger" annotation before, the comments are written in this. If I want to use this plugin, I have to write the native comments again. I wonder if it is compatible with the "io.swagger" annotation?

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

 @ApiOperation("文档收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "docId",value = "文档id"),
            @ApiImplicitParam(name = "status",value = "0、取消收藏;1、收藏"),
    })

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

Hope to be compatible with the annotations and properties of the "io.swagger.annotations" package

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
Copy link
Collaborator

Here is a solution for converting Swagger annotations to JavaDoc comments (with some limitations) for your reference only.


Swagger to JavaDoc Conversion Rules

Scenario 1: For @ApiModelProperty

  1. Input Regex:

    • Match:
      @ApiModelProperty(value = "(.*?)")
      Or:
      @ApiModelProperty("(.*?)")
  2. Output Transformation:

    • Replace with:
      /**
       * $1
       */

Scenario 2: For @ApiOperation

  1. Input Regex:

    • Match:
      @ApiOperation(value = "(.*?)")
  2. Output Transformation:

    • Replace with:
      /**
       * $1
       */

Example Transformations

Example 1: @ApiModelProperty

Before:

@ApiModelProperty(value = "The name of the user")
private String userName;

After:

/**
 * The name of the user
 */
private String userName;

Example 2: @ApiOperation

Before:

@ApiOperation(value = "Fetch the details of a user")
public User getUserDetails(String userId) {
    // Method logic
}

After:

/**
 * Fetch the details of a user
 */
public User getUserDetails(String userId) {
    // Method logic
}

Reformat Code

After the conversion, you can use the Reformat Code command in your IDE (e.g., IntelliJ IDEA or Eclipse) to clean up and align the code formatting for better readability.

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

2 participants