Commit 46cafbb5 authored by duanledexianxianxian's avatar duanledexianxianxian 😁

Refactoring code.

parent 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);
}
}
package com.apidoc.core; package kim.apidoc.core;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.StringHelper;
import com.apidoc.core.parser.ParserStrategy; import kim.apidoc.core.parser.ParserStrategy;
import com.apidoc.core.parser.VisitorParser; import kim.apidoc.core.parser.VisitorParser;
import com.apidoc.core.render.ProjectRender; import kim.apidoc.core.render.ProjectRender;
import com.apidoc.core.resolver.TypeResolvers; import kim.apidoc.core.resolver.TypeResolvers;
import com.apidoc.core.schema.Project; import kim.apidoc.core.schema.Project;
import com.github.javaparser.ParseResult; import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration; import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.CompilationUnit;
...@@ -38,17 +38,6 @@ public class ApiDoc { ...@@ -38,17 +38,6 @@ public class ApiDoc {
* ApiDoc实例 * ApiDoc实例
*/ */
private static ApiDoc INSTANCE; 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 { ...@@ -59,7 +48,6 @@ public class ApiDoc {
*/ */
@Getter @Getter
private Project project = new Project(); private Project project = new Project();
/** /**
* The Visitor parser. * The Visitor parser.
*/ */
...@@ -68,7 +56,6 @@ public class ApiDoc { ...@@ -68,7 +56,6 @@ public class ApiDoc {
* The Parser configuration. * The Parser configuration.
*/ */
private ParserConfiguration parserConfiguration; private ParserConfiguration parserConfiguration;
/** /**
* The Type resolvers. * The Type resolvers.
*/ */
...@@ -78,7 +65,7 @@ public class ApiDoc { ...@@ -78,7 +65,7 @@ public class ApiDoc {
/** /**
* Instantiates a new ApiDoc. * Instantiates a new ApiDoc.
*/ */
private ApiDoc(){ private ApiDoc() {
init(new Context()); init(new Context());
} }
...@@ -87,16 +74,25 @@ public class ApiDoc { ...@@ -87,16 +74,25 @@ public class ApiDoc {
* *
* @param context the context * @param context the context
*/ */
public ApiDoc(Context context){ public ApiDoc(Context context) {
init(context); init(context);
} }
/**
* Get instance api doc.
*
* @return the api doc
*/
public static ApiDoc getInstance() {
return INSTANCE;
}
/** /**
* 初始化环境配置 * 初始化环境配置
* *
* @param context the context * @param context the context
*/ */
private void init(Context context){ private void init(Context context) {
INSTANCE = this; INSTANCE = this;
this.context = context; this.context = context;
project.setId(context.getId()); project.setId(context.getId());
...@@ -133,21 +129,21 @@ public class ApiDoc { ...@@ -133,21 +129,21 @@ public class ApiDoc {
* *
* @return the parser strategy * @return the parser strategy
*/ */
private ParserStrategy loadParserStrategy(){ private ParserStrategy loadParserStrategy() {
ServiceLoader<ParserStrategy> serviceLoader = ServiceLoader.load(ParserStrategy.class); ServiceLoader<ParserStrategy> serviceLoader = ServiceLoader.load(ParserStrategy.class);
List<ParserStrategy> strategies = Lists.newArrayList(serviceLoader); List<ParserStrategy> strategies = Lists.newArrayList(serviceLoader);
if(strategies.isEmpty()){ if (strategies.isEmpty()) {
throw new IllegalArgumentException("no ParserStrategy implements found"); throw new IllegalArgumentException("no ParserStrategy implements found");
} }
if(StringHelper.isBlank(context.framework)){ if (StringHelper.isBlank(context.framework)) {
return strategies.get(0); return strategies.get(0);
} }
for (ParserStrategy strategy : strategies) { for (ParserStrategy strategy : strategies) {
if(Objects.equals(context.framework,strategy.name())){ if (Objects.equals(context.framework, strategy.name())) {
return strategy; 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 { ...@@ -155,12 +151,12 @@ public class ApiDoc {
* *
* @return project project * @return project project
*/ */
public Project parse(){ public Project parse() {
for (Path source : this.context.getSources()) { for (Path source : this.context.getSources()) {
SourceRoot root = new SourceRoot(source, parserConfiguration); SourceRoot root = new SourceRoot(source, parserConfiguration);
try { try {
for (ParseResult<CompilationUnit> result : root.tryToParse()) { for (ParseResult<CompilationUnit> result : root.tryToParse()) {
if(result.isSuccessful() && result.getResult().isPresent()){ if (result.isSuccessful() && result.getResult().isPresent()) {
result.getResult().get().accept(visitorParser, project); result.getResult().get().accept(visitorParser, project);
} }
} }
...@@ -174,7 +170,7 @@ public class ApiDoc { ...@@ -174,7 +170,7 @@ public class ApiDoc {
/** /**
* 渲染解析结果 * 渲染解析结果
*/ */
public void render(){ public void render() {
for (ProjectRender render : this.context.getRenders()) { for (ProjectRender render : this.context.getRenders()) {
render.render(project); render.render(project);
} }
......
package com.apidoc.core; package kim.apidoc.core;
import com.apidoc.core.common.helper.FileHelper; import kim.apidoc.core.common.helper.FileHelper;
import com.apidoc.core.render.AsciiDocRender; import kim.apidoc.core.render.AsciiDocRender;
import com.apidoc.core.render.PostmanRender; import kim.apidoc.core.render.PostmanRender;
import com.apidoc.core.render.ProjectRender; import kim.apidoc.core.render.ProjectRender;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.Getter; import lombok.Getter;
......
package com.apidoc.core.common; package kim.apidoc.core.common;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
package com.apidoc.core.common; package kim.apidoc.core.common;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
......
package com.apidoc.core.common; package kim.apidoc.core.common;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
......
package com.apidoc.core.common; package kim.apidoc.core.common;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.StringHelper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
......
package com.apidoc.core.common.description; package kim.apidoc.core.common.description;
import com.apidoc.core.common.ObjectMappers; import kim.apidoc.core.common.ObjectMappers;
import com.apidoc.core.schema.Row; import kim.apidoc.core.schema.Row;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -15,47 +15,47 @@ public class ArrayTypeDescription extends TypeDescription { ...@@ -15,47 +15,47 @@ public class ArrayTypeDescription extends TypeDescription {
public ArrayTypeDescription(TypeDescription component) { public ArrayTypeDescription(TypeDescription component) {
this.component = component; this.component = component;
this.value = ObjectMappers.instance.createArrayNode(); this.value = ObjectMappers.instance.createArrayNode();
if(component.isAvailable()){ if (component.isAvailable()) {
this.type = component.getType() + "[]"; this.type = component.getType() + "[]";
if(component.isPrimitive()){ if (component.isPrimitive()) {
primitive(component.asPrimitive()); primitive(component.asPrimitive());
}else if(component.isString()){ } else if (component.isString()) {
value.add(component.asString().getValue()); value.add(component.asString().getValue());
}else if(component.isArray()){ } else if (component.isArray()) {
value.add(component.asArray().getValue()); value.add(component.asArray().getValue());
}else if(component.isObject()){ } else if (component.isObject()) {
value.add(component.asObject().getValue()); value.add(component.asObject().getValue());
} }
}else{ } else {
this.type = "[]"; this.type = "[]";
} }
} }
public void primitive(PrimitiveTypeDescription typeDescription){ public void primitive(PrimitiveTypeDescription typeDescription) {
switch (typeDescription.getType()){ switch (typeDescription.getType()) {
case "byte": case "byte":
value.add((byte)typeDescription.getValue()); value.add((byte) typeDescription.getValue());
break; break;
case "short": case "short":
value.add((short)typeDescription.getValue()); value.add((short) typeDescription.getValue());
break; break;
case "char": case "char":
value.add((char)typeDescription.getValue()); value.add((char) typeDescription.getValue());
break; break;
case "int": case "int":
value.add((int)typeDescription.getValue()); value.add((int) typeDescription.getValue());
break; break;
case "long": case "long":
value.add((long)typeDescription.getValue()); value.add((long) typeDescription.getValue());
break; break;
case "boolean": case "boolean":
value.add((boolean)typeDescription.getValue()); value.add((boolean) typeDescription.getValue());
break; break;
case "float": case "float":
value.add((float)typeDescription.getValue()); value.add((float) typeDescription.getValue());
break; break;
case "double": case "double":
value.add((double)typeDescription.getValue()); value.add((double) typeDescription.getValue());
break; break;
} }
} }
...@@ -76,17 +76,17 @@ public class ArrayTypeDescription extends TypeDescription { ...@@ -76,17 +76,17 @@ public class ArrayTypeDescription extends TypeDescription {
} }
} }
public ArrayNode getValue(){ public ArrayNode getValue() {
return value; return value;
} }
@Override @Override
public Collection<Row> rows() { public Collection<Row> rows() {
ArrayList<Row> rows = new ArrayList<>(); ArrayList<Row> rows = new ArrayList<>();
if(key != null){ if (key != null) {
rows.addAll(super.rows()); rows.addAll(super.rows());
} }
if(component.isAvailable()){ if (component.isAvailable()) {
rows.addAll(component.rows()); rows.addAll(component.rows());
} }
return rows; return rows;
......
package com.apidoc.core.common.description; package kim.apidoc.core.common.description;
import com.apidoc.core.common.ObjectMappers; import kim.apidoc.core.common.ObjectMappers;
import com.apidoc.core.schema.Row; import kim.apidoc.core.schema.Row;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Getter; import lombok.Getter;
...@@ -14,9 +14,8 @@ import java.util.List; ...@@ -14,9 +14,8 @@ import java.util.List;
@Getter @Getter
public class ObjectTypeDescription extends TypeDescription { public class ObjectTypeDescription extends TypeDescription {
private ObjectNode value = ObjectMappers.instance.createObjectNode();
protected List<TypeDescription> members = Lists.newArrayList(); protected List<TypeDescription> members = Lists.newArrayList();
private ObjectNode value = ObjectMappers.instance.createObjectNode();
public void merge(ObjectTypeDescription other) { public void merge(ObjectTypeDescription other) {
value.setAll(other.getValue()); value.setAll(other.getValue());
...@@ -87,6 +86,7 @@ public class ObjectTypeDescription extends TypeDescription { ...@@ -87,6 +86,7 @@ public class ObjectTypeDescription extends TypeDescription {
} }
} }
@Override
public ObjectNode getValue() { public ObjectNode getValue() {
return value; return value;
} }
......
package com.apidoc.core.common.description; package kim.apidoc.core.common.description;
import com.github.javaparser.resolution.types.ResolvedPrimitiveType; import com.github.javaparser.resolution.types.ResolvedPrimitiveType;
import com.github.javaparser.resolution.types.ResolvedReferenceType; import com.github.javaparser.resolution.types.ResolvedReferenceType;
...@@ -6,8 +6,8 @@ import com.github.javaparser.resolution.types.ResolvedReferenceType; ...@@ -6,8 +6,8 @@ import com.github.javaparser.resolution.types.ResolvedReferenceType;
public class PrimitiveTypeDescription extends TypeDescription { public class PrimitiveTypeDescription extends TypeDescription {
public PrimitiveTypeDescription(ResolvedReferenceType referenceType){ public PrimitiveTypeDescription(ResolvedReferenceType referenceType) {
switch (referenceType.getId()){ switch (referenceType.getId()) {
case "java.lang.Byte": case "java.lang.Byte":
value = (byte) 0; value = (byte) 0;
type = "byte"; type = "byte";
...@@ -33,7 +33,7 @@ public class PrimitiveTypeDescription extends TypeDescription { ...@@ -33,7 +33,7 @@ public class PrimitiveTypeDescription extends TypeDescription {
type = "double"; type = "double";
break; break;
case "java.lang.Character": case "java.lang.Character":
value = (char)0; value = (char) 0;
type = "char"; type = "char";
break; break;
case "java.lang.Boolean": case "java.lang.Boolean":
...@@ -43,9 +43,10 @@ public class PrimitiveTypeDescription extends TypeDescription { ...@@ -43,9 +43,10 @@ public class PrimitiveTypeDescription extends TypeDescription {
} }
} }
public PrimitiveTypeDescription(ResolvedPrimitiveType resolvedPrimitiveType){
public PrimitiveTypeDescription(ResolvedPrimitiveType resolvedPrimitiveType) {
type = resolvedPrimitiveType.describe(); type = resolvedPrimitiveType.describe();
switch (resolvedPrimitiveType){ switch (resolvedPrimitiveType) {
case BYTE: case BYTE:
value = (byte) 0; value = (byte) 0;
break; break;
...@@ -65,7 +66,7 @@ public class PrimitiveTypeDescription extends TypeDescription { ...@@ -65,7 +66,7 @@ public class PrimitiveTypeDescription extends TypeDescription {
value = 0d; value = 0d;
break; break;
case CHAR: case CHAR:
value = (char)0; value = (char) 0;
break; break;
case BOOLEAN: case BOOLEAN:
value = false; value = false;
......
package com.apidoc.core.common.description; package kim.apidoc.core.common.description;
public class StringTypeDescription extends TypeDescription { public class StringTypeDescription extends TypeDescription {
...@@ -7,7 +7,8 @@ public class StringTypeDescription extends TypeDescription { ...@@ -7,7 +7,8 @@ public class StringTypeDescription extends TypeDescription {
value = charSequence.toString(); value = charSequence.toString();
} }
public String getValue(){ @Override
return (String)value; public String getValue() {
return (String) value;
} }
} }
package com.apidoc.core.common.description; package kim.apidoc.core.common.description;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.StringHelper;
import com.apidoc.core.schema.Row; import kim.apidoc.core.schema.Row;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -61,36 +61,36 @@ public abstract class TypeDescription { ...@@ -61,36 +61,36 @@ public abstract class TypeDescription {
return (ObjectTypeDescription) this; return (ObjectTypeDescription) this;
} }
public void addRemark(String value){ public void addRemark(String value) {
if(value==null){ if (value == null) {
return; return;
} }
if(remark==null){ if (remark == null) {
remark = value; remark = value;
}else{ } else {
remark += " " + value; remark += " " + value;
} }
} }
public String fullKey(){ public String fullKey() {
return StringHelper.join(".",prefix,key); return StringHelper.join(".", prefix, key);
} }
public Collection<Row> rows() { public Collection<Row> rows() {
String key = fullKey(); String key = fullKey();
if(StringHelper.isBlank(key)){ if (StringHelper.isBlank(key)) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
String def; String def;
if(defaultValue!=null){ if (defaultValue != null) {
def = String.valueOf(defaultValue); def = String.valueOf(defaultValue);
}else if(value!=null){ } else if (value != null) {
def = String.valueOf(value); def = String.valueOf(value);
}else{ } else {
def = ""; def = "";
} }
if(required!=null){ if (required != null) {
condition.append("required=").append(required); condition.append("required=").append(required);
} }
......
package com.apidoc.core.common.description; package kim.apidoc.core.common.description;
import com.apidoc.core.schema.Row; import kim.apidoc.core.schema.Row;
import java.util.Collection; import java.util.Collection;
......
package com.apidoc.core.common.diff; package kim.apidoc.core.common.diff;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import lombok.Getter; import lombok.Getter;
...@@ -42,7 +42,7 @@ public class FileMatcher { ...@@ -42,7 +42,7 @@ public class FileMatcher {
return changs; return changs;
} }
public void rederHtml(Path templateHtml, Path resultHtml) { public void renderHtml(Path templateHtml, Path resultHtml) {
String results = matchPatcher.diff_prettyHtml(diffs); String results = matchPatcher.diff_prettyHtml(diffs);
String[] lines = br(results).replaceAll("<span>|</span>", "").split("\n"); String[] lines = br(results).replaceAll("<span>|</span>", "").split("\n");
String html = readFile(templateHtml); String html = readFile(templateHtml);
......
package com.apidoc.core.common.diff; package kim.apidoc.core.common.diff;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
...@@ -9,7 +9,7 @@ import java.nio.file.Path; ...@@ -9,7 +9,7 @@ import java.nio.file.Path;
public class FileSystem { public class FileSystem {
public static boolean open(Path path) { public static boolean open(Path path) {
if(!Files.exists(path)){ if (!Files.exists(path)) {
return false; return false;
} }
if (cmd(path.toString())) { if (cmd(path.toString())) {
...@@ -25,8 +25,8 @@ public class FileSystem { ...@@ -25,8 +25,8 @@ public class FileSystem {
private static boolean cmd(String command, String args) { private static boolean cmd(String command, String args) {
try { try {
Process p = Runtime.getRuntime().exec(new String[]{command,args}); Process p = Runtime.getRuntime().exec(new String[]{command, args});
return p!=null; return p != null;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -45,6 +45,14 @@ public class FileSystem { ...@@ -45,6 +45,14 @@ public class FileSystem {
return false; 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 { public enum OS {
mac("open"), mac("open"),
win("explorer"); win("explorer");
...@@ -55,17 +63,9 @@ public class FileSystem { ...@@ -55,17 +63,9 @@ public class FileSystem {
this.command = command; this.command = command;
} }
public String getCommand(){ public String getCommand() {
return command; return command;
} }
} }
private static OS currentOS() {
String s = System.getProperty("os.name").toLowerCase();
if (s.contains("win")) {
return OS.win;
}
return OS.mac;
}
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.apidoc.core.common.diff; package kim.apidoc.core.common.diff;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.expr.*; import com.github.javaparser.ast.expr.*;
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.FieldDeclaration;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.FieldDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.MethodDeclaration;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node; import com.github.javaparser.ast.Node;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.expr.*; import com.github.javaparser.ast.expr.*;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration; import com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.FieldDeclaration;
import com.github.javaparser.ast.expr.AnnotationExpr; import com.github.javaparser.ast.expr.AnnotationExpr;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import java.util.Optional; import java.util.Optional;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.ImportDeclaration; import com.github.javaparser.ast.ImportDeclaration;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration; import com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration;
import com.github.javaparser.resolution.types.ResolvedReferenceType; import com.github.javaparser.resolution.types.ResolvedReferenceType;
......
package com.apidoc.core.common.helper; package kim.apidoc.core.common.helper;
import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.FieldDeclaration;
import com.github.javaparser.ast.expr.AnnotationExpr; import com.github.javaparser.ast.expr.AnnotationExpr;
......
package com.apidoc.core.common.markup; package kim.apidoc.core.common.markup;
import com.apidoc.core.common.markup.asciidoc.AsciiDocBuilder; import kim.apidoc.core.common.markup.asciidoc.AsciiDocBuilder;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
......
package com.apidoc.core.common.markup.asciidoc; package kim.apidoc.core.common.markup.asciidoc;
public enum AsciiDoc implements CharSequence { public enum AsciiDoc implements CharSequence {
EXTENSION(".adoc"), EXTENSION(".adoc"),
......
package com.apidoc.core.common.markup.asciidoc; package kim.apidoc.core.common.markup.asciidoc;
import com.apidoc.core.common.Assert; import kim.apidoc.core.common.Assert;
import com.apidoc.core.common.markup.MarkupBuilder; import kim.apidoc.core.common.markup.MarkupBuilder;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import java.util.List; import java.util.List;
......
package com.apidoc.core.common.markup.asciidoc; package kim.apidoc.core.common.markup.asciidoc;
/** /**
* https://en.wikipedia.org/wiki/Web_colors#HTML_color_names * https://en.wikipedia.org/wiki/Web_colors#HTML_color_names
......
package com.apidoc.core.common.markup.markdown; package kim.apidoc.core.common.markup.markdown;
public enum Markdown implements CharSequence { public enum Markdown implements CharSequence {
EXTENSION(".md"), EXTENSION(".md"),
......
package com.apidoc.core.common.markup.markdown; package kim.apidoc.core.common.markup.markdown;
import com.apidoc.core.common.Assert; import kim.apidoc.core.common.Assert;
import com.apidoc.core.common.markup.MarkupBuilder; import kim.apidoc.core.common.markup.MarkupBuilder;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import static com.apidoc.core.common.markup.markdown.Markdown.*;
public class MarkdownBuilder implements MarkupBuilder { public class MarkdownBuilder implements MarkupBuilder {
public static final int MAX_TITLE = 6; public static final int MAX_TITLE = 6;
...@@ -19,7 +17,7 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -19,7 +17,7 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override @Override
public MarkupBuilder header(String text, CharSequence... attrs) { public MarkupBuilder header(String text, CharSequence... attrs) {
Assert.notBlank(text, "header must not be blank"); Assert.notBlank(text, "header must not be blank");
content.append(HEADER); content.append(Markdown.HEADER);
content.append(nobr(text.trim())); content.append(nobr(text.trim()));
br(); br();
return this; return this;
...@@ -30,7 +28,7 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -30,7 +28,7 @@ public class MarkdownBuilder implements MarkupBuilder {
Assert.notBlank(text, "header must not be blank"); Assert.notBlank(text, "header must not be blank");
Assert.between(level, 1, MAX_TITLE, "title level can not be " + level); Assert.between(level, 1, MAX_TITLE, "title level can not be " + level);
br(); 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())); .append(nobr(text.trim()));
br(); br();
return this; return this;
...@@ -67,35 +65,35 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -67,35 +65,35 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override @Override
public MarkupBuilder note(String text) { public MarkupBuilder note(String text) {
content.append(QUOTE); content.append(Markdown.QUOTE);
paragraph(text); paragraph(text);
return this; return this;
} }
@Override @Override
public MarkupBuilder tip(String text) { public MarkupBuilder tip(String text) {
content.append(QUOTE); content.append(Markdown.QUOTE);
paragraph(text); paragraph(text);
return this; return this;
} }
@Override @Override
public MarkupBuilder important(String text) { public MarkupBuilder important(String text) {
content.append(QUOTE); content.append(Markdown.QUOTE);
paragraph(text); paragraph(text);
return this; return this;
} }
@Override @Override
public MarkupBuilder warning(String text) { public MarkupBuilder warning(String text) {
content.append(QUOTE); content.append(Markdown.QUOTE);
paragraph(text); paragraph(text);
return this; return this;
} }
@Override @Override
public MarkupBuilder caution(String text) { public MarkupBuilder caution(String text) {
content.append(QUOTE); content.append(Markdown.QUOTE);
paragraph(text); paragraph(text);
return this; return this;
} }
...@@ -114,42 +112,42 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -114,42 +112,42 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override @Override
public MarkupBuilder listing(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder listing(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder literal(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder literal(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder sidebar(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder sidebar(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder comment(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder comment(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder passthrough(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder passthrough(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder quote(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder quote(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder example(Consumer<MarkupBuilder> consumer, CharSequence... attrs) { public MarkupBuilder example(Consumer<MarkupBuilder> consumer, CharSequence... attrs) {
return block(consumer, LISTING, attrs); return block(consumer, Markdown.LISTING, attrs);
} }
@Override @Override
public MarkupBuilder list(String text) { public MarkupBuilder list(String text) {
return list(text, LIST_FLAG); return list(text, Markdown.LIST_FLAG);
} }
@Override @Override
...@@ -187,28 +185,28 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -187,28 +185,28 @@ public class MarkdownBuilder implements MarkupBuilder {
public MarkupBuilder table(List<List<String>> data, boolean header, boolean footer) { public MarkupBuilder table(List<List<String>> data, boolean header, boolean footer) {
for (int i = 0; i < data.size(); i++) { 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++) { for (int j = 0; j < data.get(i).size(); j++) {
String value = data.get(i).get(j); String value = data.get(i).get(j);
if(value!=null){ 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{ }else{
content.append(" "); content.append(" ");
} }
content.append(TABLE_CELL); content.append(Markdown.TABLE_CELL);
} }
br(); br();
if(i==0 && header){ if(i==0 && header){
content.append(TABLE_CELL); content.append(Markdown.TABLE_CELL);
for (int j = 0; j < data.get(i).size(); j++) { for (int j = 0; j < data.get(i).size(); j++) {
content.append(TABLE_Header); content.append(Markdown.TABLE_Header);
} }
br(); br();
} }
if(i==data.size()-2 && footer){ 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++) { for (int j = 0; j < data.get(i).size(); j++) {
content.append(TABLE_Header); content.append(Markdown.TABLE_Header);
} }
br(); br();
} }
...@@ -231,55 +229,55 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -231,55 +229,55 @@ public class MarkdownBuilder implements MarkupBuilder {
@Override @Override
public MarkupBuilder emphasized(String text, CharSequence... textStyle) { public MarkupBuilder emphasized(String text, CharSequence... textStyle) {
return style(EMPHASIZED, text, textStyle); return style(Markdown.EMPHASIZED, text, textStyle);
} }
@Override @Override
public MarkupBuilder strong(String text, CharSequence... textStyle) { public MarkupBuilder strong(String text, CharSequence... textStyle) {
return style(STRONG, text, textStyle); return style(Markdown.STRONG, text, textStyle);
} }
@Override @Override
public MarkupBuilder monospaced(String text, CharSequence... textStyle) { public MarkupBuilder monospaced(String text, CharSequence... textStyle) {
return style(MONOSPACED, text, textStyle); return style(Markdown.MONOSPACED, text, textStyle);
} }
@Override @Override
public MarkupBuilder quoted(String text, CharSequence... textStyle) { public MarkupBuilder quoted(String text, CharSequence... textStyle) {
return style(QUOTE, text, textStyle); return style(Markdown.QUOTE, text, textStyle);
} }
@Override @Override
public MarkupBuilder doubleQuoted(String text, CharSequence... textStyle) { public MarkupBuilder doubleQuoted(String text, CharSequence... textStyle) {
return style(DOUBLE_QUOTED, text, textStyle); return style(Markdown.DOUBLE_QUOTED, text, textStyle);
} }
@Override @Override
public MarkupBuilder unquoted(String text, CharSequence... textStyle) { public MarkupBuilder unquoted(String text, CharSequence... textStyle) {
return style(UNQUOTED, text, textStyle); return style(Markdown.UNQUOTED, text, textStyle);
} }
@Override @Override
public MarkupBuilder br() { public MarkupBuilder br() {
content.append(BR); content.append(Markdown.BR);
return this; return this;
} }
@Override @Override
public MarkupBuilder hbr() { public MarkupBuilder hbr() {
content.append(HBR); content.append(Markdown.HBR);
return this; return this;
} }
@Override @Override
public MarkupBuilder newLine() { public MarkupBuilder newLine() {
content.append(NEW_LINE); content.append(Markdown.NEW_LINE);
return this; return this;
} }
@Override @Override
public MarkupBuilder pageBreak() { public MarkupBuilder pageBreak() {
content.append(PAGEBREAKS); content.append(Markdown.PAGEBREAKS);
br(); br();
return this; return this;
} }
...@@ -298,8 +296,8 @@ public class MarkdownBuilder implements MarkupBuilder { ...@@ -298,8 +296,8 @@ public class MarkdownBuilder implements MarkupBuilder {
if (Assert.isBlank(content)) { if (Assert.isBlank(content)) {
return content; return content;
} }
return content.replaceAll(BR.toString(), return content.replaceAll(Markdown.BR.toString(),
Matcher.quoteReplacement(WHITESPACE.toString())); Matcher.quoteReplacement(Markdown.WHITESPACE.toString()));
} }
} }
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
/** /**
* 对应postman定义的mode * 对应postman定义的mode
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter; import lombok.Getter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import com.apidoc.core.schema.Row; import kim.apidoc.core.schema.Row;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import com.apidoc.core.schema.Header; import kim.apidoc.core.schema.Header;
import com.apidoc.core.schema.Method; import kim.apidoc.core.schema.Method;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import com.apidoc.core.schema.Header; import kim.apidoc.core.schema.Header;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.common.postman; package kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apidoc.core.parser; package kim.apidoc.core.parser;
import com.apidoc.core.schema.Chapter; import kim.apidoc.core.schema.Chapter;
import com.apidoc.core.schema.Section; import kim.apidoc.core.schema.Section;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.MethodDeclaration;
......
package com.apidoc.core.parser; package kim.apidoc.core.parser;
import com.apidoc.core.common.helper.OptionalHelper; import kim.apidoc.core.common.helper.OptionalHelper;
import com.apidoc.core.schema.Chapter; import kim.apidoc.core.schema.Chapter;
import com.apidoc.core.schema.Node; import kim.apidoc.core.schema.Node;
import com.apidoc.core.schema.Project; import kim.apidoc.core.schema.Project;
import com.apidoc.core.schema.Section; import kim.apidoc.core.schema.Section;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter; import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
......
package com.apidoc.core.render; package kim.apidoc.core.render;
import com.apidoc.core.ApiDoc; import kim.apidoc.core.ApiDoc;
import com.apidoc.core.common.helper.FileHelper; import kim.apidoc.core.common.helper.FileHelper;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.StringHelper;
import com.apidoc.core.common.markup.MarkupBuilder; import kim.apidoc.core.common.markup.MarkupBuilder;
import com.apidoc.core.common.markup.asciidoc.AsciiDoc; import kim.apidoc.core.common.markup.asciidoc.AsciiDoc;
import com.apidoc.core.schema.*;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import kim.apidoc.core.schema.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.asciidoctor.Asciidoctor; import org.asciidoctor.Asciidoctor;
import org.asciidoctor.AttributesBuilder; import org.asciidoctor.AttributesBuilder;
......
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) {
}
}
package com.apidoc.core.render; package kim.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 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 lombok.extern.slf4j.Slf4j;
import java.nio.file.Path; import java.nio.file.Path;
......
package com.apidoc.core.render; package kim.apidoc.core.render;
import com.apidoc.core.schema.Project; import kim.apidoc.core.schema.Project;
/** /**
* The interface Project render. * The interface Project render.
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.ApiDoc; import kim.apidoc.core.ApiDoc;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.ArrayTypeDescription; import kim.apidoc.core.common.description.ArrayTypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
public class ArrayTypeResolver implements TypeResolver { public class ArrayTypeResolver implements TypeResolver {
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.ApiDoc; import kim.apidoc.core.ApiDoc;
import com.apidoc.core.common.helper.TypeParameterHelper; import kim.apidoc.core.common.helper.TypeParameterHelper;
import com.apidoc.core.common.description.ArrayTypeDescription; import kim.apidoc.core.common.description.ArrayTypeDescription;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.UnAvailableTypeDescription; import kim.apidoc.core.common.description.UnAvailableTypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.StringTypeDescription; import kim.apidoc.core.common.description.StringTypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.StringTypeDescription; import kim.apidoc.core.common.description.StringTypeDescription;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.github.javaparser.resolution.declarations.ResolvedEnumConstantDeclaration; import com.github.javaparser.resolution.declarations.ResolvedEnumConstantDeclaration;
import com.github.javaparser.resolution.declarations.ResolvedEnumDeclaration; import com.github.javaparser.resolution.declarations.ResolvedEnumDeclaration;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.UnAvailableTypeDescription; import kim.apidoc.core.common.description.UnAvailableTypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
...@@ -9,24 +9,14 @@ import com.google.common.collect.ImmutableList; ...@@ -9,24 +9,14 @@ import com.google.common.collect.ImmutableList;
* 不支持直接使用Map,建议使用DTO * 不支持直接使用Map,建议使用DTO
*/ */
public class MapTypeResolver implements TypeResolver { public class MapTypeResolver implements TypeResolver {
@Override private static boolean isMap(ResolvedType type) {
public boolean accept(ResolvedType type) { if (!type.isReferenceType()) {
return isMap(type);
}
@Override
public TypeDescription resolve(ResolvedType type) {
return new UnAvailableTypeDescription();
}
private static boolean isMap(ResolvedType type){
if(!type.isReferenceType()){
return false; return false;
} }
return isMap(type.asReferenceType().getId()); return isMap(type.asReferenceType().getId());
} }
private static boolean isMap(String id){ private static boolean isMap(String id) {
return ImmutableList.of("java.util.Map", return ImmutableList.of("java.util.Map",
"java.util.HashMap", "java.util.HashMap",
"java.util.Hashtable", "java.util.Hashtable",
...@@ -35,4 +25,14 @@ public class MapTypeResolver implements TypeResolver { ...@@ -35,4 +25,14 @@ public class MapTypeResolver implements TypeResolver {
"java.lang.TreeMap" "java.lang.TreeMap"
).contains(id); ).contains(id);
} }
@Override
public boolean accept(ResolvedType type) {
return isMap(type);
}
@Override
public TypeDescription resolve(ResolvedType type) {
return new UnAvailableTypeDescription();
}
} }
package com.apidoc.core.resolver; package kim.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.declarations.ResolvedFieldDeclaration;
import com.github.javaparser.resolution.types.ResolvedReferenceType; import com.github.javaparser.resolution.types.ResolvedReferenceType;
import com.github.javaparser.resolution.types.ResolvedType; 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; import java.util.Optional;
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.PrimitiveTypeDescription; import kim.apidoc.core.common.description.PrimitiveTypeDescription;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.StringTypeDescription; import kim.apidoc.core.common.description.StringTypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.UnAvailableTypeDescription; import kim.apidoc.core.common.description.UnAvailableTypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
public class SystemObjectTypeResolver implements TypeResolver { public class SystemObjectTypeResolver implements TypeResolver {
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.github.javaparser.ast.type.Type; import com.github.javaparser.ast.type.Type;
public interface TypeNameResolver { public interface TypeNameResolver {
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
public interface TypeResolver { public interface TypeResolver {
......
package com.apidoc.core.resolver; package kim.apidoc.core.resolver;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.helper.TypeNameHelper; import kim.apidoc.core.common.helper.TypeNameHelper;
import com.apidoc.core.common.description.UnAvailableTypeDescription; import kim.apidoc.core.common.description.UnAvailableTypeDescription;
import com.github.javaparser.ast.type.Type; import com.github.javaparser.ast.type.Type;
import com.github.javaparser.resolution.UnsolvedSymbolException; import com.github.javaparser.resolution.UnsolvedSymbolException;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
......
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -6,14 +6,31 @@ import lombok.Setter; ...@@ -6,14 +6,31 @@ import lombok.Setter;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
/**
* The type Book.
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Setter @Setter
@Getter @Getter
public class Book extends Node { public class Book extends Node {
/**
* The constant DEFAULT.
*/
public static final String DEFAULT = "index"; public static final String DEFAULT = "index";
/**
* 章
*/
Set<Chapter> chapters = new TreeSet<>(); Set<Chapter> chapters = new TreeSet<>();
/**
* Instantiates a new Book.
*
* @param id the id
*/
public Book(String id) { public Book(String id) {
this.id = id; this.id = id;
} }
......
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -8,13 +8,22 @@ import java.util.TreeSet; ...@@ -8,13 +8,22 @@ import java.util.TreeSet;
/** /**
* 章,一个类解析为一章 * 章,一个类解析为一章
*
* @author fengyuchenglun
* @version 1.0.0
*/ */
@Setter @Setter
@Getter @Getter
public class Chapter extends Node { public class Chapter extends Node {
/**
* The Book name.
*/
String bookName; String bookName;
/**
* The Sections.
*/
Set<Section> sections = new TreeSet<>(); Set<Section> sections = new TreeSet<>();
} }
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
/**
* The type Header.
*
* @author fengyuchenglun
* @version 1.0.0
*/
@Setter @Setter
@Getter @Getter
@NoArgsConstructor @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; String key;
/**
* The Value.
*/
String value; String value;
/**
* The Description.
*/
String description; String description;
/**
* Instantiates a new Header.
*
* @param key the key
* @param value the value
*/
public Header(String key, String value) { public Header(String key, String value) {
this.key = key; this.key = key;
this.value = value; 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(":"); String[] arr = text.split(":");
Header header = new Header(); Header header = new Header();
header.setKey(arr[0]); header.setKey(arr[0]);
if(arr.length>1){ if (arr.length > 1) {
header.setValue(arr[1]); header.setValue(arr[1]);
} }
return header; return header;
} }
@Override @Override
public String toString(){ public String toString() {
return key + ": " + value; return key + ": " + value;
} }
......
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);
}
}
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import com.apidoc.core.Context; import kim.apidoc.core.Context;
import com.apidoc.core.common.helper.CommentHelper; import kim.apidoc.core.common.helper.CommentHelper;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.StringHelper;
import com.github.javaparser.ast.comments.Comment; import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.javadoc.Javadoc; import com.github.javaparser.javadoc.Javadoc;
import lombok.Getter; import lombok.Getter;
......
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -31,7 +31,7 @@ public class Project extends Node { ...@@ -31,7 +31,7 @@ public class Project extends Node {
* @param chapter the chapter * @param chapter the chapter
*/ */
public void addChapter(Chapter chapter) { public void addChapter(Chapter chapter) {
if(Objects.isNull(chapter.getBookName())){ if (Objects.isNull(chapter.getBookName())) {
chapter.setBookName(Book.DEFAULT); chapter.setBookName(Book.DEFAULT);
} }
if (!books.containsKey(chapter.getBookName())) { if (!books.containsKey(chapter.getBookName())) {
......
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import lombok.*; import lombok.*;
/**
* The type Row.
*
* @author fengyuchenglun
* @version 1.0.0
*/
@EqualsAndHashCode @EqualsAndHashCode
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
...@@ -9,12 +15,32 @@ import lombok.*; ...@@ -9,12 +15,32 @@ import lombok.*;
@Getter @Getter
public class Row { public class Row {
/**
* The Key.
*/
String key; String key;
/**
* The Type.
*/
String type; String type;
/**
* The Condition.
*/
String condition; String condition;
/**
* The Def.
*/
String def; String def;
/**
* The Remark.
*/
String remark; String remark;
/**
* Instantiates a new Row.
*
* @param type the type
*/
public Row(String type) { public Row(String type) {
this.type = type; this.type = type;
} }
......
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import com.apidoc.core.common.ObjectMappers; import kim.apidoc.core.common.ObjectMappers;
import com.apidoc.core.common.QueryStringBuilder; import kim.apidoc.core.common.QueryStringBuilder;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.StringHelper;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Getter; import lombok.Getter;
...@@ -12,42 +12,93 @@ import java.util.*; ...@@ -12,42 +12,93 @@ import java.util.*;
/** /**
* 小节,一个请求,封装为一个小节 * 小节,一个请求,封装为一个小节
*
* @author fengyuchenglun
* @version 1.0.0
*/ */
@Setter @Setter
@Getter @Getter
public class Section extends Node { public class Section extends Node {
/**
* The Method.
*/
Method method; Method method;
/**
* The Uri.
*/
String 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(); ObjectNode pathVariable = ObjectMappers.instance.createObjectNode();
/**
* The Parameter.
*/
JsonNode parameter; JsonNode parameter;
/**
* The Query parameter.
*/
boolean queryParameter = true; boolean queryParameter = true;
Map<String,Row> requestRows = new LinkedHashMap<>(); /**
* The Request rows.
Map<String,Header> outHeaders = new LinkedHashMap<>(); */
Map<String, Row> requestRows = new LinkedHashMap<>();
/**
* The Out headers.
*/
Map<String, Header> outHeaders = new LinkedHashMap<>();
/**
* The Response.
*/
JsonNode response; JsonNode response;
Map<String,Row> responseRows = new LinkedHashMap<>(); /**
* The Response rows.
*/
Map<String, Row> responseRows = new LinkedHashMap<>();
/**
* The Raw response.
*/
Object rawResponse; Object rawResponse;
public void addRequestRow(Row row){ /**
* Add request row.
*
* @param row the row
*/
public void addRequestRow(Row row) {
requestRows.put(row.getKey(), 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) { for (Row row : rows) {
if(row.getKey()!=null && !requestRows.containsKey(row.getKey())){ if (row.getKey() != null && !requestRows.containsKey(row.getKey())) {
requestRows.put(row.getKey(),row); 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()); StringBuilder builder = new StringBuilder(this.method.toString());
builder.append(" ").append(this.uri); builder.append(" ").append(this.uri);
if(this.queryParameter && Objects.equals("GET", this.method)){ if (this.queryParameter && Objects.equals("GET", this.method)) {
String parameterString = getParameterString(); String parameterString = getParameterString();
if(StringHelper.nonBlank(parameterString)){ if (StringHelper.nonBlank(parameterString)) {
builder.append("?").append(parameterString); builder.append("?").append(parameterString);
} }
} }
...@@ -55,52 +106,92 @@ public class Section extends Node { ...@@ -55,52 +106,92 @@ public class Section extends Node {
return builder.toString(); return builder.toString();
} }
public String getParameterString(){ /**
if(queryParameter && parameter instanceof ObjectNode){ * Get parameter string string.
return new QueryStringBuilder().append((ObjectNode)parameter).toString(); *
* @return the string
*/
public String getParameterString() {
if (queryParameter && parameter instanceof ObjectNode) {
return new QueryStringBuilder().append((ObjectNode) parameter).toString();
} }
return ObjectMappers.pretty(parameter); 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 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); 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) { 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); 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 ObjectMappers.pretty(response);
} }
return String.valueOf(rawResponse); 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())) { 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())) { if (!outHeaders.containsKey(header.getKey())) {
outHeaders.put(header.getKey(),header); outHeaders.put(header.getKey(), header);
} }
} }
......
package com.apidoc.core.schema; package kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -8,23 +8,41 @@ import java.util.Objects; ...@@ -8,23 +8,41 @@ import java.util.Objects;
/** /**
* //@param username 用户名 * //@param username 用户名
* id key content * id key content
*
* @author fengyuchenglun
* @version 1.0.0
*/ */
@Slf4j @Slf4j
@Setter @Setter
@Getter @Getter
public class Tag { public class Tag {
/**
* The Id.
*/
String id; String id;
/**
* The Key.
*/
String key; String key;
/**
* The Content.
*/
String 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)) { if (Objects.nonNull(content)) {
try{ try {
return Integer.parseInt(content); return Integer.parseInt(content);
}catch (Exception e){ } catch (Exception e) {
log.warn(content+" parse error"); log.warn(content + " parse error");
} }
} }
return def; return def;
......
package com.apigcc.springmvc; package com.kim.apidoc.springmvc;
import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.Parameter; import com.github.javaparser.ast.body.Parameter;
......
package com.apigcc.springmvc; package com.kim.apidoc.springmvc;
import com.apidoc.core.common.URI; import kim.apidoc.core.common.URI;
import com.apidoc.core.common.helper.AnnotationHelper; import kim.apidoc.core.common.helper.AnnotationHelper;
import com.apidoc.core.common.helper.ClassDeclarationHelper; import kim.apidoc.core.common.helper.ClassDeclarationHelper;
import com.apidoc.core.common.helper.ExpressionHelper; import kim.apidoc.core.common.helper.ExpressionHelper;
import com.apidoc.core.schema.Method; import kim.apidoc.core.schema.Method;
import com.github.javaparser.ast.Node; import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
......
package com.apigcc.springmvc; package com.kim.apidoc.springmvc;
import com.apidoc.core.ApiDoc; import kim.apidoc.core.ApiDoc;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Data; import lombok.Data;
......
package com.apigcc.springmvc; package com.kim.apidoc.springmvc;
import com.apidoc.core.ApiDoc; import com.kim.apidoc.springmvc.resovler.SpringComponentTypeResolver;
import com.apidoc.core.common.URI; import kim.apidoc.core.ApiDoc;
import com.apidoc.core.common.description.ObjectTypeDescription; import kim.apidoc.core.common.URI;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.ObjectTypeDescription;
import com.apidoc.core.common.helper.AnnotationHelper; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.helper.ExpressionHelper; import kim.apidoc.core.common.helper.AnnotationHelper;
import com.apidoc.core.common.helper.StringHelper; import kim.apidoc.core.common.helper.ExpressionHelper;
import com.apidoc.core.parser.ParserStrategy; import kim.apidoc.core.common.helper.StringHelper;
import com.apidoc.core.schema.Chapter; import kim.apidoc.core.parser.ParserStrategy;
import com.apidoc.core.schema.Header; import kim.apidoc.core.schema.Chapter;
import com.apidoc.core.schema.Row; import kim.apidoc.core.schema.Header;
import com.apidoc.core.schema.Section; import kim.apidoc.core.schema.Row;
import com.apigcc.springmvc.resovler.SpringComponentTypeResolver; import kim.apidoc.core.schema.Section;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.body.Parameter; import com.github.javaparser.ast.body.Parameter;
...@@ -22,9 +22,6 @@ import com.github.javaparser.ast.expr.Expression; ...@@ -22,9 +22,6 @@ import com.github.javaparser.ast.expr.Expression;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static com.apigcc.springmvc.ParameterHelper.ANNOTATION_REQUEST_HEADER;
import static com.apigcc.springmvc.ParameterHelper.ANNOTATION_REQUEST_PARAM;
/** /**
* spring 解析 * spring 解析
...@@ -196,7 +193,7 @@ public class SpringParser implements ParserStrategy { ...@@ -196,7 +193,7 @@ public class SpringParser implements ParserStrategy {
if (ParameterHelper.isRequestHeader(parameter)) { if (ParameterHelper.isRequestHeader(parameter)) {
String key = parameter.getNameAsString(); String key = parameter.getNameAsString();
String defaultValue = "{value}"; 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"); Optional<Expression> valueOptional = AnnotationHelper.getAnyAttribute(annotationExpr, "value", "name");
if (valueOptional.isPresent()) { if (valueOptional.isPresent()) {
key = String.valueOf(ExpressionHelper.getValue(valueOptional.get())); key = String.valueOf(ExpressionHelper.getValue(valueOptional.get()));
...@@ -260,7 +257,7 @@ public class SpringParser implements ParserStrategy { ...@@ -260,7 +257,7 @@ public class SpringParser implements ParserStrategy {
Object defaultValue = null; Object defaultValue = null;
Boolean required = null; Boolean required = null;
Optional<AnnotationExpr> optional = parameter.getAnnotationByName(ANNOTATION_REQUEST_PARAM); Optional<AnnotationExpr> optional = parameter.getAnnotationByName(ParameterHelper.ANNOTATION_REQUEST_PARAM);
if (optional.isPresent()) { if (optional.isPresent()) {
Optional<Expression> valueOptional = AnnotationHelper.getAnyAttribute(optional.get(), "value", "name"); Optional<Expression> valueOptional = AnnotationHelper.getAnyAttribute(optional.get(), "value", "name");
if (valueOptional.isPresent()) { if (valueOptional.isPresent()) {
......
package com.apigcc.springmvc.resovler; package com.kim.apidoc.springmvc.resovler;
import com.apidoc.core.ApiDoc; import kim.apidoc.core.ApiDoc;
import com.apidoc.core.common.description.TypeDescription; import kim.apidoc.core.common.description.TypeDescription;
import com.apidoc.core.common.description.UnAvailableTypeDescription; import kim.apidoc.core.common.description.UnAvailableTypeDescription;
import com.apidoc.core.common.helper.TypeParameterHelper; import kim.apidoc.core.common.helper.TypeParameterHelper;
import com.apidoc.core.resolver.TypeNameResolver; import kim.apidoc.core.resolver.TypeNameResolver;
import com.apidoc.core.resolver.TypeResolver; import kim.apidoc.core.resolver.TypeResolver;
import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.type.Type; import com.github.javaparser.ast.type.Type;
import com.github.javaparser.resolution.types.ResolvedType; import com.github.javaparser.resolution.types.ResolvedType;
......
com.kim.apidoc.springmvc.SpringParser
\ No newline at end of file
package com.apigcc.example; package com.kim.apidoc.example;
import com.apidoc.core.ApiDoc; import kim.apidoc.core.ApiDoc;
import com.apidoc.core.Context; import kim.apidoc.core.Context;
import org.junit.Test; import org.junit.Test;
import java.nio.file.Paths; import java.nio.file.Paths;
......
package com.apigcc.example.annotation; package com.kim.apidoc.example.annotation;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
......
package com.apigcc.example.annotation; package com.kim.apidoc.example.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
/** /**
* 用户角色 * 用户角色
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
/** /**
* 某些用户信息框架,如spring security的用户登录信息 * 某些用户信息框架,如spring security的用户登录信息
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apigcc.example.common; package com.kim.apidoc.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.apigcc.example.spring; package com.kim.apidoc.example.spring;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
package com.apigcc.example.spring.advanced; package com.kim.apidoc.example.spring.advanced;
import com.apigcc.example.common.ResultData; import com.kim.apidoc.example.common.ResultData;
import com.apigcc.example.spring.BaseController; import com.kim.apidoc.example.spring.BaseController;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
......
package com.apigcc.example.spring.advanced; package com.kim.apidoc.example.spring.advanced;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
......
package com.apigcc.example.spring.advanced; package com.kim.apidoc.example.spring.advanced;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
......
package com.apigcc.example.spring.advanced; package com.kim.apidoc.example.spring.advanced;
import com.apigcc.example.annotation.KimController; import com.kim.apidoc.example.annotation.KimController;
import com.apigcc.example.common.ResultData; import com.kim.apidoc.example.common.ResultData;
import com.apigcc.example.common.User; import com.kim.apidoc.example.common.User;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment