Easily generate Swagger and Protostuff annotations with one click, generate JavaDoc with various data sources. deleting various elements can also be done with one click.
- Jetbrains IntelliJ IDEA / Android studio Plugin.
- For Controller class or POJO class, you can easily generate Protostuff annotations ' @Tag ' with one click and convert JavaDoc to Swagger annotations ' @Api, @ApiOperation, @ApiModel, @ApiModelProperty ' with one click. In turn, you can convert Swagger annotations to JavaDoc with a single click.
- You can generate a JavaDoc for the specified field , please note that this is not generated by 'translation' , but fuzzy matching the project with the same name field , matching its comments and Swagger annotations , extracted and populated with JavaDoc for the specified field.
- B站有精心制作的视频可以看,视频在YouTube也放了一份
- B站还有专栏文章写的更详细一些,文章在简书里也放了一份
- Jetbrains IntelliJ IDEA / Android studio 插件.
- 作用于 Controller 类或 POJO 类,你可以很方便的一键生成 Protostuff 注解 ' @Tag ' ,并且可以一键直接将 JavaDoc 转换为 Swagger 注解 ' @Api, @ApiOperation, @ApiModel, @ApiModelProperty '。反过来,你也可以一键将 Swagger 注解转换为 JavaDoc。
- 可以生成指定字段的JavaDoc,请注意这并不是通过'翻译'生成的,而是模糊匹配项目中的同名字段,匹配其注释及Swagger注解,提取并填充为指定字段的JavaDoc。
- You can generate Swagger annotations ' @Api, @ApiOperation, @ApiModel, @ApiModelProperty ' with one click, and Protostuff annotations ' @Tag ' with one click via the right-click menu.
- you can through the right-click menu , one-click Swagger annotations converted to JavaDoc annotations.
- With the cursor pointing to the name of a class, field or method, right-clicking Execute allows you to process only that element. When the cursor is pointing elsewhere, right-click to perform unified processing for all elements in the current file.
- You can remove the JavaDoc, annotations, etc. of a class, field, or method with a single click via the right-click menu.
- If you only need to work with the Swagger annotation and not the Protostuff annotation and vice versa, don't worry, you can switch between them via the 'settings - tools - Bitkylin Universal Generate' page. Of course, you can also disable the operation of both annotations and only operate JavaDoc.
- You declared the class fields, or declared the method parameter fields, but you do not want to manually write JavaDoc, you can right-click the menu, use the 'Find JavaDoc' feature, the feature can be based on the same name field in the project, exact or fuzzy match its comments and Swagger annotations, to generate the specified fields of the JavaDoc.
- The plugin supports two languages, English and Chinese, which can be switched via the 'settings - tools - Bitkylin Universal Generate' page.
- 你可以通过右键菜单,一键生成Swagger注解 ' @Api, @ApiOperation, @ApiModel, @ApiModelProperty ', 一键生成Protostuff注解 ' @Tag '。
- 你可以通过右键菜单,一键将 Swagger 注解转换为 JavaDoc 注释。
- 光标指向类、字段或者方法的名字,点击右键执行,可以仅针对该元素进行处理。当光标指向其他地方,点击右键,可以对当前文件中的所有元素进行统一处理。
- 你可以通过右键菜单,一键删除类、字段或者方法的 JavaDoc、注解等。
- 如果你只需要操作 Swagger 注解而不需要操作 Protostuff 注解,反之亦然,不用担心,你可以通过 'settings - tools - Bitkylin Universal Generate' 页面进行切换。当然了,你也可以关闭两个注解的操作功能,仅操作JavaDoc。
- 你声明了类的字段,或者声明了方法的入参字段,但是你不想手动编写JavaDoc,你可以通过右键菜单,使用'查找JavaDoc'功能,该功能可以根据项目中的同名字段,精确或模糊匹配其注释及Swagger注解,生成指定字段的JavaDoc。
- 插件支持两种语言,英文和中文,可以通过 'settings - tools - Bitkylin Universal Generate' 页面进行切换。
Class name suffixed with ' Controller ', or with ' @Controller, @RestController ' annotation, you will add ' @Api, @ApiOperation ' annotation when you execute the instruction. Classes with Lombok annotations ' @Data, @Getter, @Setter ' will add ' @ApiModel, @ApiModelProperty, @Tag ' annotation when you execute the instruction.
类名后缀为 ' Controller ',或者有 ' @Controller、@RestController ' 注解,你在执行指令时,会添加 ' @Api, @ApiOperation ' 注解。类上有Lombok注解 ' @Data、@Getter、@Setter ',你在执行指令时,会添加 ' @ApiModel, @ApiModelProperty, @Tag ' 注解。
If you want to generate @Tag annotations for the whole document with a customized starting number, just set the starting number in the first field of the class and execute 'Generate Entry Annotation - Full Document' via the right-click menu, See the next section: Class Format Examples.
如果你想按照自定义的起始序号,生成整个文档的 @Tag 注解,只需要在类中的第一个字段设置起始序号即可,然后通过右键菜单执行'生成入口注解 - 整个文档' ,参见下一节:类格式示例。
@Data
public class TestRequest {
private String name;
}
Above is your declared class and a field, but you don't want to manually write the field's JavaDoc, you can use the 'Search JavaDoc' function via the right-click menu, which can generate the JavaDoc for the specified field based on the same field in the project, matching its comments and Swagger annotations exactly or fuzzy.
上面是你声明的类以及一个属性,但是你不想手动编写属性的JavaDoc,你可以通过右键菜单,使用'查找JavaDoc'功能,该功能可以根据项目中的同名字段,精确或模糊匹配其注释及Swagger注解,生成指定字段的JavaDoc。
import io.protostuff.Tag;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data
public class TestRequest {
@Tag(105)
private String name;
/**
* bitkylin age
*/
private Integer age;
private Address address;
@Setter
@Getter
public static class Address {
@Tag(208)
private String province;
private String city;
private String detailedAddress;
}
}
/**
* test desc
*
* @author bitkylin
*/
@RestController
@RequestMapping('/test')
public class TestController {
/**
* test api one
*/
@PostMapping('/api-one')
public String apiOne(@RequestBody TestRequest request) {
return 'success';
}
}
感谢以下项目提供的灵感与实现方式:
- https://github.com/starcwang/easy_javadoc
- https://github.com/EverSpring/swagger-tool
- https://github.com/huangbaihua001/RestfulToolkitX
-
Using the IDE built-in plugin system:
Settings/Preferences > Plugins > Marketplace > Search for "Bitkylin Universal Generate" > Install
-
Manually:
Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...
- Create a new IntelliJ Platform Plugin Template project.
- Get familiar with the template documentation.
- Adjust the pluginGroup, plugin ID and sources package.
- Adjust the plugin description in
README
(see Tips) - Review the Legal Agreements.
- Publish a plugin manually for the first time.
- Set the
PLUGIN_ID
in the above README badges. - Set the Plugin Signing related secrets.
- Set the Deployment Token.
- Click the Watch button on the top of the IntelliJ Platform Plugin Template to be notified about releases containing new features and fixes.
Plugin based on the IntelliJ Platform Plugin Template.