这篇文章将带你了解如何用spring官方推荐的restdoc去生成api文档。本文创建一个简单的springboot工程,将http接口通过Api文档暴露出来。只需要通过 JUnit单元测试和Spring的MockMVC就可以生成文档。
准备工作
创建工程
引入依赖,其pom文件:
org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.restdocs spring-restdocs-mockmvc test