sc-docs 可以根据Java docs规范以及springmvc 注解,jsr 311注解 生成 swagger 文档,无需侵入到项目之中
At first generate the JAR by executing:
mvn package
Then manually install the following JARs:
- target/sc-docs.jar
curl -o sc-docs.jar -L https://github.com/wu191287278/sc-docs/releases/download/v2.8.0/sc-docs.jar
/**
* 搜索接口
*/
@RestController
@RequestMapping(value="/search")
public class SearchController {
/**
* 搜索用户
*
* @param nickname 用户昵称
* @throws 未找到用户
* @return 用户列表
*/
@GetMapping(value = "user")
public String user(@RequestParam(value = "nickname") String nickname) throws NotFoundException{
return "user:"+nickname;
}
}
git clone https://github.com/shuzheng/zheng.git
java -jar sc-docs.jar -i ./zheng -o ./docs
java -jar sc-docs.jar -serve ./docs
usage: java -jar sc-docs.jar [-i <arg>] [-o <arg>] [-serve <arg>] [-t]
-i,--input <arg> Source directory
-o,--output <arg> Output directory
-serve <arg> Start server
Name | Description |
---|---|
-Ddocs.projectName.host=localhost | 指定host |
-Ddocs.projectName.basePath=/ | 指定基础路径 |
-Ddocs.projectName.scheme=http | 指定http/https |
-Ddocs.projectName.info.title=demo | 指定标题 |
java -Ddocs.projectName.host=localhost:8080 -Ddocs.projectName.scheme=http -Ddocs.projectName.info.title=demo -jar sc-docs.jar -i sourceDirectory -o outDirectory -t