Spring Boot闆嗘垚smart-doc鐢熸垚api鏂囨。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot闆嗘垚smart-doc鐢熸垚api鏂囨。相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/filters' title='filters'>filters res href javabean 鍩轰簬鎺ュ彛 api local html java
smart-doc鏄竴涓猨ava restful api鏂囨。鐢熸垚宸ュ叿锛宻mart-doc棰犺浜嗕紶缁熺被浼約wagger杩欑澶ч噺閲囩敤娉ㄨВ渚靛叆鏉ョ敓鎴愭枃妗g殑瀹炵幇鏂规硶銆俿mart-doc瀹屽叏鍩轰簬鎺ュ彛婧愮爜鍒嗘瀽鏉ョ敓鎴愭帴鍙f枃妗o紝瀹屽叏鍋氬埌闆舵敞瑙d镜鍏ワ紝浣犲彧闇€瑕佹寜鐓ava鏍囧噯娉ㄩ噴鐨勫啓锛宻mart-doc灏辫兘甯綘鐢熸垚涓€涓畝鏄撴槑浜嗙殑markdown鎴栨槸涓€涓儚GitBook鏍峰紡鐨勯潤鎬乭tml鏂囨。銆?br/>涓嬮潰灏嗕粙缁嶅浣曞湪Spring Boot椤圭洰涓泦鎴恠mart-doc鐢熸垚涓€涓畝鏄庣殑api鏂囨。銆?/p>娉ㄦ剰锛?/strong> smart-doc宸茬粡琚紑婧愪腑鍥芥敹褰曪紝骞朵笖寮€濮嬭鍥藉唴寰堝寮€鍙戣€呬娇鐢ㄥ埌鑷繁椤圭洰涓揩閫熺敓鎴愭帴鍙f枃妗c€?/p>
娣诲姞smart-doc渚濊禆锛屾敞鎰忔墦鍖呭悗涓嶉渶瑕佸皢smart-doc鎵撳叆鏈€缁堢殑浜у搧鍖咃紝鍥犳鎴戞帹鑽愬彧鐢╰est绾у埆灏卞彲浠ヤ簡銆?/p> 鏂板缓涓€涓璞★細 涓嬮潰鏉ユ柊寤轰竴涓猆serController锛岀劧鍚庡皢User浣滀负Controller鐨勮姹傚弬鏁板拰鍝嶅簲瀹炰綋娴嬭瘯涓媠mart-doc鏄浣曡交鏉惧畬鎴愭枃妗g敓鎴愮殑銆?/p>
娣诲姞瀹屾垚controller鍚庯紝鎴戜滑鍦ㄩ」鐩腑鏂板缓涓€涓崟鍏冩祴璇曠被鐢ㄤ簬璺戞枃妗c€?/p>
鏈€鍚庤繍琛屼竴涓嬪崟鍏冩祴璇晄mart-doc鍗冲彲鐢熸垚markdown鎺ュ彛鏂囨。鍒版寚瀹氱殑鐩綍銆?/p>
URL: Type: Content-Type: Request-parameters: Request-example: Response-fields: Response-example: 鏄笉鏄瘮swagger绠€鍗曞緢澶氬憿锛岃€屼笖杩樺畬鍏ㄤ笉渚靛叆浠g爜锛屽彧闇€瑕佸啓涓婃爣鍑嗙殑java doc娉ㄩ噴銆傞渶瑕佷簡瑙f洿澶氬鎯呭喌璇锋煡鐪媠mart-doc椤圭洰锛屽ソ鐢ㄨ璁板緱鐐箂tar鍝︺€?a href="https://gitee.com/sunyurepository/smart-doc" rel="nofollow">鏌ョ湅smart-doc椤圭洰 娉ㄦ剰: 鏈枃鏉ヨ嚜smart-doc鍘熶綔鑰咃紝鎮ㄥ彲浠ヨ浆杞戒絾璇峰嬁copy鍏呭綋鍘熷垱銆?/p> 以上是关于Spring Boot闆嗘垚smart-doc鐢熸垚api鏂囨。的主要内容,如果未能解决你的问题,请参考以下文章 Kiwi Syslog Web Access涓嶢ctive Directory闆嗘垚璁よ瘉 鎸佺画闆嗘垚楂樼骇绡囦箣Jenkins cli涓嶫enkins ssh 铻嶄簯鍗虫椂閫氳SDK闆嗘垚 -- FCM鎺ㄩ€侀泦鎴愭寚鍗?Android骞冲彴)smart-doc鍔熻兘
鍦⊿pring Boot椤圭洰涓泦鎴怱mart-doc
<dependency>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
public class User {
/**
* 鐢ㄦ埛鍚? */
private String userName;
/**
* 鏄电О
*/
private String nickName;
/**
* 鐢ㄦ埛鍦板潃
*/
private String userAddress;
/**
* 鐢ㄦ埛骞撮緞
*/
private int userAge;
/**
* 鎵嬫満鍙? */
private String phone;
/**
* 鍒涘缓鏃堕棿
*/
private Long createTime;
/**
* ipv6
*/
private String ipv6;
/**
* 鍥哄畾鐢佃瘽
*/
private String telephone;
//鐪佺暐get set
}
@RestController
@RequestMapping("/user")
public class UserController {
/**
* 娣诲姞鐢ㄦ埛
* @param user
* @return
*/
@PostMapping("/add")
public User addUser(@RequestBody User user){
return null;
}
}
public class ApiDocTest {
/**
* 鍖呮嫭璁剧疆璇锋眰澶达紝缂哄け娉ㄩ噴鐨勫瓧娈垫壒閲忓湪鏂囨。鐢熸垚鏈熶娇鐢ㄥ畾涔夊ソ鐨勬敞閲? */
@Test
public void testBuilderControllersApi() {
ApiConfig config = new ApiConfig();
config.setServerUrl("http://localhost:8080");
//true浼氫弗鏍艰姹傛敞閲婏紝鎺ㄨ崘璁剧疆true
config.setStrict(true);
//true浼氬皢鏂囨。鍚堝苟瀵煎嚭鍒颁竴涓猰arkdown
//config.setAllInOne(true);
//鐢熸垚html鏃跺姞瀵嗘枃妗e悕涓嶆毚闇瞔ontroller鐨勫悕绉? config.setMd5EncryptedHtmlName(true);
//鎸囧畾鏂囨。杈撳嚭璺緞
//@since 1.7 鐗堟湰寮€濮嬶紝閫夋嫨鐢熸垚闈欐€乭tml doc鏂囨。鍙娇鐢ㄨ璺緞锛欴ocGlobalConstants.HTML_DOC_OUT_PATH;
config.setOutPath("d:\md");
// @since 1.2,濡傛灉涓嶉厤缃閫夐」锛屽垯榛樿鍖归厤鍏ㄩ儴鐨刢ontroller,
// 濡傛灉闇€瑕侀厤缃湁澶氫釜controller鍙互浣跨敤閫楀彿闅斿紑
config.setPackageFilters("com.power.doc.controller");
long start = System.currentTimeMillis();
//鑾峰彇鎺ュ彛鏁版嵁鍚庤嚜琛屽鐞? ApiDocBuilder.builderControllersApi(config);
long end = System.currentTimeMillis();
DateTimeUtil.printRunTime(end, start);
}
}
鏂囨。鐢熸垚鏁堟灉
鐢ㄦ埛淇℃伅鎿嶄綔鎺ュ彛
娣诲姞鐢ㄦ埛
http://localhost:8080/user/add
POST
application/json; charset=utf-8
Parameter
Type
Description
Required
Since
userName
string
鐢ㄦ埛鍚?/td>
false
-
nickName
string
鏄电О
false
-
userAddress
string
鐢ㄦ埛鍦板潃
false
-
userAge
int
鐢ㄦ埛骞撮緞
false
-
phone
string
鎵嬫満鍙?/td>
false
-
createTime
number
鍒涘缓鏃堕棿
false
-
ipv6
string
ipv6
false
-
telephone
string
鍥哄畾鐢佃瘽
false
-
{
"userName":"楣忛.璐?,
"nickName":"raymond.gutkowski",
"userAddress":"Apt. 819 钀ф梺7699鍙凤紝 绔犱笜锛?婊?852063",
"userAge":41,
"phone":"15018373016",
"createTime":1569934393095,
"ipv6":"9eb3:fada:ffd2:912e:6225:1062:a2d7:718f",
"telephone":"15018373016"
}
Field
Type
Description
Since
userName
string
鐢ㄦ埛鍚?/td>
-
nickName
string
鏄电О
-
userAddress
string
鐢ㄦ埛鍦板潃
-
userAge
int
鐢ㄦ埛骞撮緞
-
phone
string
鎵嬫満鍙?/td>
-
createTime
number
鍒涘缓鏃堕棿
-
ipv6
string
ipv6
-
telephone
string
鍥哄畾鐢佃瘽
-
{
"userName":"楣忛.璐?,
"nickName":"raymond.gutkowski",
"userAddress":"Apt. 819 钀ф梺7699鍙凤紝 绔犱笜锛?婊?852063",
"userAge":41,
"phone":"15018373016",
"createTime":1569934393095,
"ipv6":"9eb3:fada:ffd2:912e:6225:1062:a2d7:718f",
"telephone":"15018373016"
}