smart-doc生成java 接口文檔

smart-doc是一個java restful api文檔生成工具,smart-doc顛覆了傳統(tǒng)類似swagger這種大量采用注解侵入來生成文檔的實(shí)現(xiàn)方法。smart-doc完全基于接口源碼分析來生成接口文檔,完全做到零注解侵入,只需要按照java標(biāo)準(zhǔn)注釋的寫就能得到一個標(biāo)準(zhǔn)的markdown接口文檔。如果你已經(jīng)厭倦了swagger等文檔工具的注解和強(qiáng)侵入污染,那請擁抱smart-doc吧!目前smart-doc正在完善中。。。
添加依賴

        <dependency>
            <groupId>com.github.shalousun</groupId>
            <artifactId>smart-doc</artifactId>
            <version>1.1</version>
            <scope>test</scope>
        </dependency>

//嚴(yán)格模式下,會檢測javadoc,如過沒寫注釋會拋出異常

/**
 * hello
 *
 * @author <a >dujf</a>
 * @date 2018/8/31
 * @since JDK1.8
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

  /**
   * 創(chuàng)建
   *
   * @param user
   * @return
   */
  @PostMapping
  public User create(User user) {
    return user;
  }

  /**
   * 查詢
   *
   * @param name 用戶名
   * @return
   */
  @GetMapping
  public User getName(String name) {
    return new User();
  }

  /**
   * 修改
   *
   * @param name
   * @return
   */
  @PutMapping
  public String update(String name) {
    return name;
  }

  /**
   * 刪除
   *
   * @param name
   * @return
   */
  @DeleteMapping
  public String delete(String name) {
    return name;
  }
}

/**
 * 用戶表
 * @author <a >dujf</a>
 * @date 2018/8/31
 * @since JDK1.8
 */
public class User {

  /**
   * 姓名
   */
  @NotNull//有此注解生成文檔require = true
  private String name;

  /**
   * 電話
   */
  private String mobile;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getMobile() {
    return mobile;
  }

  public void setMobile(String mobile) {
    this.mobile = mobile;
  }
}
/**
   * 測試生成文檔
   */
  @Test
  public void testBuilderControllersApiSimple() {
    ApiConfig config = new ApiConfig();
    //服務(wù)地址
    config.setServerUrl("http://localhost:8010");
    //生成到一個文檔
    config.setAllInOne(true);
    //采用嚴(yán)格模式
    config.isStrict();
    //文檔輸出路徑
    config.setOutPath("/Users/dujf/Downloads/md");
    ApiDocBuilder.builderControllersApi(config);
    //將生成的文檔輸出到/Users/dujf/Downloads/md目錄下,嚴(yán)格模式下api-doc會檢測Controller的接口注釋
  }

生成文檔示例:


image.png

image.png

項(xiàng)目地址:https://gitee.com/athe/smart-doc-spring-boot

參考鏈接:https://github.com/shalousun/ApplicationPower/tree/master/smart-doc

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、背景 在當(dāng)今各種盛行的前后端分離、restful service開發(fā)過程中,接口文檔是必不可少的。對于前后端分...
    shalousun閱讀 1,473評論 1 2
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,741評論 25 709
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,506評論 19 139
  • 大家好,我是辣椒先生HOT。 千島國的稱呼,是印度尼西亞旅游的一張名片。 我覺得這是在挑釁咱們的地理常識,明明有1...
    辣椒先生HOT閱讀 662評論 3 7
  • 下午天籟補(bǔ)胎 王博和客戶溝通后需要換胎 最后溝通后因?yàn)閮r格的原因 客戶覺得貴 最后在店長的同意后換了四條路航輪胎...
    31馬赫閱讀 132評論 0 0

友情鏈接更多精彩內(nèi)容