-
Notifications
You must be signed in to change notification settings - Fork 280
Smart doc custom javadoc tags
cqmike edited this page Aug 28, 2021
·
3 revisions
Since java native javadoc tags are not many, some special scenes cannot use the existing javadoc tag to complete the markup of the document, so smart-doc customizes some javadoc tags.
tag | description |
---|---|
@ignore | The ignore tag is used to filter a field on the request parameter object. After setting, smart-doc does not output the field to the request parameter list. |
@required | If you do not use the JSR303 validation specification to validate the parameter fields, you can use the @required tag to annotate the fields of the request parameter object. After the annotation, smart-doc will ask for the field to be required when outputting the parameter list. |
@mock | Used to set custom document display values in the basic object type field. After setting the value, smart-doc no longer generates random values. It is convenient to directly output delivery documents through smart-doc. |
@dubbo | Used to mark that this is a dubbo interface, so that smart-doc can scan the dubbo rpc interface to generate documents. |
@restApi | Used to support smart-doc to scan Spring Cloud Feign's defined interface to generate documentation. |
@order | It is used to set the custom sort order number of the controller interface or api entry. @order 1 means that the order number is set to 1. |
@ignoreResponseBodyAdvice | A wrapper class used to ignore ResponseBodyAdvice settings. |
@download | It is used to mark the file download method of the controller and tell smart-doc that this is a download interface. |
@page | The annotation method is used to render and return a static page. If a test is initiated when the debug page is generated, the browser will automatically open a new tab to display the page. |
@tag | @since 2.2.5, @tag is used to categorize controller methods. You can assign methods under different controllers to multiple categories, and you can also directly assign controllers to one category or multiple categories. |
public class User {
/**
* name
*/
private String name;
/**
* id card
*/
private String idCard;
/**
* gender
*/
private int gender;
/**
* create time
* @ignore
*/
private Timestamp createTime;
}
In the Spring Boot Controller, User is used as the parameter receiving object. The parameter request document output by smart-doc is as follows:
Parameter | Type | Description | Required |
---|---|---|---|
name | string | name | false |
idCard | string | id card | false |
gender | int | gender | false |
public class User {
/**
* name
*/
private String name;
/**
* id card
* @required
*/
private String idCard;
/**
* gender
*/
private int gender;
/**
* create time
* @ignore
*/
private Timestamp createTime;
}
In the Spring Boot Controller, User is used as the parameter receiving object. The parameter request document output by smart-doc is as follows:
Parameter | Type | Description | Required |
---|---|---|---|
name | string | name | false |
idCard | string | id card | true |
gender | int | gender | false |
/**
* json file config test
* @tag dev
* @author cqmike 2021-07-16 14:09
**/
@RestController
public class ConfigRequestParamController {
/**
* get request test query param
* @tag test
* @author cqmike
* @return
*/
@GetMapping("configQueryParamGet")
public void configQueryParamGet(String configQueryParam) {
}
/**
* post request test query param
*
* @tag test
* @author cqmike
* @return
*/
@PostMapping("configQueryParamPost")
public void configQueryParamPost(String configQueryParam) {
}
}