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
46cafbb5
Commit
46cafbb5
authored
Mar 26, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
Refactoring code.
parent
19054687
Changes
106
Show whitespace changes
Inline
Side-by-side
Showing
106 changed files
with
849 additions
and
378 deletions
+849
-378
apidoc-core/src/main/java/com/apidoc/core/schema/Method.java
apidoc-core/src/main/java/com/apidoc/core/schema/Method.java
+0
-19
apidoc-core/src/main/java/kim/apidoc/core/ApiDoc.java
apidoc-core/src/main/java/kim/apidoc/core/ApiDoc.java
+28
-32
apidoc-core/src/main/java/kim/apidoc/core/Context.java
apidoc-core/src/main/java/kim/apidoc/core/Context.java
+5
-5
apidoc-core/src/main/java/kim/apidoc/core/common/Assert.java
apidoc-core/src/main/java/kim/apidoc/core/common/Assert.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/ObjectMappers.java
...e/src/main/java/kim/apidoc/core/common/ObjectMappers.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/QueryStringBuilder.java
.../main/java/kim/apidoc/core/common/QueryStringBuilder.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/URI.java
apidoc-core/src/main/java/kim/apidoc/core/common/URI.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/common/description/ArrayTypeDescription.java
.../apidoc/core/common/description/ArrayTypeDescription.java
+22
-22
apidoc-core/src/main/java/kim/apidoc/core/common/description/ObjectTypeDescription.java
...apidoc/core/common/description/ObjectTypeDescription.java
+5
-5
apidoc-core/src/main/java/kim/apidoc/core/common/description/PrimitiveTypeDescription.java
...doc/core/common/description/PrimitiveTypeDescription.java
+8
-7
apidoc-core/src/main/java/kim/apidoc/core/common/description/StringTypeDescription.java
...apidoc/core/common/description/StringTypeDescription.java
+4
-3
apidoc-core/src/main/java/kim/apidoc/core/common/description/TypeDescription.java
...a/kim/apidoc/core/common/description/TypeDescription.java
+14
-14
apidoc-core/src/main/java/kim/apidoc/core/common/description/UnAvailableTypeDescription.java
...c/core/common/description/UnAvailableTypeDescription.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/common/diff/FileMatcher.java
...rc/main/java/kim/apidoc/core/common/diff/FileMatcher.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/common/diff/FileSystem.java
...src/main/java/kim/apidoc/core/common/diff/FileSystem.java
+13
-13
apidoc-core/src/main/java/kim/apidoc/core/common/diff/MatchPatcher.java
...c/main/java/kim/apidoc/core/common/diff/MatchPatcher.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/AnnotationHelper.java
.../java/kim/apidoc/core/common/helper/AnnotationHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/ClassDeclarationHelper.java
...kim/apidoc/core/common/helper/ClassDeclarationHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/CommentHelper.java
...ain/java/kim/apidoc/core/common/helper/CommentHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/CompilationUnitHelper.java
.../kim/apidoc/core/common/helper/CompilationUnitHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/ExpressionHelper.java
.../java/kim/apidoc/core/common/helper/ExpressionHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/FieldHelper.java
.../main/java/kim/apidoc/core/common/helper/FieldHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/FileHelper.java
...c/main/java/kim/apidoc/core/common/helper/FileHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/JsonPropertyHelper.java
...ava/kim/apidoc/core/common/helper/JsonPropertyHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/OptionalHelper.java
...in/java/kim/apidoc/core/common/helper/OptionalHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/ReferenceContext.java
.../java/kim/apidoc/core/common/helper/ReferenceContext.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/StringHelper.java
...main/java/kim/apidoc/core/common/helper/StringHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/TypeNameHelper.java
...in/java/kim/apidoc/core/common/helper/TypeNameHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/TypeParameterHelper.java
...va/kim/apidoc/core/common/helper/TypeParameterHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/helper/ValidationHelper.java
.../java/kim/apidoc/core/common/helper/ValidationHelper.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/markup/MarkupBuilder.java
...ain/java/kim/apidoc/core/common/markup/MarkupBuilder.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/common/markup/asciidoc/AsciiDoc.java
...java/kim/apidoc/core/common/markup/asciidoc/AsciiDoc.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/markup/asciidoc/AsciiDocBuilder.java
...m/apidoc/core/common/markup/asciidoc/AsciiDocBuilder.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/common/markup/asciidoc/Color.java
...in/java/kim/apidoc/core/common/markup/asciidoc/Color.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/markup/markdown/Markdown.java
...java/kim/apidoc/core/common/markup/markdown/Markdown.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/markup/markdown/MarkdownBuilder.java
...m/apidoc/core/common/markup/markdown/MarkdownBuilder.java
+37
-39
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Body.java
...re/src/main/java/kim/apidoc/core/common/postman/Body.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/postman/BodyMode.java
...rc/main/java/kim/apidoc/core/common/postman/BodyMode.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Folder.java
.../src/main/java/kim/apidoc/core/common/postman/Folder.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Info.java
...re/src/main/java/kim/apidoc/core/common/postman/Info.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Item.java
...re/src/main/java/kim/apidoc/core/common/postman/Item.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Parameter.java
...c/main/java/kim/apidoc/core/common/postman/Parameter.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Postman.java
...src/main/java/kim/apidoc/core/common/postman/Postman.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Request.java
...src/main/java/kim/apidoc/core/common/postman/Request.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Response.java
...rc/main/java/kim/apidoc/core/common/postman/Response.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/common/postman/Url.java
...ore/src/main/java/kim/apidoc/core/common/postman/Url.java
+1
-1
apidoc-core/src/main/java/kim/apidoc/core/parser/ParserStrategy.java
.../src/main/java/kim/apidoc/core/parser/ParserStrategy.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/parser/VisitorParser.java
...e/src/main/java/kim/apidoc/core/parser/VisitorParser.java
+6
-6
apidoc-core/src/main/java/kim/apidoc/core/render/AsciiDocRender.java
.../src/main/java/kim/apidoc/core/render/AsciiDocRender.java
+8
-8
apidoc-core/src/main/java/kim/apidoc/core/render/MarkdownRender.java
.../src/main/java/kim/apidoc/core/render/MarkdownRender.java
+18
-0
apidoc-core/src/main/java/kim/apidoc/core/render/PostmanRender.java
...e/src/main/java/kim/apidoc/core/render/PostmanRender.java
+6
-6
apidoc-core/src/main/java/kim/apidoc/core/render/ProjectRender.java
...e/src/main/java/kim/apidoc/core/render/ProjectRender.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/resolver/ArrayTypeResolver.java
...main/java/kim/apidoc/core/resolver/ArrayTypeResolver.java
+4
-4
apidoc-core/src/main/java/kim/apidoc/core/resolver/CollectionTypeResolver.java
...java/kim/apidoc/core/resolver/CollectionTypeResolver.java
+6
-6
apidoc-core/src/main/java/kim/apidoc/core/resolver/DateTypeResolver.java
.../main/java/kim/apidoc/core/resolver/DateTypeResolver.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/resolver/EnumTypeResolver.java
.../main/java/kim/apidoc/core/resolver/EnumTypeResolver.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/resolver/MapTypeResolver.java
...c/main/java/kim/apidoc/core/resolver/MapTypeResolver.java
+16
-16
apidoc-core/src/main/java/kim/apidoc/core/resolver/ObjectTypeResolver.java
...ain/java/kim/apidoc/core/resolver/ObjectTypeResolver.java
+5
-5
apidoc-core/src/main/java/kim/apidoc/core/resolver/PrimitiveTypeResolver.java
.../java/kim/apidoc/core/resolver/PrimitiveTypeResolver.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/resolver/StringTypeResolver.java
...ain/java/kim/apidoc/core/resolver/StringTypeResolver.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/resolver/SystemObjectTypeResolver.java
...va/kim/apidoc/core/resolver/SystemObjectTypeResolver.java
+3
-3
apidoc-core/src/main/java/kim/apidoc/core/resolver/TypeNameResolver.java
.../main/java/kim/apidoc/core/resolver/TypeNameResolver.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/resolver/TypeResolver.java
.../src/main/java/kim/apidoc/core/resolver/TypeResolver.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/resolver/TypeResolvers.java
...src/main/java/kim/apidoc/core/resolver/TypeResolvers.java
+4
-4
apidoc-core/src/main/java/kim/apidoc/core/schema/Book.java
apidoc-core/src/main/java/kim/apidoc/core/schema/Book.java
+18
-1
apidoc-core/src/main/java/kim/apidoc/core/schema/Chapter.java
...oc-core/src/main/java/kim/apidoc/core/schema/Chapter.java
+10
-1
apidoc-core/src/main/java/kim/apidoc/core/schema/Header.java
apidoc-core/src/main/java/kim/apidoc/core/schema/Header.java
+72
-0
apidoc-core/src/main/java/kim/apidoc/core/schema/Method.java
apidoc-core/src/main/java/kim/apidoc/core/schema/Method.java
+84
-0
apidoc-core/src/main/java/kim/apidoc/core/schema/Node.java
apidoc-core/src/main/java/kim/apidoc/core/schema/Node.java
+4
-4
apidoc-core/src/main/java/kim/apidoc/core/schema/Project.java
...oc-core/src/main/java/kim/apidoc/core/schema/Project.java
+2
-2
apidoc-core/src/main/java/kim/apidoc/core/schema/Row.java
apidoc-core/src/main/java/kim/apidoc/core/schema/Row.java
+48
-0
apidoc-core/src/main/java/kim/apidoc/core/schema/Section.java
...oc-core/src/main/java/kim/apidoc/core/schema/Section.java
+198
-0
apidoc-core/src/main/java/kim/apidoc/core/schema/Tag.java
apidoc-core/src/main/java/kim/apidoc/core/schema/Tag.java
+51
-0
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/ParameterHelper.java
...c/main/java/com/kim/apidoc/springmvc/ParameterHelper.java
+1
-1
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/RequestMappingHelper.java
...n/java/com/kim/apidoc/springmvc/RequestMappingHelper.java
+6
-6
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringMVCContext.java
.../main/java/com/kim/apidoc/springmvc/SpringMVCContext.java
+2
-2
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java
.../src/main/java/com/kim/apidoc/springmvc/SpringParser.java
+17
-20
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/resovler/SpringComponentTypeResolver.java
...pidoc/springmvc/resovler/SpringComponentTypeResolver.java
+8
-8
apidoc-springmvc/src/main/resources/META-INF/services/com.apidoc.core.parser.ParserStrategy
...s/META-INF/services/com.apidoc.core.parser.ParserStrategy
+0
-1
apidoc-springmvc/src/main/resources/META-INF/services/kim.apidoc.core.parser.ParserStrategy
...s/META-INF/services/kim.apidoc.core.parser.ParserStrategy
+1
-0
apidoc-springmvc/src/test/java/com/kim/apidoc/example/ApigccTest.java
...gmvc/src/test/java/com/kim/apidoc/example/ApigccTest.java
+3
-3
apidoc-springmvc/src/test/java/com/kim/apidoc/example/annotation/KimController.java
...java/com/kim/apidoc/example/annotation/KimController.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/annotation/KimResponseBody.java
...va/com/kim/apidoc/example/annotation/KimResponseBody.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Code.java
...mvc/src/test/java/com/kim/apidoc/example/common/Code.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Menu.java
...mvc/src/test/java/com/kim/apidoc/example/common/Menu.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Page.java
...mvc/src/test/java/com/kim/apidoc/example/common/Page.java
+1
-1
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/common/ResultData.java
...c/test/java/com/kim/apidoc/example/common/ResultData.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Role.java
...mvc/src/test/java/com/kim/apidoc/example/common/Role.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/StaticFinalCode.java
...t/java/com/kim/apidoc/example/common/StaticFinalCode.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/User.java
...mvc/src/test/java/com/kim/apidoc/example/common/User.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/UserDTO.java
.../src/test/java/com/kim/apidoc/example/common/UserDTO.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/UserDetails.java
.../test/java/com/kim/apidoc/example/common/UserDetails.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/UserQuery.java
...rc/test/java/com/kim/apidoc/example/common/UserQuery.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/common/Wrapper.java
.../src/test/java/com/kim/apidoc/example/common/Wrapper.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/BaseController.java
...st/java/com/kim/apidoc/example/spring/BaseController.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/AuthController.java
...om/kim/apidoc/example/spring/advanced/AuthController.java
+3
-3
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/EmptyController.java
...m/kim/apidoc/example/spring/advanced/EmptyController.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/IgnoreController.java
.../kim/apidoc/example/spring/advanced/IgnoreController.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/KimUserController.java
...kim/apidoc/example/spring/advanced/KimUserController.java
+4
-4
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/PageController.java
...om/kim/apidoc/example/spring/advanced/PageController.java
+4
-4
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/advanced/UserController.java
...om/kim/apidoc/example/spring/advanced/UserController.java
+3
-3
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/Greeting.java
...st/java/com/kim/apidoc/example/spring/hello/Greeting.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/example/spring/hello/GreetingController.java
...m/kim/apidoc/example/spring/hello/GreetingController.java
+1
-1
apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
...vc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
+7
-7
markdown接口模版.md
markdown接口模版.md
+5
-5
No files found.
apidoc-core/src/main/java/com/apidoc/core/schema/Method.java
deleted
100644 → 0
View file @
19054687
package
com.apidoc.core.schema
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 支持的http method
*/
@Slf4j
public
enum
Method
{
GET
,
POST
,
PUT
,
DELETE
,
OPTIONS
,
PATCH
,
COPY
,
HEAD
,
LINK
,
UNLINK
,
PURGE
,
LOCK
,
UNLOCK
,
PROPFIND
,
VIEW
;
public
static
Method
of
(
String
name
)
{
return
valueOf
(
name
);
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/ApiDoc.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/ApiDoc.java
View file @
46cafbb5
package
co
m.apidoc.core
;
import
co
m.apidoc.core.common.helper.StringHelper
;
import
co
m.apidoc.core.parser.ParserStrategy
;
import
co
m.apidoc.core.parser.VisitorParser
;
import
co
m.apidoc.core.render.ProjectRender
;
import
co
m.apidoc.core.resolver.TypeResolvers
;
import
co
m.apidoc.core.schema.Project
;
package
ki
m.apidoc.core
;
import
ki
m.apidoc.core.common.helper.StringHelper
;
import
ki
m.apidoc.core.parser.ParserStrategy
;
import
ki
m.apidoc.core.parser.VisitorParser
;
import
ki
m.apidoc.core.render.ProjectRender
;
import
ki
m.apidoc.core.resolver.TypeResolvers
;
import
ki
m.apidoc.core.schema.Project
;
import
com.github.javaparser.ParseResult
;
import
com.github.javaparser.ParserConfiguration
;
import
com.github.javaparser.ast.CompilationUnit
;
...
...
@@ -38,17 +38,6 @@ public class ApiDoc {
* ApiDoc实例
*/
private
static
ApiDoc
INSTANCE
;
/**
* Get instance api doc.
*
* @return the api doc
*/
public
static
ApiDoc
getInstance
(){
return
INSTANCE
;
}
/**
* 上下文
*/
...
...
@@ -59,7 +48,6 @@ public class ApiDoc {
*/
@Getter
private
Project
project
=
new
Project
();
/**
* The Visitor parser.
*/
...
...
@@ -68,7 +56,6 @@ public class ApiDoc {
* The Parser configuration.
*/
private
ParserConfiguration
parserConfiguration
;
/**
* The Type resolvers.
*/
...
...
@@ -78,7 +65,7 @@ public class ApiDoc {
/**
* Instantiates a new ApiDoc.
*/
private
ApiDoc
(){
private
ApiDoc
()
{
init
(
new
Context
());
}
...
...
@@ -87,16 +74,25 @@ public class ApiDoc {
*
* @param context the context
*/
public
ApiDoc
(
Context
context
){
public
ApiDoc
(
Context
context
)
{
init
(
context
);
}
/**
* Get instance api doc.
*
* @return the api doc
*/
public
static
ApiDoc
getInstance
()
{
return
INSTANCE
;
}
/**
* 初始化环境配置
*
* @param context the context
*/
private
void
init
(
Context
context
){
private
void
init
(
Context
context
)
{
INSTANCE
=
this
;
this
.
context
=
context
;
project
.
setId
(
context
.
getId
());
...
...
@@ -133,21 +129,21 @@ public class ApiDoc {
*
* @return the parser strategy
*/
private
ParserStrategy
loadParserStrategy
(){
private
ParserStrategy
loadParserStrategy
()
{
ServiceLoader
<
ParserStrategy
>
serviceLoader
=
ServiceLoader
.
load
(
ParserStrategy
.
class
);
List
<
ParserStrategy
>
strategies
=
Lists
.
newArrayList
(
serviceLoader
);
if
(
strategies
.
isEmpty
())
{
if
(
strategies
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"no ParserStrategy implements found"
);
}
if
(
StringHelper
.
isBlank
(
context
.
framework
))
{
if
(
StringHelper
.
isBlank
(
context
.
framework
))
{
return
strategies
.
get
(
0
);
}
for
(
ParserStrategy
strategy
:
strategies
)
{
if
(
Objects
.
equals
(
context
.
framework
,
strategy
.
name
()))
{
if
(
Objects
.
equals
(
context
.
framework
,
strategy
.
name
()))
{
return
strategy
;
}
}
throw
new
IllegalArgumentException
(
"no ParserStrategy implements found for "
+
context
.
framework
);
throw
new
IllegalArgumentException
(
"no ParserStrategy implements found for "
+
context
.
framework
);
}
/**
...
...
@@ -155,12 +151,12 @@ public class ApiDoc {
*
* @return project project
*/
public
Project
parse
(){
public
Project
parse
()
{
for
(
Path
source
:
this
.
context
.
getSources
())
{
SourceRoot
root
=
new
SourceRoot
(
source
,
parserConfiguration
);
try
{
for
(
ParseResult
<
CompilationUnit
>
result
:
root
.
tryToParse
())
{
if
(
result
.
isSuccessful
()
&&
result
.
getResult
().
isPresent
())
{
if
(
result
.
isSuccessful
()
&&
result
.
getResult
().
isPresent
())
{
result
.
getResult
().
get
().
accept
(
visitorParser
,
project
);
}
}
...
...
@@ -174,7 +170,7 @@ public class ApiDoc {
/**
* 渲染解析结果
*/
public
void
render
(){
public
void
render
()
{
for
(
ProjectRender
render
:
this
.
context
.
getRenders
())
{
render
.
render
(
project
);
}
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/Context.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/Context.java
View file @
46cafbb5
package
co
m.apidoc.core
;
package
ki
m.apidoc.core
;
import
co
m.apidoc.core.common.helper.FileHelper
;
import
co
m.apidoc.core.render.AsciiDocRender
;
import
co
m.apidoc.core.render.PostmanRender
;
import
co
m.apidoc.core.render.ProjectRender
;
import
ki
m.apidoc.core.common.helper.FileHelper
;
import
ki
m.apidoc.core.render.AsciiDocRender
;
import
ki
m.apidoc.core.render.PostmanRender
;
import
ki
m.apidoc.core.render.ProjectRender
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
lombok.Getter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/Assert.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/Assert.java
View file @
46cafbb5
package
co
m.apidoc.core.common
;
package
ki
m.apidoc.core.common
;
import
com.google.common.base.Strings
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/ObjectMappers.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/ObjectMappers.java
View file @
46cafbb5
package
co
m.apidoc.core.common
;
package
ki
m.apidoc.core.common
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/QueryStringBuilder.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/QueryStringBuilder.java
View file @
46cafbb5
package
co
m.apidoc.core.common
;
package
ki
m.apidoc.core.common
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/URI.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/URI.java
View file @
46cafbb5
package
co
m.apidoc.core.common
;
package
ki
m.apidoc.core.common
;
import
co
m.apidoc.core.common.helper.StringHelper
;
import
ki
m.apidoc.core.common.helper.StringHelper
;
import
com.google.common.collect.Lists
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/description/ArrayTypeDescription.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/description/ArrayTypeDescription.java
View file @
46cafbb5
package
co
m.apidoc.core.common.description
;
package
ki
m.apidoc.core.common.description
;
import
co
m.apidoc.core.common.ObjectMappers
;
import
co
m.apidoc.core.schema.Row
;
import
ki
m.apidoc.core.common.ObjectMappers
;
import
ki
m.apidoc.core.schema.Row
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
java.util.ArrayList
;
...
...
@@ -15,47 +15,47 @@ public class ArrayTypeDescription extends TypeDescription {
public
ArrayTypeDescription
(
TypeDescription
component
)
{
this
.
component
=
component
;
this
.
value
=
ObjectMappers
.
instance
.
createArrayNode
();
if
(
component
.
isAvailable
())
{
if
(
component
.
isAvailable
())
{
this
.
type
=
component
.
getType
()
+
"[]"
;
if
(
component
.
isPrimitive
())
{
if
(
component
.
isPrimitive
())
{
primitive
(
component
.
asPrimitive
());
}
else
if
(
component
.
isString
())
{
}
else
if
(
component
.
isString
())
{
value
.
add
(
component
.
asString
().
getValue
());
}
else
if
(
component
.
isArray
())
{
}
else
if
(
component
.
isArray
())
{
value
.
add
(
component
.
asArray
().
getValue
());
}
else
if
(
component
.
isObject
())
{
}
else
if
(
component
.
isObject
())
{
value
.
add
(
component
.
asObject
().
getValue
());
}
}
else
{
}
else
{
this
.
type
=
"[]"
;
}
}
public
void
primitive
(
PrimitiveTypeDescription
typeDescription
){
switch
(
typeDescription
.
getType
()){
public
void
primitive
(
PrimitiveTypeDescription
typeDescription
)
{
switch
(
typeDescription
.
getType
())
{
case
"byte"
:
value
.
add
((
byte
)
typeDescription
.
getValue
());
value
.
add
((
byte
)
typeDescription
.
getValue
());
break
;
case
"short"
:
value
.
add
((
short
)
typeDescription
.
getValue
());
value
.
add
((
short
)
typeDescription
.
getValue
());
break
;
case
"char"
:
value
.
add
((
char
)
typeDescription
.
getValue
());
value
.
add
((
char
)
typeDescription
.
getValue
());
break
;
case
"int"
:
value
.
add
((
int
)
typeDescription
.
getValue
());
value
.
add
((
int
)
typeDescription
.
getValue
());
break
;
case
"long"
:
value
.
add
((
long
)
typeDescription
.
getValue
());
value
.
add
((
long
)
typeDescription
.
getValue
());
break
;
case
"boolean"
:
value
.
add
((
boolean
)
typeDescription
.
getValue
());
value
.
add
((
boolean
)
typeDescription
.
getValue
());
break
;
case
"float"
:
value
.
add
((
float
)
typeDescription
.
getValue
());
value
.
add
((
float
)
typeDescription
.
getValue
());
break
;
case
"double"
:
value
.
add
((
double
)
typeDescription
.
getValue
());
value
.
add
((
double
)
typeDescription
.
getValue
());
break
;
}
}
...
...
@@ -76,17 +76,17 @@ public class ArrayTypeDescription extends TypeDescription {
}
}
public
ArrayNode
getValue
(){
public
ArrayNode
getValue
()
{
return
value
;
}
@Override
public
Collection
<
Row
>
rows
()
{
ArrayList
<
Row
>
rows
=
new
ArrayList
<>();
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
rows
.
addAll
(
super
.
rows
());
}
if
(
component
.
isAvailable
())
{
if
(
component
.
isAvailable
())
{
rows
.
addAll
(
component
.
rows
());
}
return
rows
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/description/ObjectTypeDescription.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/description/ObjectTypeDescription.java
View file @
46cafbb5
package
co
m.apidoc.core.common.description
;
package
ki
m.apidoc.core.common.description
;
import
co
m.apidoc.core.common.ObjectMappers
;
import
co
m.apidoc.core.schema.Row
;
import
ki
m.apidoc.core.common.ObjectMappers
;
import
ki
m.apidoc.core.schema.Row
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.google.common.collect.Lists
;
import
lombok.Getter
;
...
...
@@ -14,9 +14,8 @@ import java.util.List;
@Getter
public
class
ObjectTypeDescription
extends
TypeDescription
{
private
ObjectNode
value
=
ObjectMappers
.
instance
.
createObjectNode
();
protected
List
<
TypeDescription
>
members
=
Lists
.
newArrayList
();
private
ObjectNode
value
=
ObjectMappers
.
instance
.
createObjectNode
();
public
void
merge
(
ObjectTypeDescription
other
)
{
value
.
setAll
(
other
.
getValue
());
...
...
@@ -87,6 +86,7 @@ public class ObjectTypeDescription extends TypeDescription {
}
}
@Override
public
ObjectNode
getValue
()
{
return
value
;
}
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/description/PrimitiveTypeDescription.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/description/PrimitiveTypeDescription.java
View file @
46cafbb5
package
co
m.apidoc.core.common.description
;
package
ki
m.apidoc.core.common.description
;
import
com.github.javaparser.resolution.types.ResolvedPrimitiveType
;
import
com.github.javaparser.resolution.types.ResolvedReferenceType
;
...
...
@@ -6,8 +6,8 @@ import com.github.javaparser.resolution.types.ResolvedReferenceType;
public
class
PrimitiveTypeDescription
extends
TypeDescription
{
public
PrimitiveTypeDescription
(
ResolvedReferenceType
referenceType
){
switch
(
referenceType
.
getId
()){
public
PrimitiveTypeDescription
(
ResolvedReferenceType
referenceType
)
{
switch
(
referenceType
.
getId
())
{
case
"java.lang.Byte"
:
value
=
(
byte
)
0
;
type
=
"byte"
;
...
...
@@ -33,7 +33,7 @@ public class PrimitiveTypeDescription extends TypeDescription {
type
=
"double"
;
break
;
case
"java.lang.Character"
:
value
=
(
char
)
0
;
value
=
(
char
)
0
;
type
=
"char"
;
break
;
case
"java.lang.Boolean"
:
...
...
@@ -43,9 +43,10 @@ public class PrimitiveTypeDescription extends TypeDescription {
}
}
public
PrimitiveTypeDescription
(
ResolvedPrimitiveType
resolvedPrimitiveType
){
public
PrimitiveTypeDescription
(
ResolvedPrimitiveType
resolvedPrimitiveType
)
{
type
=
resolvedPrimitiveType
.
describe
();
switch
(
resolvedPrimitiveType
){
switch
(
resolvedPrimitiveType
)
{
case
BYTE:
value
=
(
byte
)
0
;
break
;
...
...
@@ -65,7 +66,7 @@ public class PrimitiveTypeDescription extends TypeDescription {
value
=
0
d
;
break
;
case
CHAR:
value
=
(
char
)
0
;
value
=
(
char
)
0
;
break
;
case
BOOLEAN:
value
=
false
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/description/StringTypeDescription.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/description/StringTypeDescription.java
View file @
46cafbb5
package
co
m.apidoc.core.common.description
;
package
ki
m.apidoc.core.common.description
;
public
class
StringTypeDescription
extends
TypeDescription
{
...
...
@@ -7,7 +7,8 @@ public class StringTypeDescription extends TypeDescription {
value
=
charSequence
.
toString
();
}
public
String
getValue
(){
return
(
String
)
value
;
@Override
public
String
getValue
()
{
return
(
String
)
value
;
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/common/description/TypeDescription.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/description/TypeDescription.java
View file @
46cafbb5
package
co
m.apidoc.core.common.description
;
package
ki
m.apidoc.core.common.description
;
import
co
m.apidoc.core.common.helper.StringHelper
;
import
co
m.apidoc.core.schema.Row
;
import
ki
m.apidoc.core.common.helper.StringHelper
;
import
ki
m.apidoc.core.schema.Row
;
import
com.google.common.collect.Lists
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -61,36 +61,36 @@ public abstract class TypeDescription {
return
(
ObjectTypeDescription
)
this
;
}
public
void
addRemark
(
String
value
){
if
(
value
==
null
)
{
public
void
addRemark
(
String
value
)
{
if
(
value
==
null
)
{
return
;
}
if
(
remark
==
null
)
{
if
(
remark
==
null
)
{
remark
=
value
;
}
else
{
}
else
{
remark
+=
" "
+
value
;
}
}
public
String
fullKey
(){
return
StringHelper
.
join
(
"."
,
prefix
,
key
);
public
String
fullKey
()
{
return
StringHelper
.
join
(
"."
,
prefix
,
key
);
}
public
Collection
<
Row
>
rows
()
{
String
key
=
fullKey
();
if
(
StringHelper
.
isBlank
(
key
))
{
if
(
StringHelper
.
isBlank
(
key
))
{
return
Lists
.
newArrayList
();
}
String
def
;
if
(
defaultValue
!=
null
)
{
if
(
defaultValue
!=
null
)
{
def
=
String
.
valueOf
(
defaultValue
);
}
else
if
(
value
!=
null
)
{
}
else
if
(
value
!=
null
)
{
def
=
String
.
valueOf
(
value
);
}
else
{
}
else
{
def
=
""
;
}
if
(
required
!=
null
)
{
if
(
required
!=
null
)
{
condition
.
append
(
"required="
).
append
(
required
);
}
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/description/UnAvailableTypeDescription.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/description/UnAvailableTypeDescription.java
View file @
46cafbb5
package
co
m.apidoc.core.common.description
;
package
ki
m.apidoc.core.common.description
;
import
co
m.apidoc.core.schema.Row
;
import
ki
m.apidoc.core.schema.Row
;
import
java.util.Collection
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/diff/FileMatcher.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/diff/FileMatcher.java
View file @
46cafbb5
package
co
m.apidoc.core.common.diff
;
package
ki
m.apidoc.core.common.diff
;
import
com.google.common.base.Charsets
;
import
lombok.Getter
;
...
...
@@ -42,7 +42,7 @@ public class FileMatcher {
return
changs
;
}
public
void
rederHtml
(
Path
templateHtml
,
Path
resultHtml
)
{
public
void
re
n
derHtml
(
Path
templateHtml
,
Path
resultHtml
)
{
String
results
=
matchPatcher
.
diff_prettyHtml
(
diffs
);
String
[]
lines
=
br
(
results
).
replaceAll
(
"<span>|</span>"
,
""
).
split
(
"\n"
);
String
html
=
readFile
(
templateHtml
);
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/diff/FileSystem.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/diff/FileSystem.java
View file @
46cafbb5
package
co
m.apidoc.core.common.diff
;
package
ki
m.apidoc.core.common.diff
;
import
java.awt.*
;
import
java.io.File
;
...
...
@@ -9,7 +9,7 @@ import java.nio.file.Path;
public
class
FileSystem
{
public
static
boolean
open
(
Path
path
)
{
if
(!
Files
.
exists
(
path
))
{
if
(!
Files
.
exists
(
path
))
{
return
false
;
}
if
(
cmd
(
path
.
toString
()))
{
...
...
@@ -25,8 +25,8 @@ public class FileSystem {
private
static
boolean
cmd
(
String
command
,
String
args
)
{
try
{
Process
p
=
Runtime
.
getRuntime
().
exec
(
new
String
[]{
command
,
args
});
return
p
!=
null
;
Process
p
=
Runtime
.
getRuntime
().
exec
(
new
String
[]{
command
,
args
});
return
p
!=
null
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -45,6 +45,14 @@ public class FileSystem {
return
false
;
}
private
static
OS
currentOS
()
{
String
s
=
System
.
getProperty
(
"os.name"
).
toLowerCase
();
if
(
s
.
contains
(
"win"
))
{
return
OS
.
win
;
}
return
OS
.
mac
;
}
public
enum
OS
{
mac
(
"open"
),
win
(
"explorer"
);
...
...
@@ -55,17 +63,9 @@ public class FileSystem {
this
.
command
=
command
;
}
public
String
getCommand
(){
public
String
getCommand
()
{
return
command
;
}
}
private
static
OS
currentOS
()
{
String
s
=
System
.
getProperty
(
"os.name"
).
toLowerCase
();
if
(
s
.
contains
(
"win"
))
{
return
OS
.
win
;
}
return
OS
.
mac
;
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/common/diff/MatchPatcher.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/diff/MatchPatcher.java
View file @
46cafbb5
...
...
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
co
m.apidoc.core.common.diff
;
package
ki
m.apidoc.core.common.diff
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/AnnotationHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/AnnotationHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.expr.*
;
import
com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/ClassDeclarationHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/ClassDeclarationHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.FieldDeclaration
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/CommentHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/CommentHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.body.FieldDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/CompilationUnitHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/CompilationUnitHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.CompilationUnit
;
import
com.github.javaparser.ast.Node
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/ExpressionHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/ExpressionHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.NodeList
;
import
com.github.javaparser.ast.expr.*
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/FieldHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/FieldHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.expr.Expression
;
import
com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/FileHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/FileHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/JsonPropertyHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/JsonPropertyHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.body.FieldDeclaration
;
import
com.github.javaparser.ast.expr.AnnotationExpr
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/OptionalHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/OptionalHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
java.util.Optional
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/ReferenceContext.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/ReferenceContext.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.google.common.collect.Sets
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/StringHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/StringHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.google.common.base.Strings
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/TypeNameHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/TypeNameHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.CompilationUnit
;
import
com.github.javaparser.ast.ImportDeclaration
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/TypeParameterHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/TypeParameterHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration
;
import
com.github.javaparser.resolution.types.ResolvedReferenceType
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/helper/ValidationHelper.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/helper/ValidationHelper.java
View file @
46cafbb5
package
co
m.apidoc.core.common.helper
;
package
ki
m.apidoc.core.common.helper
;
import
com.github.javaparser.ast.body.FieldDeclaration
;
import
com.github.javaparser.ast.expr.AnnotationExpr
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/markup/MarkupBuilder.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/markup/MarkupBuilder.java
View file @
46cafbb5
package
co
m.apidoc.core.common.markup
;
package
ki
m.apidoc.core.common.markup
;
import
co
m.apidoc.core.common.markup.asciidoc.AsciiDocBuilder
;
import
ki
m.apidoc.core.common.markup.asciidoc.AsciiDocBuilder
;
import
java.util.List
;
import
java.util.function.Consumer
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/markup/asciidoc/AsciiDoc.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/markup/asciidoc/AsciiDoc.java
View file @
46cafbb5
package
co
m.apidoc.core.common.markup.asciidoc
;
package
ki
m.apidoc.core.common.markup.asciidoc
;
public
enum
AsciiDoc
implements
CharSequence
{
EXTENSION
(
".adoc"
),
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/markup/asciidoc/AsciiDocBuilder.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/markup/asciidoc/AsciiDocBuilder.java
View file @
46cafbb5
package
co
m.apidoc.core.common.markup.asciidoc
;
package
ki
m.apidoc.core.common.markup.asciidoc
;
import
co
m.apidoc.core.common.Assert
;
import
co
m.apidoc.core.common.markup.MarkupBuilder
;
import
ki
m.apidoc.core.common.Assert
;
import
ki
m.apidoc.core.common.markup.MarkupBuilder
;
import
com.google.common.base.Strings
;
import
java.util.List
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/markup/asciidoc/Color.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/markup/asciidoc/Color.java
View file @
46cafbb5
package
co
m.apidoc.core.common.markup.asciidoc
;
package
ki
m.apidoc.core.common.markup.asciidoc
;
/**
* https://en.wikipedia.org/wiki/Web_colors#HTML_color_names
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/markup/markdown/Markdown.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/markup/markdown/Markdown.java
View file @
46cafbb5
package
co
m.apidoc.core.common.markup.markdown
;
package
ki
m.apidoc.core.common.markup.markdown
;
public
enum
Markdown
implements
CharSequence
{
EXTENSION
(
".md"
),
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/markup/markdown/MarkdownBuilder.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/markup/markdown/MarkdownBuilder.java
View file @
46cafbb5
package
co
m.apidoc.core.common.markup.markdown
;
package
ki
m.apidoc.core.common.markup.markdown
;
import
co
m.apidoc.core.common.Assert
;
import
co
m.apidoc.core.common.markup.MarkupBuilder
;
import
ki
m.apidoc.core.common.Assert
;
import
ki
m.apidoc.core.common.markup.MarkupBuilder
;
import
com.google.common.base.Strings
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
java.util.regex.Matcher
;
import
static
com
.
apidoc
.
core
.
common
.
markup
.
markdown
.
Markdown
.*;
public
class
MarkdownBuilder
implements
MarkupBuilder
{
public
static
final
int
MAX_TITLE
=
6
;
...
...
@@ -19,7 +17,7 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override
public
MarkupBuilder
header
(
String
text
,
CharSequence
...
attrs
)
{
Assert
.
notBlank
(
text
,
"header must not be blank"
);
content
.
append
(
HEADER
);
content
.
append
(
Markdown
.
HEADER
);
content
.
append
(
nobr
(
text
.
trim
()));
br
();
return
this
;
...
...
@@ -30,7 +28,7 @@ public class MarkdownBuilder implements MarkupBuilder {
Assert
.
notBlank
(
text
,
"header must not be blank"
);
Assert
.
between
(
level
,
1
,
MAX_TITLE
,
"title level can not be "
+
level
);
br
();
content
.
append
(
Strings
.
repeat
(
TITLE
.
toString
(),
level
+
1
)).
append
(
WHITESPACE
)
content
.
append
(
Strings
.
repeat
(
Markdown
.
TITLE
.
toString
(),
level
+
1
)).
append
(
Markdown
.
WHITESPACE
)
.
append
(
nobr
(
text
.
trim
()));
br
();
return
this
;
...
...
@@ -67,35 +65,35 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override
public
MarkupBuilder
note
(
String
text
)
{
content
.
append
(
QUOTE
);
content
.
append
(
Markdown
.
QUOTE
);
paragraph
(
text
);
return
this
;
}
@Override
public
MarkupBuilder
tip
(
String
text
)
{
content
.
append
(
QUOTE
);
content
.
append
(
Markdown
.
QUOTE
);
paragraph
(
text
);
return
this
;
}
@Override
public
MarkupBuilder
important
(
String
text
)
{
content
.
append
(
QUOTE
);
content
.
append
(
Markdown
.
QUOTE
);
paragraph
(
text
);
return
this
;
}
@Override
public
MarkupBuilder
warning
(
String
text
)
{
content
.
append
(
QUOTE
);
content
.
append
(
Markdown
.
QUOTE
);
paragraph
(
text
);
return
this
;
}
@Override
public
MarkupBuilder
caution
(
String
text
)
{
content
.
append
(
QUOTE
);
content
.
append
(
Markdown
.
QUOTE
);
paragraph
(
text
);
return
this
;
}
...
...
@@ -114,42 +112,42 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override
public
MarkupBuilder
listing
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
literal
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
sidebar
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
comment
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
passthrough
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
quote
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
example
(
Consumer
<
MarkupBuilder
>
consumer
,
CharSequence
...
attrs
)
{
return
block
(
consumer
,
LISTING
,
attrs
);
return
block
(
consumer
,
Markdown
.
LISTING
,
attrs
);
}
@Override
public
MarkupBuilder
list
(
String
text
)
{
return
list
(
text
,
LIST_FLAG
);
return
list
(
text
,
Markdown
.
LIST_FLAG
);
}
@Override
...
...
@@ -187,28 +185,28 @@ public class MarkdownBuilder implements MarkupBuilder {
public
MarkupBuilder
table
(
List
<
List
<
String
>>
data
,
boolean
header
,
boolean
footer
)
{
for
(
int
i
=
0
;
i
<
data
.
size
();
i
++)
{
content
.
append
(
TABLE_CELL
);
content
.
append
(
Markdown
.
TABLE_CELL
);
for
(
int
j
=
0
;
j
<
data
.
get
(
i
).
size
();
j
++)
{
String
value
=
data
.
get
(
i
).
get
(
j
);
if
(
value
!=
null
){
content
.
append
(
data
.
get
(
i
).
get
(
j
).
replace
(
TABLE_CELL
,
"\\"
+
TABLE_CELL
));
content
.
append
(
data
.
get
(
i
).
get
(
j
).
replace
(
Markdown
.
TABLE_CELL
,
"\\"
+
Markdown
.
TABLE_CELL
));
}
else
{
content
.
append
(
" "
);
}
content
.
append
(
TABLE_CELL
);
content
.
append
(
Markdown
.
TABLE_CELL
);
}
br
();
if
(
i
==
0
&&
header
){
content
.
append
(
TABLE_CELL
);
content
.
append
(
Markdown
.
TABLE_CELL
);
for
(
int
j
=
0
;
j
<
data
.
get
(
i
).
size
();
j
++)
{
content
.
append
(
TABLE_Header
);
content
.
append
(
Markdown
.
TABLE_Header
);
}
br
();
}
if
(
i
==
data
.
size
()-
2
&&
footer
){
content
.
append
(
TABLE_CELL
);
content
.
append
(
Markdown
.
TABLE_CELL
);
for
(
int
j
=
0
;
j
<
data
.
get
(
i
).
size
();
j
++)
{
content
.
append
(
TABLE_Header
);
content
.
append
(
Markdown
.
TABLE_Header
);
}
br
();
}
...
...
@@ -231,55 +229,55 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override
public
MarkupBuilder
emphasized
(
String
text
,
CharSequence
...
textStyle
)
{
return
style
(
EMPHASIZED
,
text
,
textStyle
);
return
style
(
Markdown
.
EMPHASIZED
,
text
,
textStyle
);
}
@Override
public
MarkupBuilder
strong
(
String
text
,
CharSequence
...
textStyle
)
{
return
style
(
STRONG
,
text
,
textStyle
);
return
style
(
Markdown
.
STRONG
,
text
,
textStyle
);
}
@Override
public
MarkupBuilder
monospaced
(
String
text
,
CharSequence
...
textStyle
)
{
return
style
(
MONOSPACED
,
text
,
textStyle
);
return
style
(
M
arkdown
.
M
ONOSPACED
,
text
,
textStyle
);
}
@Override
public
MarkupBuilder
quoted
(
String
text
,
CharSequence
...
textStyle
)
{
return
style
(
QUOTE
,
text
,
textStyle
);
return
style
(
Markdown
.
QUOTE
,
text
,
textStyle
);
}
@Override
public
MarkupBuilder
doubleQuoted
(
String
text
,
CharSequence
...
textStyle
)
{
return
style
(
DOUBLE_QUOTED
,
text
,
textStyle
);
return
style
(
Markdown
.
DOUBLE_QUOTED
,
text
,
textStyle
);
}
@Override
public
MarkupBuilder
unquoted
(
String
text
,
CharSequence
...
textStyle
)
{
return
style
(
UNQUOTED
,
text
,
textStyle
);
return
style
(
Markdown
.
UNQUOTED
,
text
,
textStyle
);
}
@Override
public
MarkupBuilder
br
()
{
content
.
append
(
BR
);
content
.
append
(
Markdown
.
BR
);
return
this
;
}
@Override
public
MarkupBuilder
hbr
()
{
content
.
append
(
HBR
);
content
.
append
(
Markdown
.
HBR
);
return
this
;
}
@Override
public
MarkupBuilder
newLine
()
{
content
.
append
(
NEW_LINE
);
content
.
append
(
Markdown
.
NEW_LINE
);
return
this
;
}
@Override
public
MarkupBuilder
pageBreak
()
{
content
.
append
(
PAGEBREAKS
);
content
.
append
(
Markdown
.
PAGEBREAKS
);
br
();
return
this
;
}
...
...
@@ -298,8 +296,8 @@ public class MarkdownBuilder implements MarkupBuilder {
if
(
Assert
.
isBlank
(
content
))
{
return
content
;
}
return
content
.
replaceAll
(
BR
.
toString
(),
Matcher
.
quoteReplacement
(
WHITESPACE
.
toString
()));
return
content
.
replaceAll
(
Markdown
.
BR
.
toString
(),
Matcher
.
quoteReplacement
(
Markdown
.
WHITESPACE
.
toString
()));
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Body.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Body.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/BodyMode.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/BodyMode.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
/**
* 对应postman定义的mode
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Folder.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Folder.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Getter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Info.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Info.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Item.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Item.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Parameter.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Parameter.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
co
m.apidoc.core.schema.Row
;
import
ki
m.apidoc.core.schema.Row
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Postman.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Postman.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Request.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Request.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
co
m.apidoc.core.schema.Header
;
import
co
m.apidoc.core.schema.Method
;
import
ki
m.apidoc.core.schema.Header
;
import
ki
m.apidoc.core.schema.Method
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Response.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Response.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
co
m.apidoc.core.schema.Header
;
import
ki
m.apidoc.core.schema.Header
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/common/postman/Url.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/common/postman/Url.java
View file @
46cafbb5
package
co
m.apidoc.core.common.postman
;
package
ki
m.apidoc.core.common.postman
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/parser/ParserStrategy.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/parser/ParserStrategy.java
View file @
46cafbb5
package
co
m.apidoc.core.parser
;
package
ki
m.apidoc.core.parser
;
import
co
m.apidoc.core.schema.Chapter
;
import
co
m.apidoc.core.schema.Section
;
import
ki
m.apidoc.core.schema.Chapter
;
import
ki
m.apidoc.core.schema.Section
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/parser/VisitorParser.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/parser/VisitorParser.java
View file @
46cafbb5
package
co
m.apidoc.core.parser
;
package
ki
m.apidoc.core.parser
;
import
co
m.apidoc.core.common.helper.OptionalHelper
;
import
co
m.apidoc.core.schema.Chapter
;
import
co
m.apidoc.core.schema.Node
;
import
co
m.apidoc.core.schema.Project
;
import
co
m.apidoc.core.schema.Section
;
import
ki
m.apidoc.core.common.helper.OptionalHelper
;
import
ki
m.apidoc.core.schema.Chapter
;
import
ki
m.apidoc.core.schema.Node
;
import
ki
m.apidoc.core.schema.Project
;
import
ki
m.apidoc.core.schema.Section
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.visitor.VoidVisitorAdapter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/render/AsciiDocRender.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/render/AsciiDocRender.java
View file @
46cafbb5
package
com.apidoc.core.render
;
import
com.apidoc.core.ApiDoc
;
import
com.apidoc.core.common.helper.FileHelper
;
import
com.apidoc.core.common.helper.StringHelper
;
import
com.apidoc.core.common.markup.MarkupBuilder
;
import
com.apidoc.core.common.markup.asciidoc.AsciiDoc
;
import
com.apidoc.core.schema.*
;
package
kim.apidoc.core.render
;
import
kim.apidoc.core.ApiDoc
;
import
kim.apidoc.core.common.helper.FileHelper
;
import
kim.apidoc.core.common.helper.StringHelper
;
import
kim.apidoc.core.common.markup.MarkupBuilder
;
import
kim.apidoc.core.common.markup.asciidoc.AsciiDoc
;
import
com.google.common.collect.Lists
;
import
kim.apidoc.core.schema.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.asciidoctor.Asciidoctor
;
import
org.asciidoctor.AttributesBuilder
;
...
...
apidoc-core/src/main/java/kim/apidoc/core/render/MarkdownRender.java
0 → 100644
View file @
46cafbb5
package
kim.apidoc.core.render
;
import
kim.apidoc.core.schema.Project
;
/**
* 生成markdown api文档
*
* @author duanledexianxianxian
* @version 1.0.0
* @date 2020 /3/26 19:03
* @since 1.0.0
*/
public
class
MarkdownRender
implements
ProjectRender
{
@Override
public
void
render
(
Project
project
)
{
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/render/PostmanRender.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/render/PostmanRender.java
View file @
46cafbb5
package
co
m.apidoc.core.render
;
package
ki
m.apidoc.core.render
;
import
com.apidoc.core.ApiDoc
;
import
com.apidoc.core.common.ObjectMappers
;
import
com.apidoc.core.common.helper.FileHelper
;
import
com.apidoc.core.common.postman.*
;
import
com.apidoc.core.schema.*
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
kim.apidoc.core.ApiDoc
;
import
kim.apidoc.core.common.ObjectMappers
;
import
kim.apidoc.core.common.helper.FileHelper
;
import
kim.apidoc.core.common.postman.*
;
import
kim.apidoc.core.schema.*
;
import
lombok.extern.slf4j.Slf4j
;
import
java.nio.file.Path
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/render/ProjectRender.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/render/ProjectRender.java
View file @
46cafbb5
package
co
m.apidoc.core.render
;
package
ki
m.apidoc.core.render
;
import
co
m.apidoc.core.schema.Project
;
import
ki
m.apidoc.core.schema.Project
;
/**
* The interface Project render.
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/ArrayTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/ArrayTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.ApiDoc
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.ArrayTypeDescription
;
import
ki
m.apidoc.core.ApiDoc
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.ArrayTypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
public
class
ArrayTypeResolver
implements
TypeResolver
{
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/CollectionTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/CollectionTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.ApiDoc
;
import
co
m.apidoc.core.common.helper.TypeParameterHelper
;
import
co
m.apidoc.core.common.description.ArrayTypeDescription
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
ki
m.apidoc.core.ApiDoc
;
import
ki
m.apidoc.core.common.helper.TypeParameterHelper
;
import
ki
m.apidoc.core.common.description.ArrayTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
import
com.google.common.collect.ImmutableList
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/DateTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/DateTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.StringTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.StringTypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
import
com.google.common.collect.ImmutableList
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/EnumTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/EnumTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.StringTypeDescription
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.StringTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
com.github.javaparser.resolution.declarations.ResolvedEnumConstantDeclaration
;
import
com.github.javaparser.resolution.declarations.ResolvedEnumDeclaration
;
import
com.github.javaparser.resolution.types.ResolvedType
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/MapTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/MapTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
import
com.google.common.collect.ImmutableList
;
...
...
@@ -9,24 +9,14 @@ import com.google.common.collect.ImmutableList;
* 不支持直接使用Map,建议使用DTO
*/
public
class
MapTypeResolver
implements
TypeResolver
{
@Override
public
boolean
accept
(
ResolvedType
type
)
{
return
isMap
(
type
);
}
@Override
public
TypeDescription
resolve
(
ResolvedType
type
)
{
return
new
UnAvailableTypeDescription
();
}
private
static
boolean
isMap
(
ResolvedType
type
){
if
(!
type
.
isReferenceType
()){
private
static
boolean
isMap
(
ResolvedType
type
)
{
if
(!
type
.
isReferenceType
())
{
return
false
;
}
return
isMap
(
type
.
asReferenceType
().
getId
());
}
private
static
boolean
isMap
(
String
id
){
private
static
boolean
isMap
(
String
id
)
{
return
ImmutableList
.
of
(
"java.util.Map"
,
"java.util.HashMap"
,
"java.util.Hashtable"
,
...
...
@@ -35,4 +25,14 @@ public class MapTypeResolver implements TypeResolver {
"java.lang.TreeMap"
).
contains
(
id
);
}
@Override
public
boolean
accept
(
ResolvedType
type
)
{
return
isMap
(
type
);
}
@Override
public
TypeDescription
resolve
(
ResolvedType
type
)
{
return
new
UnAvailableTypeDescription
();
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/ObjectTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/ObjectTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
com.apidoc.core.ApiDoc
;
import
com.apidoc.core.common.description.ObjectTypeDescription
;
import
com.apidoc.core.common.description.TypeDescription
;
import
com.apidoc.core.common.helper.*
;
import
com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration
;
import
com.github.javaparser.resolution.types.ResolvedReferenceType
;
import
com.github.javaparser.resolution.types.ResolvedType
;
import
kim.apidoc.core.ApiDoc
;
import
kim.apidoc.core.common.description.ObjectTypeDescription
;
import
kim.apidoc.core.common.description.TypeDescription
;
import
kim.apidoc.core.common.helper.*
;
import
java.util.Optional
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/PrimitiveTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/PrimitiveTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.PrimitiveTypeDescription
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.PrimitiveTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
import
com.google.common.collect.ImmutableList
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/StringTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/StringTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.StringTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.StringTypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
import
com.google.common.collect.ImmutableList
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/SystemObjectTypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/SystemObjectTypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
public
class
SystemObjectTypeResolver
implements
TypeResolver
{
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/TypeNameResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/TypeNameResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
com.github.javaparser.ast.type.Type
;
public
interface
TypeNameResolver
{
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/TypeResolver.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/TypeResolver.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
com.github.javaparser.resolution.types.ResolvedType
;
public
interface
TypeResolver
{
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/resolver/TypeResolvers.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/resolver/TypeResolvers.java
View file @
46cafbb5
package
co
m.apidoc.core.resolver
;
package
ki
m.apidoc.core.resolver
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.helper.TypeNameHelper
;
import
co
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.helper.TypeNameHelper
;
import
ki
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
com.github.javaparser.ast.type.Type
;
import
com.github.javaparser.resolution.UnsolvedSymbolException
;
import
com.github.javaparser.resolution.types.ResolvedType
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Book.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Book.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -6,14 +6,31 @@ import lombok.Setter;
import
java.util.Set
;
import
java.util.TreeSet
;
/**
* The type Book.
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Setter
@Getter
public
class
Book
extends
Node
{
/**
* The constant DEFAULT.
*/
public
static
final
String
DEFAULT
=
"index"
;
/**
* 章
*/
Set
<
Chapter
>
chapters
=
new
TreeSet
<>();
/**
* Instantiates a new Book.
*
* @param id the id
*/
public
Book
(
String
id
)
{
this
.
id
=
id
;
}
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Chapter.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Chapter.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -8,13 +8,22 @@ import java.util.TreeSet;
/**
* 章,一个类解析为一章
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Setter
@Getter
public
class
Chapter
extends
Node
{
/**
* The Book name.
*/
String
bookName
;
/**
* The Sections.
*/
Set
<
Section
>
sections
=
new
TreeSet
<>();
}
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Header.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Header.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
/**
* The type Header.
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Setter
@Getter
@NoArgsConstructor
public
class
Header
{
public
class
Header
{
public
static
final
Header
APPLICATION_JSON
=
new
Header
(
"Content-Type"
,
"application/json"
);
public
static
final
Header
X_FORM_WWW_URLENCODED
=
new
Header
(
"Content-Type"
,
"x-www-form-urlencoded"
);
/**
* The constant APPLICATION_JSON.
*/
public
static
final
Header
APPLICATION_JSON
=
new
Header
(
"Content-Type"
,
"application/json"
);
/**
* The constant X_FORM_WWW_URLENCODED.
*/
public
static
final
Header
X_FORM_WWW_URLENCODED
=
new
Header
(
"Content-Type"
,
"x-www-form-urlencoded"
);
/**
* The Key.
*/
String
key
;
/**
* The Value.
*/
String
value
;
/**
* The Description.
*/
String
description
;
/**
* Instantiates a new Header.
*
* @param key the key
* @param value the value
*/
public
Header
(
String
key
,
String
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
static
Header
valueOf
(
String
text
){
/**
* Value of header.
*
* @param text the text
* @return the header
*/
public
static
Header
valueOf
(
String
text
)
{
String
[]
arr
=
text
.
split
(
":"
);
Header
header
=
new
Header
();
header
.
setKey
(
arr
[
0
]);
if
(
arr
.
length
>
1
)
{
if
(
arr
.
length
>
1
)
{
header
.
setValue
(
arr
[
1
]);
}
return
header
;
}
@Override
public
String
toString
(){
public
String
toString
()
{
return
key
+
": "
+
value
;
}
...
...
apidoc-core/src/main/java/kim/apidoc/core/schema/Method.java
0 → 100644
View file @
46cafbb5
package
kim.apidoc.core.schema
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 支持的http method
* @author fengyuchenglun
*/
@Slf4j
public
enum
Method
{
/**
* Get method.
*/
GET
,
/**
* Post method.
*/
POST
,
/**
* Put method.
*/
PUT
,
/**
* Delete method.
*/
DELETE
,
/**
* Options method.
*/
OPTIONS
,
/**
* Patch method.
*/
PATCH
,
/**
* Copy method.
*/
COPY
,
/**
* Head method.
*/
HEAD
,
/**
* Link method.
*/
LINK
,
/**
* Unlink method.
*/
UNLINK
,
/**
* Purge method.
*/
PURGE
,
/**
* Lock method.
*/
LOCK
,
/**
* Unlock method.
*/
UNLOCK
,
/**
* Propfind method.
*/
PROPFIND
,
/**
* View method.
*/
VIEW
;
/**
* Of method.
*
* @param name the name
* @return the method
*/
public
static
Method
of
(
String
name
)
{
return
valueOf
(
name
);
}
}
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Node.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Node.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
co
m.apidoc.core.Context
;
import
co
m.apidoc.core.common.helper.CommentHelper
;
import
co
m.apidoc.core.common.helper.StringHelper
;
import
ki
m.apidoc.core.Context
;
import
ki
m.apidoc.core.common.helper.CommentHelper
;
import
ki
m.apidoc.core.common.helper.StringHelper
;
import
com.github.javaparser.ast.comments.Comment
;
import
com.github.javaparser.javadoc.Javadoc
;
import
lombok.Getter
;
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Project.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Project.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -31,7 +31,7 @@ public class Project extends Node {
* @param chapter the chapter
*/
public
void
addChapter
(
Chapter
chapter
)
{
if
(
Objects
.
isNull
(
chapter
.
getBookName
()))
{
if
(
Objects
.
isNull
(
chapter
.
getBookName
()))
{
chapter
.
setBookName
(
Book
.
DEFAULT
);
}
if
(!
books
.
containsKey
(
chapter
.
getBookName
()))
{
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Row.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Row.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
lombok.*
;
/**
* The type Row.
*
* @author fengyuchenglun
* @version 1.0.0
*/
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
...
...
@@ -9,12 +15,32 @@ import lombok.*;
@Getter
public
class
Row
{
/**
* The Key.
*/
String
key
;
/**
* The Type.
*/
String
type
;
/**
* The Condition.
*/
String
condition
;
/**
* The Def.
*/
String
def
;
/**
* The Remark.
*/
String
remark
;
/**
* Instantiates a new Row.
*
* @param type the type
*/
public
Row
(
String
type
)
{
this
.
type
=
type
;
}
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Section.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Section.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
co
m.apidoc.core.common.ObjectMappers
;
import
co
m.apidoc.core.common.QueryStringBuilder
;
import
co
m.apidoc.core.common.helper.StringHelper
;
import
ki
m.apidoc.core.common.ObjectMappers
;
import
ki
m.apidoc.core.common.QueryStringBuilder
;
import
ki
m.apidoc.core.common.helper.StringHelper
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
lombok.Getter
;
...
...
@@ -12,42 +12,93 @@ import java.util.*;
/**
* 小节,一个请求,封装为一个小节
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Setter
@Getter
public
class
Section
extends
Node
{
/**
* The Method.
*/
Method
method
;
/**
* The Uri.
*/
String
uri
;
Map
<
String
,
Header
>
inHeaders
=
new
LinkedHashMap
<>();
/**
* The In headers.
*/
Map
<
String
,
Header
>
inHeaders
=
new
LinkedHashMap
<>();
/**
* The Path variable.
*/
ObjectNode
pathVariable
=
ObjectMappers
.
instance
.
createObjectNode
();
/**
* The Parameter.
*/
JsonNode
parameter
;
/**
* The Query parameter.
*/
boolean
queryParameter
=
true
;
Map
<
String
,
Row
>
requestRows
=
new
LinkedHashMap
<>();
/**
* The Request rows.
*/
Map
<
String
,
Row
>
requestRows
=
new
LinkedHashMap
<>();
Map
<
String
,
Header
>
outHeaders
=
new
LinkedHashMap
<>();
/**
* The Out headers.
*/
Map
<
String
,
Header
>
outHeaders
=
new
LinkedHashMap
<>();
/**
* The Response.
*/
JsonNode
response
;
Map
<
String
,
Row
>
responseRows
=
new
LinkedHashMap
<>();
/**
* The Response rows.
*/
Map
<
String
,
Row
>
responseRows
=
new
LinkedHashMap
<>();
/**
* The Raw response.
*/
Object
rawResponse
;
public
void
addRequestRow
(
Row
row
){
/**
* Add request row.
*
* @param row the row
*/
public
void
addRequestRow
(
Row
row
)
{
requestRows
.
put
(
row
.
getKey
(),
row
);
}
public
void
addRequestRows
(
Collection
<
Row
>
rows
){
/**
* Add request rows.
*
* @param rows the rows
*/
public
void
addRequestRows
(
Collection
<
Row
>
rows
)
{
for
(
Row
row
:
rows
)
{
if
(
row
.
getKey
()!=
null
&&
!
requestRows
.
containsKey
(
row
.
getKey
()))
{
requestRows
.
put
(
row
.
getKey
(),
row
);
if
(
row
.
getKey
()
!=
null
&&
!
requestRows
.
containsKey
(
row
.
getKey
()))
{
requestRows
.
put
(
row
.
getKey
(),
row
);
}
}
}
public
String
getRequestLine
(){
/**
* Get request line string.
*
* @return the string
*/
public
String
getRequestLine
()
{
StringBuilder
builder
=
new
StringBuilder
(
this
.
method
.
toString
());
builder
.
append
(
" "
).
append
(
this
.
uri
);
if
(
this
.
queryParameter
&&
Objects
.
equals
(
"GET"
,
this
.
method
))
{
if
(
this
.
queryParameter
&&
Objects
.
equals
(
"GET"
,
this
.
method
))
{
String
parameterString
=
getParameterString
();
if
(
StringHelper
.
nonBlank
(
parameterString
))
{
if
(
StringHelper
.
nonBlank
(
parameterString
))
{
builder
.
append
(
"?"
).
append
(
parameterString
);
}
}
...
...
@@ -55,52 +106,92 @@ public class Section extends Node {
return
builder
.
toString
();
}
public
String
getParameterString
(){
if
(
queryParameter
&&
parameter
instanceof
ObjectNode
){
return
new
QueryStringBuilder
().
append
((
ObjectNode
)
parameter
).
toString
();
/**
* Get parameter string string.
*
* @return the string
*/
public
String
getParameterString
()
{
if
(
queryParameter
&&
parameter
instanceof
ObjectNode
)
{
return
new
QueryStringBuilder
().
append
((
ObjectNode
)
parameter
).
toString
();
}
return
ObjectMappers
.
pretty
(
parameter
);
}
public
boolean
hasRequestBody
(){
if
(
Objects
.
equals
(
"GET"
,
this
.
method
)){
/**
* Has request body boolean.
*
* @return the boolean
*/
public
boolean
hasRequestBody
()
{
if
(
Objects
.
equals
(
"GET"
,
this
.
method
))
{
return
false
;
}
return
parameter
!=
null
&&
parameter
.
size
()>
0
;
return
parameter
!=
null
&&
parameter
.
size
()
>
0
;
}
public
void
addResponseRow
(
Row
row
){
/**
* Add response row.
*
* @param row the row
*/
public
void
addResponseRow
(
Row
row
)
{
responseRows
.
put
(
row
.
getKey
(),
row
);
}
public
void
addResponseRows
(
Collection
<
Row
>
rows
){
/**
* Add response rows.
*
* @param rows the rows
*/
public
void
addResponseRows
(
Collection
<
Row
>
rows
)
{
for
(
Row
row
:
rows
)
{
if
(
row
.
getKey
()!=
null
&&
!
responseRows
.
containsKey
(
row
.
getKey
()))
{
if
(
row
.
getKey
()
!=
null
&&
!
responseRows
.
containsKey
(
row
.
getKey
()))
{
responseRows
.
put
(
row
.
getKey
(),
row
);
}
}
}
public
boolean
hasResponseBody
(){
return
response
!=
null
||
rawResponse
!=
null
;
/**
* Has response body boolean.
*
* @return the boolean
*/
public
boolean
hasResponseBody
()
{
return
response
!=
null
||
rawResponse
!=
null
;
}
public
String
getResponseString
(){
if
(
response
!=
null
){
/**
* Get response string string.
*
* @return the string
*/
public
String
getResponseString
()
{
if
(
response
!=
null
)
{
return
ObjectMappers
.
pretty
(
response
);
}
return
String
.
valueOf
(
rawResponse
);
}
public
void
addInHeader
(
Header
header
){
/**
* Add in header.
*
* @param header the header
*/
public
void
addInHeader
(
Header
header
)
{
if
(!
inHeaders
.
containsKey
(
header
.
getKey
()))
{
inHeaders
.
put
(
header
.
getKey
(),
header
);
inHeaders
.
put
(
header
.
getKey
(),
header
);
}
}
public
void
addOutHeader
(
Header
header
){
/**
* Add out header.
*
* @param header the header
*/
public
void
addOutHeader
(
Header
header
)
{
if
(!
outHeaders
.
containsKey
(
header
.
getKey
()))
{
outHeaders
.
put
(
header
.
getKey
(),
header
);
outHeaders
.
put
(
header
.
getKey
(),
header
);
}
}
...
...
apidoc-core/src/main/java/
co
m/apidoc/core/schema/Tag.java
→
apidoc-core/src/main/java/
ki
m/apidoc/core/schema/Tag.java
View file @
46cafbb5
package
co
m.apidoc.core.schema
;
package
ki
m.apidoc.core.schema
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -9,22 +9,40 @@ import java.util.Objects;
/**
* //@param username 用户名
* id key content
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Slf4j
@Setter
@Getter
public
class
Tag
{
/**
* The Id.
*/
String
id
;
/**
* The Key.
*/
String
key
;
/**
* The Content.
*/
String
content
;
public
int
getIntContent
(
int
def
){
/**
* Get int content int.
*
* @param def the def
* @return the int
*/
public
int
getIntContent
(
int
def
)
{
if
(
Objects
.
nonNull
(
content
))
{
try
{
try
{
return
Integer
.
parseInt
(
content
);
}
catch
(
Exception
e
)
{
log
.
warn
(
content
+
" parse error"
);
}
catch
(
Exception
e
)
{
log
.
warn
(
content
+
" parse error"
);
}
}
return
def
;
...
...
apidoc-springmvc/src/main/java/com/
apigc
c/springmvc/ParameterHelper.java
→
apidoc-springmvc/src/main/java/com/
kim/apido
c/springmvc/ParameterHelper.java
View file @
46cafbb5
package
com.
apigc
c.springmvc
;
package
com.
kim.apido
c.springmvc
;
import
com.github.javaparser.ast.NodeList
;
import
com.github.javaparser.ast.body.Parameter
;
...
...
apidoc-springmvc/src/main/java/com/
apigc
c/springmvc/RequestMappingHelper.java
→
apidoc-springmvc/src/main/java/com/
kim/apido
c/springmvc/RequestMappingHelper.java
View file @
46cafbb5
package
com.
apigc
c.springmvc
;
package
com.
kim.apido
c.springmvc
;
import
co
m.apidoc.core.common.URI
;
import
co
m.apidoc.core.common.helper.AnnotationHelper
;
import
co
m.apidoc.core.common.helper.ClassDeclarationHelper
;
import
co
m.apidoc.core.common.helper.ExpressionHelper
;
import
co
m.apidoc.core.schema.Method
;
import
ki
m.apidoc.core.common.URI
;
import
ki
m.apidoc.core.common.helper.AnnotationHelper
;
import
ki
m.apidoc.core.common.helper.ClassDeclarationHelper
;
import
ki
m.apidoc.core.common.helper.ExpressionHelper
;
import
ki
m.apidoc.core.schema.Method
;
import
com.github.javaparser.ast.Node
;
import
com.github.javaparser.ast.NodeList
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
...
...
apidoc-springmvc/src/main/java/com/
apigc
c/springmvc/SpringMVCContext.java
→
apidoc-springmvc/src/main/java/com/
kim/apido
c/springmvc/SpringMVCContext.java
View file @
46cafbb5
package
com.
apigc
c.springmvc
;
package
com.
kim.apido
c.springmvc
;
import
co
m.apidoc.core.ApiDoc
;
import
ki
m.apidoc.core.ApiDoc
;
import
com.google.common.collect.Lists
;
import
lombok.Data
;
...
...
apidoc-springmvc/src/main/java/com/
apigc
c/springmvc/SpringParser.java
→
apidoc-springmvc/src/main/java/com/
kim/apido
c/springmvc/SpringParser.java
View file @
46cafbb5
package
com.
apigc
c.springmvc
;
import
com.
apidoc.core.ApiDoc
;
import
com.apidoc.core.common.URI
;
import
com.apidoc.core.common.description.ObjectTypeDescription
;
import
com.apidoc.core.common.description.
TypeDescription
;
import
com.apidoc.core.common.helper.AnnotationHelper
;
import
com.apidoc.core.common.helper.Express
ionHelper
;
import
com.apidoc.core.common.helper.String
Helper
;
import
com.apidoc.core.parser.ParserStrategy
;
import
com.apidoc.core.schema.Chapter
;
import
com.apidoc.core.schema.Head
er
;
import
com.apidoc.core.schema.Row
;
import
com.apidoc.core.schema.Section
;
import
com.apigcc.springmvc.resovler.SpringComponentTypeResolver
;
package
com.
kim.apido
c.springmvc
;
import
com.
kim.apidoc.springmvc.resovler.SpringComponentTypeResolver
;
import
kim.apidoc.core.ApiDoc
;
import
kim.apidoc.core.common.URI
;
import
kim.apidoc.core.common.description.Object
TypeDescription
;
import
kim.apidoc.core.common.description.TypeDescription
;
import
kim.apidoc.core.common.helper.Annotat
ionHelper
;
import
kim.apidoc.core.common.helper.Expression
Helper
;
import
kim.apidoc.core.common.helper.StringHelper
;
import
kim.apidoc.core.parser.ParserStrategy
;
import
kim.apidoc.core.schema.Chapt
er
;
import
kim.apidoc.core.schema.Header
;
import
kim.apidoc.core.schema.Row
;
import
kim.apidoc.core.schema.Section
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.body.Parameter
;
...
...
@@ -22,9 +22,6 @@ import com.github.javaparser.ast.expr.Expression;
import
java.util.List
;
import
java.util.Optional
;
import
static
com
.
apigcc
.
springmvc
.
ParameterHelper
.
ANNOTATION_REQUEST_HEADER
;
import
static
com
.
apigcc
.
springmvc
.
ParameterHelper
.
ANNOTATION_REQUEST_PARAM
;
/**
* spring 解析
...
...
@@ -196,7 +193,7 @@ public class SpringParser implements ParserStrategy {
if
(
ParameterHelper
.
isRequestHeader
(
parameter
))
{
String
key
=
parameter
.
getNameAsString
();
String
defaultValue
=
"{value}"
;
AnnotationExpr
annotationExpr
=
parameter
.
getAnnotationByName
(
ANNOTATION_REQUEST_HEADER
).
get
();
AnnotationExpr
annotationExpr
=
parameter
.
getAnnotationByName
(
ParameterHelper
.
ANNOTATION_REQUEST_HEADER
).
get
();
Optional
<
Expression
>
valueOptional
=
AnnotationHelper
.
getAnyAttribute
(
annotationExpr
,
"value"
,
"name"
);
if
(
valueOptional
.
isPresent
())
{
key
=
String
.
valueOf
(
ExpressionHelper
.
getValue
(
valueOptional
.
get
()));
...
...
@@ -260,7 +257,7 @@ public class SpringParser implements ParserStrategy {
Object
defaultValue
=
null
;
Boolean
required
=
null
;
Optional
<
AnnotationExpr
>
optional
=
parameter
.
getAnnotationByName
(
ANNOTATION_REQUEST_PARAM
);
Optional
<
AnnotationExpr
>
optional
=
parameter
.
getAnnotationByName
(
ParameterHelper
.
ANNOTATION_REQUEST_PARAM
);
if
(
optional
.
isPresent
())
{
Optional
<
Expression
>
valueOptional
=
AnnotationHelper
.
getAnyAttribute
(
optional
.
get
(),
"value"
,
"name"
);
if
(
valueOptional
.
isPresent
())
{
...
...
apidoc-springmvc/src/main/java/com/
apigc
c/springmvc/resovler/SpringComponentTypeResolver.java
→
apidoc-springmvc/src/main/java/com/
kim/apido
c/springmvc/resovler/SpringComponentTypeResolver.java
View file @
46cafbb5
package
com.
apigc
c.springmvc.resovler
;
import
co
m.apidoc.core.ApiDoc
;
import
co
m.apidoc.core.common.description.TypeDescription
;
import
co
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
co
m.apidoc.core.common.helper.TypeParameterHelper
;
import
co
m.apidoc.core.resolver.TypeNameResolver
;
import
co
m.apidoc.core.resolver.TypeResolver
;
package
com.
kim.apido
c.springmvc.resovler
;
import
ki
m.apidoc.core.ApiDoc
;
import
ki
m.apidoc.core.common.description.TypeDescription
;
import
ki
m.apidoc.core.common.description.UnAvailableTypeDescription
;
import
ki
m.apidoc.core.common.helper.TypeParameterHelper
;
import
ki
m.apidoc.core.resolver.TypeNameResolver
;
import
ki
m.apidoc.core.resolver.TypeResolver
;
import
com.github.javaparser.ast.NodeList
;
import
com.github.javaparser.ast.type.Type
;
import
com.github.javaparser.resolution.types.ResolvedType
;
...
...
apidoc-springmvc/src/main/resources/META-INF/services/com.apidoc.core.parser.ParserStrategy
deleted
100644 → 0
View file @
19054687
com.apigcc.springmvc.SpringParser
\ No newline at end of file
apidoc-springmvc/src/main/resources/META-INF/services/kim.apidoc.core.parser.ParserStrategy
0 → 100644
View file @
46cafbb5
com.kim.apidoc.springmvc.SpringParser
\ No newline at end of file
apidoc-springmvc/src/test/java/com/
apigc
c/example/ApigccTest.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/ApigccTest.java
View file @
46cafbb5
package
com.
apigc
c.example
;
package
com.
kim.apido
c.example
;
import
co
m.apidoc.core.ApiDoc
;
import
co
m.apidoc.core.Context
;
import
ki
m.apidoc.core.ApiDoc
;
import
ki
m.apidoc.core.Context
;
import
org.junit.Test
;
import
java.nio.file.Paths
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/annotation/KimController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/annotation/KimController.java
View file @
46cafbb5
package
com.
apigc
c.example.annotation
;
package
com.
kim.apido
c.example.annotation
;
import
org.springframework.stereotype.Controller
;
import
java.lang.annotation.ElementType
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/annotation/KimResponseBody.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/annotation/KimResponseBody.java
View file @
46cafbb5
package
com.
apigc
c.example.annotation
;
package
com.
kim.apido
c.example.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/Code.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/Code.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
/**
* @code
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/Menu.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/Menu.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/Page.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/Page.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/Query.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/Query.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/ResultData.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/ResultData.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/Role.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/Role.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
/**
* 用户角色
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/StaticFinalCode.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/StaticFinalCode.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
/**
* @code
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/User.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/User.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Getter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/UserDTO.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/UserDTO.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/UserDetails.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/UserDetails.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
/**
* 某些用户信息框架,如spring security的用户登录信息
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/UserQuery.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/UserQuery.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/common/Wrapper.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/common/Wrapper.java
View file @
46cafbb5
package
com.
apigc
c.example.common
;
package
com.
kim.apido
c.example.common
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/BaseController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/BaseController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring
;
package
com.
kim.apido
c.example.spring
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/advanced/AuthController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/advanced/AuthController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.advanced
;
package
com.
kim.apido
c.example.spring.advanced
;
import
com.
apigc
c.example.common.ResultData
;
import
com.
apigc
c.example.spring.BaseController
;
import
com.
kim.apido
c.example.common.ResultData
;
import
com.
kim.apido
c.example.spring.BaseController
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/advanced/EmptyController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/advanced/EmptyController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.advanced
;
package
com.
kim.apido
c.example.spring.advanced
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/advanced/IgnoreController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/advanced/IgnoreController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.advanced
;
package
com.
kim.apido
c.example.spring.advanced
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/advanced/KimUserController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/advanced/KimUserController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.advanced
;
package
com.
kim.apido
c.example.spring.advanced
;
import
com.
apigc
c.example.annotation.KimController
;
import
com.
apigc
c.example.common.ResultData
;
import
com.
apigc
c.example.common.User
;
import
com.
kim.apido
c.example.annotation.KimController
;
import
com.
kim.apido
c.example.common.ResultData
;
import
com.
kim.apido
c.example.common.User
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/advanced/PageController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/advanced/PageController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.advanced
;
package
com.
kim.apido
c.example.spring.advanced
;
import
com.apigcc.example.common.*
;
import
com.apigcc.example.spring.BaseController
;
import
com.apigcc.example.spring.hello.Greeting
;
import
com.apigcc.model.Info
;
import
com.apigcc.model.InfoQuery
;
import
com.kim.apidoc.example.common.*
;
import
com.kim.apidoc.example.spring.BaseController
;
import
com.kim.apidoc.example.spring.hello.Greeting
;
import
org.jruby.ir.Tuple
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/advanced/UserController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/advanced/UserController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.advanced
;
package
com.
kim.apido
c.example.spring.advanced
;
import
com.
apigc
c.example.common.*
;
import
com.
apigc
c.example.spring.BaseController
;
import
com.
kim.apido
c.example.common.*
;
import
com.
kim.apido
c.example.spring.BaseController
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.*
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/hello/Greeting.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/hello/Greeting.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.hello
;
package
com.
kim.apido
c.example.spring.hello
;
public
class
Greeting
{
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/example/spring/hello/GreetingController.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/example/spring/hello/GreetingController.java
View file @
46cafbb5
package
com.
apigc
c.example.spring.hello
;
package
com.
kim.apido
c.example.spring.hello
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
apidoc-springmvc/src/test/java/com/
apigc
c/springmvc/SpringTest.java
→
apidoc-springmvc/src/test/java/com/
kim/apido
c/springmvc/SpringTest.java
View file @
46cafbb5
package
com.
apigc
c.springmvc
;
package
com.
kim.apido
c.springmvc
;
import
co
m.apidoc.core.ApiDoc
;
import
co
m.apidoc.core.Context
;
import
co
m.apidoc.core.common.diff.FileMatcher
;
import
ki
m.apidoc.core.ApiDoc
;
import
ki
m.apidoc.core.Context
;
import
ki
m.apidoc.core.common.diff.FileMatcher
;
import
org.junit.Test
;
import
java.io.IOException
;
...
...
@@ -17,7 +17,7 @@ public class SpringTest {
Context
context
=
new
Context
();
context
.
setId
(
"test"
);
context
.
setName
(
"测试项目"
);
context
.
addSource
(
Paths
.
get
(
"K:\\@project-dianli@\\
apigcc\\apigc
c-springmvc\\src\\test\\java"
));
context
.
addSource
(
Paths
.
get
(
"K:\\@project-dianli@\\
tool\\apidoc\\apido
c-springmvc\\src\\test\\java"
));
// context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css");
ApiDoc
apigcc
=
new
ApiDoc
(
context
);
...
...
@@ -47,7 +47,7 @@ public class SpringTest {
FileMatcher
fileMatcher
=
new
FileMatcher
();
int
changed
=
fileMatcher
.
compare
(
template
,
buildAdoc
);
if
(
changed
>
0
){
fileMatcher
.
rederHtml
(
templateHtml
,
resultHtml
);
fileMatcher
.
re
n
derHtml
(
templateHtml
,
resultHtml
);
}
System
.
out
.
println
(
"BUILD SUCCESS"
);
...
...
@@ -76,7 +76,7 @@ public class SpringTest {
FileMatcher
fileMatcher
=
new
FileMatcher
();
int
changed
=
fileMatcher
.
compare
(
template
,
buildAdoc
);
if
(
changed
>
0
){
fileMatcher
.
rederHtml
(
templateHtml
,
resultHtml
);
fileMatcher
.
re
n
derHtml
(
templateHtml
,
resultHtml
);
}
System
.
out
.
println
(
"BUILD SUCCESS"
);
...
...
markdown接口模版.md
View file @
46cafbb5
...
...
@@ -56,9 +56,9 @@ POST /api/v1/users HTTP/1.1
}
```
| Field | Type |
Condition | Default |
Description |
| :------- | :----- | :--------
| :------ | :--------
-- |
| loginId | String |
| |
用户编号 |
| userName | String |
| |
用户名 |
| password | String |
| |
密码 |
| Field | Type | Description |
| :------- | :----- | :---------- |
| loginId | String | 用户编号 |
| userName | String | 用户名 |
| password | String | 密码 |
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