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
01c179c7
Commit
01c179c7
authored
Mar 30, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
Refactoring code.
parent
27ab485b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
9 deletions
+60
-9
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java
...apidoc/core/common/description/ObjectTypeDescription.java
+11
-0
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java
...m/kim/apidoc/core/common/description/TypeDescription.java
+1
-1
apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java
...c/main/java/com/kim/apidoc/core/parser/VisitorParser.java
+13
-3
apidoc-core/src/main/resources/templates/markdown.ftl
apidoc-core/src/main/resources/templates/markdown.ftl
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/ResultData.java
...c/test/java/com/kim/apidoc/example/common/ResultData.java
+29
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java
...kim/apidoc/example/spring/advanced/KimUserController.java
+5
-3
No files found.
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java
View file @
01c179c7
...
@@ -104,4 +104,15 @@ public class ObjectTypeDescription extends TypeDescription {
...
@@ -104,4 +104,15 @@ public class ObjectTypeDescription extends TypeDescription {
}
}
return
rows
;
return
rows
;
}
}
@Override
public
Collection
<
Row
>
rows
(
String
requestParameterType
)
{
Collection
<
Row
>
rows
=
super
.
rows
(
null
);
for
(
TypeDescription
member
:
members
)
{
if
(
member
.
isAvailable
())
{
rows
.
addAll
(
member
.
rows
(
requestParameterType
));
}
}
return
rows
;
}
}
}
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/TypeDescription.java
View file @
01c179c7
...
@@ -199,7 +199,7 @@ public abstract class TypeDescription {
...
@@ -199,7 +199,7 @@ public abstract class TypeDescription {
* @return the collection
* @return the collection
*/
*/
public
Collection
<
Row
>
rows
()
{
public
Collection
<
Row
>
rows
()
{
return
rows
(
null
);
return
this
.
rows
(
null
);
}
}
public
void
accept
(
Comment
comment
)
{
public
void
accept
(
Comment
comment
)
{
...
...
apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java
View file @
01c179c7
package
com.kim.apidoc.core.parser
;
package
com.kim.apidoc.core.parser
;
import
com.github.javaparser.ast.comments.JavadocComment
;
import
com.kim.apidoc.core.schema.Chapter
;
import
com.kim.apidoc.core.schema.Chapter
;
import
com.kim.apidoc.core.schema.Node
;
import
com.kim.apidoc.core.schema.Node
;
import
com.kim.apidoc.core.schema.Project
;
import
com.kim.apidoc.core.schema.Project
;
...
@@ -30,13 +31,14 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
...
@@ -30,13 +31,14 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
/**
/**
* 类或者接口声明
* 类或者接口声明
*
* @param classOrInterfaceDeclaration
* @param classOrInterfaceDeclaration
* @param arg
* @param arg
*/
*/
@Override
@Override
public
void
visit
(
final
ClassOrInterfaceDeclaration
classOrInterfaceDeclaration
,
final
Node
arg
)
{
public
void
visit
(
final
ClassOrInterfaceDeclaration
classOrInterfaceDeclaration
,
final
Node
arg
)
{
if
(
arg
instanceof
Project
&&
parserStrategy
.
accept
(
classOrInterfaceDeclaration
)
)
{
if
(
arg
instanceof
Project
)
{
Project
project
=
(
Project
)
arg
;
Project
project
=
(
Project
)
arg
;
// 章节
// 章节
Chapter
chapter
=
new
Chapter
();
Chapter
chapter
=
new
Chapter
();
...
@@ -44,17 +46,25 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
...
@@ -44,17 +46,25 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
chapter
.
setName
(
classOrInterfaceDeclaration
.
getNameAsString
());
chapter
.
setName
(
classOrInterfaceDeclaration
.
getNameAsString
());
classOrInterfaceDeclaration
.
getComment
().
ifPresent
(
chapter:
:
accept
);
classOrInterfaceDeclaration
.
getComment
().
ifPresent
(
chapter:
:
accept
);
OptionalHelper
.
any
(
chapter
.
getTag
(
"book"
),
chapter
.
getTag
(
"group"
))
OptionalHelper
.
any
(
chapter
.
getTag
(
"book"
),
chapter
.
getTag
(
"group"
))
.
ifPresent
(
tag
->
chapter
.
setBookName
(
tag
.
getContent
()));
.
ifPresent
(
tag
->
chapter
.
setBookName
(
tag
.
getContent
()));
if
(
parserStrategy
.
accept
(
classOrInterfaceDeclaration
))
{
parserStrategy
.
visit
(
classOrInterfaceDeclaration
,
chapter
);
parserStrategy
.
visit
(
classOrInterfaceDeclaration
,
chapter
);
}
project
.
addChapter
(
chapter
);
project
.
addChapter
(
chapter
);
super
.
visit
(
classOrInterfaceDeclaration
,
chapter
);
super
.
visit
(
classOrInterfaceDeclaration
,
chapter
);
}
}
}
}
@Override
public
void
visit
(
JavadocComment
n
,
Node
arg
)
{
super
.
visit
(
n
,
arg
);
}
/**
/**
* 方法声明
* 方法声明
*
* @param methodDeclaration
* @param methodDeclaration
* @param arg
* @param arg
*/
*/
...
...
apidoc-core/src/main/resources/templates/markdown.ftl
View file @
01c179c7
...
@@ -60,7 +60,7 @@ ${section.getParameterString()}
...
@@ -60,7 +60,7 @@ ${section.getParameterString()}
| Field | Type | Request Type | Required | Condition | Default | Description |
| Field | Type | Request Type | Required | Condition | Default | Description |
| :------- | :----- | :----- |:-------- |:-------- | :------ | :---------- |
| :------- | :----- | :----- |:-------- |:-------- | :------ | :---------- |
<#list section.requestRows as rowKey,rowValue>
<#list section.requestRows as rowKey,rowValue>
| ${rowValue.key!''} | ${rowValue.type!''} |
${rowValue.requestParameterType!''}
|${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} |
| ${rowValue.key!''} | ${rowValue.type!''} |
**${rowValue.requestParameterType!''}**
|${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} |
</#list>
</#list>
</#if>
</#if>
<#-- 响应-->
<#-- 响应-->
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/ResultData.java
View file @
01c179c7
...
@@ -3,6 +3,14 @@ package com.kim.apidoc.example.common;
...
@@ -3,6 +3,14 @@ package com.kim.apidoc.example.common;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
/**
* The type Result data.
*
* @param <T> the type parameter
* @author fengyuchenglun
* @version 1.0.0
* @resultData
*/
@Setter
@Setter
@Getter
@Getter
public
class
ResultData
<
T
>
{
public
class
ResultData
<
T
>
{
...
@@ -11,13 +19,33 @@ public class ResultData<T> {
...
@@ -11,13 +19,33 @@ public class ResultData<T> {
* 返回码
* 返回码
*/
*/
int
code
;
int
code
;
//返回信息
/**
* The Msg.
*/
//返回信息
String
msg
;
String
msg
;
/**
* The Data.
*/
T
data
;
T
data
;
/**
* Ok result data.
*
* @param <T> the type parameter
* @return the result data
*/
public
static
<
T
>
ResultData
<
T
>
ok
(){
public
static
<
T
>
ResultData
<
T
>
ok
(){
return
ok
(
null
);
return
ok
(
null
);
}
}
/**
* Ok result data.
*
* @param <T> the type parameter
* @param data the data
* @return the result data
*/
public
static
<
T
>
ResultData
<
T
>
ok
(
T
data
){
public
static
<
T
>
ResultData
<
T
>
ok
(
T
data
){
ResultData
<
T
>
resultData
=
new
ResultData
<>();
ResultData
<
T
>
resultData
=
new
ResultData
<>();
resultData
.
code
=
0
;
resultData
.
code
=
0
;
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java
View file @
01c179c7
package
com.kim.apidoc.example.spring.advanced
;
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.ResultData
;
import
com.kim.apidoc.example.common.ResultData
;
import
com.kim.apidoc.example.common.User
;
import
com.kim.apidoc.example.common.User
;
import
com.kim.apidoc.example.common.UserQuery
;
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.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -25,11 +26,12 @@ public class KimUserController {
...
@@ -25,11 +26,12 @@ public class KimUserController {
* 用户详情信息
* 用户详情信息
* 主动根据id获取用户的信息
* 主动根据id获取用户的信息
*
*
* @param userQuery the user query
* @param id the id
* @param query the query
* @return result data
* @return result data
*/
*/
@GetMapping
(
value
=
"/{id}"
)
@GetMapping
(
value
=
"/{id}"
)
public
ResultData
<
User
>
detail
(
UserQuery
userQ
uery
)
{
public
ResultData
<
User
>
detail
(
@PathVariable
String
id
,
Query
q
uery
)
{
User
user
=
new
User
();
User
user
=
new
User
();
return
ResultData
.
ok
(
user
);
return
ResultData
.
ok
(
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