Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apidoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
apidoc
Commits
d1cdf8f4
Commit
d1cdf8f4
authored
Apr 20, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
Adding tests.
parent
f4af126d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
34 deletions
+38
-34
apidoc-core/src/main/java/com/kim/apidoc/core/common/QueryStringBuilder.java
...n/java/com/kim/apidoc/core/common/QueryStringBuilder.java
+8
-8
apidoc-core/src/main/java/com/kim/apidoc/core/common/URI.java
...oc-core/src/main/java/com/kim/apidoc/core/common/URI.java
+12
-12
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Section.java
...ore/src/main/java/com/kim/apidoc/core/schema/Section.java
+8
-2
apidoc-core/src/main/resources/templates/markdown.ftl
apidoc-core/src/main/resources/templates/markdown.ftl
+3
-3
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Query.java
...vc/src/test/java/com/kim/apidoc/example/common/Query.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java
...om/kim/apidoc/example/spring/advanced/UserController.java
+6
-8
No files found.
apidoc-core/src/main/java/com/kim/apidoc/core/common/QueryStringBuilder.java
View file @
d1cdf8f4
...
@@ -9,8 +9,8 @@ public class QueryStringBuilder {
...
@@ -9,8 +9,8 @@ public class QueryStringBuilder {
private
StringBuilder
builder
=
new
StringBuilder
();
private
StringBuilder
builder
=
new
StringBuilder
();
public
QueryStringBuilder
append
(
Object
key
,
Object
value
){
public
QueryStringBuilder
append
(
Object
key
,
Object
value
)
{
if
(
builder
.
length
()>
0
)
{
if
(
builder
.
length
()
>
0
)
{
builder
.
append
(
"&"
);
builder
.
append
(
"&"
);
}
}
builder
.
append
(
key
);
builder
.
append
(
key
);
...
@@ -19,21 +19,21 @@ public class QueryStringBuilder {
...
@@ -19,21 +19,21 @@ public class QueryStringBuilder {
return
this
;
return
this
;
}
}
public
QueryStringBuilder
append
(
ObjectNode
objectNode
){
public
QueryStringBuilder
append
(
ObjectNode
objectNode
)
{
Iterator
<
String
>
iterator
=
objectNode
.
fieldNames
();
Iterator
<
String
>
iterator
=
objectNode
.
fieldNames
();
while
(
iterator
.
hasNext
()){
while
(
iterator
.
hasNext
())
{
String
key
=
iterator
.
next
();
String
key
=
iterator
.
next
();
JsonNode
valueNode
=
objectNode
.
get
(
key
);
JsonNode
valueNode
=
objectNode
.
get
(
key
);
String
value
=
valueNode
.
isTextual
()
?
valueNode
.
asText
():
valueNode
.
toString
();
String
value
=
valueNode
.
isTextual
()
?
valueNode
.
asText
()
:
valueNode
.
toString
();
append
(
key
,
value
);
append
(
key
,
value
);
}
}
return
this
;
return
this
;
}
}
public
String
toString
(){
@Override
public
String
toString
()
{
return
builder
.
toString
();
return
builder
.
toString
();
}
}
}
}
apidoc-core/src/main/java/com/kim/apidoc/core/common/URI.java
View file @
d1cdf8f4
...
@@ -24,34 +24,34 @@ public class URI {
...
@@ -24,34 +24,34 @@ public class URI {
this
.
text
=
text
;
this
.
text
=
text
;
}
}
public
URI
add
(
String
text
){
public
URI
add
(
String
text
)
{
return
add
(
new
URI
(
text
));
return
add
(
new
URI
(
text
));
}
}
public
URI
add
(
URI
uri
){
public
URI
add
(
URI
uri
)
{
if
(
next
!=
null
)
{
if
(
next
!=
null
)
{
next
.
add
(
uri
);
next
.
add
(
uri
);
}
else
{
}
else
{
next
=
uri
;
next
=
uri
;
}
}
return
this
;
return
this
;
}
}
public
void
remove
(
URI
uri
){
public
void
remove
(
URI
uri
)
{
if
(
Objects
.
equals
(
next
,
uri
))
{
if
(
Objects
.
equals
(
next
,
uri
))
{
next
=
null
;
next
=
null
;
}
else
{
}
else
{
next
.
remove
(
uri
);
next
.
remove
(
uri
);
}
}
}
}
@Override
@Override
public
String
toString
(){
public
String
toString
()
{
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
appendTo
(
list
);
appendTo
(
list
);
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
for
(
String
text
:
list
)
{
for
(
String
text
:
list
)
{
if
(
StringHelper
.
nonBlank
(
text
))
{
if
(
StringHelper
.
nonBlank
(
text
))
{
builder
.
append
(
"/"
);
builder
.
append
(
"/"
);
builder
.
append
(
text
);
builder
.
append
(
text
);
}
}
...
@@ -59,11 +59,11 @@ public class URI {
...
@@ -59,11 +59,11 @@ public class URI {
return
builder
.
toString
();
return
builder
.
toString
();
}
}
private
void
appendTo
(
List
<
String
>
list
){
private
void
appendTo
(
List
<
String
>
list
)
{
if
(
Objects
.
nonNull
(
text
))
{
if
(
Objects
.
nonNull
(
text
))
{
list
.
addAll
(
Lists
.
newArrayList
(
text
.
split
(
"/"
)));
list
.
addAll
(
Lists
.
newArrayList
(
text
.
split
(
"/"
)));
}
}
if
(
next
!=
null
)
{
if
(
next
!=
null
)
{
next
.
appendTo
(
list
);
next
.
appendTo
(
list
);
}
}
}
}
...
...
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Section.java
View file @
d1cdf8f4
...
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.JsonNode;
...
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.*
;
import
java.util.*
;
...
@@ -44,12 +45,10 @@ public class Section extends Node {
...
@@ -44,12 +45,10 @@ public class Section extends Node {
* The Query parameter.
* The Query parameter.
*/
*/
boolean
queryParameter
=
true
;
boolean
queryParameter
=
true
;
/**
/**
* The Request rows.
* The Request rows.
*/
*/
Map
<
String
,
Row
>
requestRows
=
new
LinkedHashMap
<>();
Map
<
String
,
Row
>
requestRows
=
new
LinkedHashMap
<>();
/**
/**
* The Out headers.
* The Out headers.
*/
*/
...
@@ -67,6 +66,13 @@ public class Section extends Node {
...
@@ -67,6 +66,13 @@ public class Section extends Node {
*/
*/
Object
rawResponse
;
Object
rawResponse
;
public
void
setUri
(
String
uri
)
{
String
value
=
""
;
if
(
StringUtils
.
isNotBlank
(
uri
))
{
value
=
uri
.
replaceAll
(
"\\{"
,
":"
).
replaceAll
(
"}"
,
""
);
}
this
.
uri
=
value
;
}
/**
/**
* Add request row.
* Add request row.
...
...
apidoc-core/src/main/resources/templates/markdown.ftl
View file @
d1cdf8f4
...
@@ -72,10 +72,10 @@ ${section.getResponseString()}
...
@@ -72,10 +72,10 @@ ${section.getResponseString()}
<#-- 响应参数table列表-->
<#-- 响应参数table列表-->
<#if section.responseRows?? && (section.responseRows?size>0)>
<#if section.responseRows?? && (section.responseRows?size>0)>
| 字段 | 类型 | 描述 |
| 字段 | 类型
| 默认值
| 描述 |
| :------- | :----- | :---------- |
| :------- | :----- |
:----- |
:---------- |
<#list section.responseRows as rowKey,rowValue>
<#list section.responseRows as rowKey,rowValue>
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.remark!''} |
| ${rowValue.key!''} | ${rowValue.type!''} | ${rowValue.
def!''} | ${rowValue.
remark!''} |
</#list>
</#list>
</#if>
</#if>
</#if>
</#if>
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Query.java
View file @
d1cdf8f4
...
@@ -15,6 +15,6 @@ public class Query {
...
@@ -15,6 +15,6 @@ public class Query {
/**
/**
* 查询关键字
* 查询关键字
*/
*/
String
q
=
""
;
String
q
=
"
123
"
;
}
}
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/
Kim
UserController.java
→
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java
View file @
d1cdf8f4
...
@@ -3,8 +3,6 @@ package com.kim.apidoc.example.spring.advanced;
...
@@ -3,8 +3,6 @@ package com.kim.apidoc.example.spring.advanced;
import
com.kim.apidoc.example.annotation.KimController
;
import
com.kim.apidoc.example.annotation.KimController
;
import
com.kim.apidoc.example.common.Query
;
import
com.kim.apidoc.example.common.Query
;
import
com.kim.apidoc.example.common.User
;
import
com.kim.apidoc.example.common.User
;
import
com.kim.apidoc.example.common.ResultData
;
import
com.kim.apidoc.example.common.ResultData
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -21,18 +19,18 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -21,18 +19,18 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
*/
@KimController
@KimController
@RequestMapping
(
"/api/v1"
)
@RequestMapping
(
"/api/v1"
)
public
class
Kim
UserController
{
public
class
UserController
{
/**
/**
*
Detail user.
*
查看用户详情
*
*
* @param
id the id
* @param
userId 用户编号
* @param query
the query
* @param query
过滤条件
* @return 用户对象 user
* @return 用户对象 user
*/
*/
@GetMapping
(
value
=
"/{
i
d}"
)
@GetMapping
(
value
=
"/{
userI
d}"
)
public
User
detail
(
@PathVariable
String
i
d
,
Query
query
)
{
public
User
detail
(
@PathVariable
String
userI
d
,
Query
query
)
{
User
user
=
new
User
();
User
user
=
new
User
();
return
user
;
return
user
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment