Commit ca53f41f authored by duanledexianxianxian's avatar duanledexianxianxian 😁

代码重构

parent d1cdf8f4
package com.kim.apidoc.core; package com.github.fengyuchenglun.apidoc.core;
import com.kim.apidoc.core.common.helper.StringHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper;
import com.kim.apidoc.core.parser.ParserStrategy; import com.github.fengyuchenglun.apidoc.core.parser.ParserStrategy;
import com.kim.apidoc.core.parser.VisitorParser; import com.github.fengyuchenglun.apidoc.core.parser.VisitorParser;
import com.kim.apidoc.core.render.ProjectRender; import com.github.fengyuchenglun.apidoc.core.render.ProjectRender;
import com.kim.apidoc.core.resolver.TypeResolvers; import com.github.fengyuchenglun.apidoc.core.resolver.TypeResolvers;
import com.kim.apidoc.core.schema.Project; import com.github.fengyuchenglun.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;
......
package com.kim.apidoc.core; package com.github.fengyuchenglun.apidoc.core;
import com.github.fengyuchenglun.apidoc.core.common.Constants;
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 com.kim.apidoc.core.common.helper.FileHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.FileHelper;
import com.kim.apidoc.core.render.MarkdownRender; import com.github.fengyuchenglun.apidoc.core.render.MarkdownRender;
import com.kim.apidoc.core.render.ProjectRender; import com.github.fengyuchenglun.apidoc.core.render.ProjectRender;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -13,8 +14,6 @@ import java.nio.file.Paths; ...@@ -13,8 +14,6 @@ import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.kim.apidoc.core.common.Constants.MARKDOWN_TEMPLATE;
/** /**
* The type Context. * The type Context.
* *
...@@ -109,7 +108,7 @@ public class Context { ...@@ -109,7 +108,7 @@ public class Context {
* markdown模版文件路径 * markdown模版文件路径
*/ */
@Setter @Setter
private String markdownTemplate = MARKDOWN_TEMPLATE; private String markdownTemplate = Constants.MARKDOWN_TEMPLATE;
/** /**
* 自定义扩展参数 * 自定义扩展参数
......
package com.kim.apidoc.core.common; package com.github.fengyuchenglun.apidoc.core.common;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
package com.kim.apidoc.core.common; package com.github.fengyuchenglun.apidoc.core.common;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
......
package com.kim.apidoc.core.common; package com.github.fengyuchenglun.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.kim.apidoc.core.common; package com.github.fengyuchenglun.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.kim.apidoc.core.common; package com.github.fengyuchenglun.apidoc.core.common;
import com.kim.apidoc.core.common.helper.StringHelper; import com.github.fengyuchenglun.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.kim.apidoc.core.common.description; package com.github.fengyuchenglun.apidoc.core.common.description;
import com.kim.apidoc.core.schema.Row; import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers;
import com.kim.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.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;
......
package com.kim.apidoc.core.common.description; package com.github.fengyuchenglun.apidoc.core.common.description;
import com.kim.apidoc.core.schema.Row; import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers;
import com.kim.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.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;
......
package com.kim.apidoc.core.common.description; package com.github.fengyuchenglun.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;
......
package com.kim.apidoc.core.common.description; package com.github.fengyuchenglun.apidoc.core.common.description;
/** /**
* 字符串类型 * 字符串类型
......
package com.kim.apidoc.core.common.description; package com.github.fengyuchenglun.apidoc.core.common.description;
import com.github.fengyuchenglun.apidoc.core.common.helper.CommentHelper;
import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper;
import com.github.fengyuchenglun.apidoc.core.schema.Row;
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 com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.kim.apidoc.core.common.helper.CommentHelper;
import com.kim.apidoc.core.common.helper.StringHelper;
import com.kim.apidoc.core.schema.Row;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.description; package com.github.fengyuchenglun.apidoc.core.common.description;
import com.kim.apidoc.core.schema.Row; import com.github.fengyuchenglun.apidoc.core.schema.Row;
import java.util.Collection; import java.util.Collection;
......
package com.kim.apidoc.core.common.diff; package com.github.fengyuchenglun.apidoc.core.common.diff;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import lombok.Getter; import lombok.Getter;
......
package com.kim.apidoc.core.common.diff; package com.github.fengyuchenglun.apidoc.core.common.diff;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
......
...@@ -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.kim.apidoc.core.common.diff; package com.github.fengyuchenglun.apidoc.core.common.diff;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.apidoc.core.common.helper;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.type.ClassOrInterfaceType; import com.github.javaparser.ast.type.ClassOrInterfaceType;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.apidoc.core.common.helper;
import com.github.fengyuchenglun.apidoc.core.schema.Cell;
import com.github.javaparser.ast.body.EnumConstantDeclaration; import com.github.javaparser.ast.body.EnumConstantDeclaration;
import com.github.javaparser.ast.body.EnumDeclaration; import com.github.javaparser.ast.body.EnumDeclaration;
import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.Expression;
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.kim.apidoc.core.schema.Cell;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.apidoc.core.common.helper;
import com.github.fengyuchenglun.apidoc.core.schema.Cell;
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;
import com.github.javaparser.ast.body.VariableDeclarator; import com.github.javaparser.ast.body.VariableDeclarator;
import com.github.javaparser.ast.comments.Comment;
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;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserFieldDeclaration; import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserFieldDeclaration;
import com.kim.apidoc.core.schema.Cell;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.apidoc.core.common.helper;
import java.util.Optional; import java.util.Optional;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.apidoc.core.common.helper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.apidoc.core.common.helper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
package com.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.helper; package com.github.fengyuchenglun.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.kim.apidoc.core.common.markup; package com.github.fengyuchenglun.apidoc.core.common.markup;
import com.kim.apidoc.core.common.markup.asciidoc.AsciiDocBuilder; import com.github.fengyuchenglun.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.kim.apidoc.core.common.markup.asciidoc; package com.github.fengyuchenglun.apidoc.core.common.markup.asciidoc;
public enum AsciiDoc implements CharSequence { public enum AsciiDoc implements CharSequence {
EXTENSION(".adoc"), EXTENSION(".adoc"),
......
package com.kim.apidoc.core.common.markup.asciidoc; package com.github.fengyuchenglun.apidoc.core.common.markup.asciidoc;
import com.kim.apidoc.core.common.markup.MarkupBuilder; import com.github.fengyuchenglun.apidoc.core.common.Assert;
import com.kim.apidoc.core.common.Assert; import com.github.fengyuchenglun.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.kim.apidoc.core.common.markup.asciidoc; package com.github.fengyuchenglun.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.kim.apidoc.core.common.markup.markdown; package com.github.fengyuchenglun.apidoc.core.common.markup.markdown;
public enum Markdown implements CharSequence { public enum Markdown implements CharSequence {
EXTENSION(".md"), EXTENSION(".md"),
......
package com.kim.apidoc.core.common.markup.markdown; package com.github.fengyuchenglun.apidoc.core.common.markup.markdown;
import com.kim.apidoc.core.common.markup.MarkupBuilder; import com.github.fengyuchenglun.apidoc.core.common.Assert;
import com.kim.apidoc.core.common.Assert; import com.github.fengyuchenglun.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.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
/** /**
* 对应postman定义的mode * 对应postman定义的mode
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter; import lombok.Getter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import com.kim.apidoc.core.schema.Row; import com.github.fengyuchenglun.apidoc.core.schema.Row;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import com.kim.apidoc.core.schema.Header; import com.github.fengyuchenglun.apidoc.core.schema.Header;
import com.kim.apidoc.core.schema.Method; import com.github.fengyuchenglun.apidoc.core.schema.Method;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import com.kim.apidoc.core.schema.Header; import com.github.fengyuchenglun.apidoc.core.schema.Header;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.common.postman; package com.github.fengyuchenglun.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.parser; package com.github.fengyuchenglun.apidoc.core.parser;
import com.kim.apidoc.core.schema.Chapter; import com.github.fengyuchenglun.apidoc.core.schema.Chapter;
import com.kim.apidoc.core.schema.Section; import com.github.fengyuchenglun.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.kim.apidoc.core.parser; package com.github.fengyuchenglun.apidoc.core.parser;
import com.github.fengyuchenglun.apidoc.core.schema.*;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.EnumDeclaration; import com.github.javaparser.ast.body.EnumDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.comments.JavadocComment; import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter; import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.helper.OptionalHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.OptionalHelper;
import com.kim.apidoc.core.schema.*;
/** /**
......
package com.kim.apidoc.core.render; package com.github.fengyuchenglun.apidoc.core.render;
import com.github.fengyuchenglun.apidoc.core.schema.*;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.helper.FileHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.FileHelper;
import com.kim.apidoc.core.common.helper.StringHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper;
import com.kim.apidoc.core.common.markup.MarkupBuilder; import com.github.fengyuchenglun.apidoc.core.common.markup.MarkupBuilder;
import com.kim.apidoc.core.common.markup.asciidoc.AsciiDoc; import com.github.fengyuchenglun.apidoc.core.common.markup.asciidoc.AsciiDoc;
import com.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 com.kim.apidoc.core.render; package com.github.fengyuchenglun.apidoc.core.render;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.common.Constants;
import com.kim.apidoc.core.common.Constants; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.apidoc.core.common.helper.FileHelper;
import com.kim.apidoc.core.common.helper.FileHelper; import com.github.fengyuchenglun.apidoc.core.schema.Project;
import com.kim.apidoc.core.schema.Project;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.nio.file.Path; import java.nio.file.Path;
......
package com.kim.apidoc.core.render; package com.github.fengyuchenglun.apidoc.core.render;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers;
import com.kim.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.apidoc.core.common.postman.*;
import com.kim.apidoc.core.common.helper.FileHelper; import com.github.fengyuchenglun.apidoc.core.schema.*;
import com.kim.apidoc.core.common.postman.*; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.schema.*; import com.github.fengyuchenglun.apidoc.core.common.helper.FileHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.nio.file.Path; import java.nio.file.Path;
......
package com.kim.apidoc.core.render; package com.github.fengyuchenglun.apidoc.core.render;
import com.kim.apidoc.core.schema.Project; import com.github.fengyuchenglun.apidoc.core.schema.Project;
/** /**
* The interface Project render. * The interface Project render.
......
package com.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.ArrayTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.helper.TypeParameterHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.TypeParameterHelper;
import com.kim.apidoc.core.common.description.ArrayTypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.ArrayTypeDescription;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.StringTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.StringTypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.StringTypeDescription;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.github.fengyuchenglun.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 com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration; import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.description.ObjectTypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.ObjectTypeDescription;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.helper.*;
import java.util.Optional; import java.util.Optional;
......
package com.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.PrimitiveTypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.PrimitiveTypeDescription;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.StringTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.resolver; package com.github.fengyuchenglun.apidoc.core.resolver;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.helper.TypeNameHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.TypeNameHelper;
import com.kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.github.fengyuchenglun.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.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import com.github.javaparser.ast.body.BodyDeclaration; import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.comments.JavadocComment; import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName;
import com.kim.apidoc.core.common.helper.EnumHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.EnumHelper;
import com.kim.apidoc.core.common.helper.FieldHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.FieldHelper;
import com.kim.apidoc.core.common.helper.FileHelper;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import com.github.fengyuchenglun.apidoc.core.Context;
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 com.kim.apidoc.core.Context; import com.github.fengyuchenglun.apidoc.core.common.helper.CommentHelper;
import com.kim.apidoc.core.common.helper.CommentHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper;
import com.kim.apidoc.core.common.helper.StringHelper;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import lombok.Getter; import lombok.Getter;
......
package com.github.fengyuchenglun.apidoc.core.schema;
/**
* 请求参数枚举类型
*
* @author duanledexianxianxian
* @date 2020 /3/29 0:37
* @since 1.0.0
*/
public enum RequestParameterType {
/**
* 查询参数.
*/
QUERY("QUERY", "查询参数"),
/**
* 路径参数.
*/
PATH("PATH", "路径参数"),
/**
* 请求参数体.
*/
BODY("BODY", "请求体");
/**
* 编码
*/
private String code;
/**
* 信息
*/
private String msg;
RequestParameterType(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import lombok.*; import lombok.*;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import com.kim.apidoc.core.common.ObjectMappers; import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers;
import com.kim.apidoc.core.common.QueryStringBuilder; import com.github.fengyuchenglun.apidoc.core.common.QueryStringBuilder;
import com.kim.apidoc.core.common.helper.StringHelper; import com.github.fengyuchenglun.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;
......
package com.kim.apidoc.core.schema; package com.github.fengyuchenglun.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.kim.apidoc.core.schema;
/**
* 请求参数枚举类型
*
* @author duanledexianxianxian
* @date 2020 /3/29 0:37
* @since 1.0.0
*/
public enum RequestParameterType {
/**
* 查询参数.
*/
QUERY,
/**
* 路径参数.
*/
PATH,
/**
* 请求参数体.
*/
BODY
}
[TOC] [TOC]
<#-- ---------- BEGIN 循环遍历book ----------> <#-- ---------- BEGIN 循环遍历book ---------->
<#if books??> <#if books??>
<#list books as bookKey,bookValue> <#list books as bookKey,bookValue>
......
package com.kim.apidoc.springmvc; package com.github.fengyuchenglun.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.kim.apidoc.springmvc; package com.github.fengyuchenglun.apidoc.springmvc;
import com.kim.apidoc.core.common.URI; import com.github.fengyuchenglun.apidoc.core.common.URI;
import com.kim.apidoc.core.common.helper.AnnotationHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.AnnotationHelper;
import com.kim.apidoc.core.common.helper.ClassDeclarationHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.ClassDeclarationHelper;
import com.kim.apidoc.core.common.helper.ExpressionHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.ExpressionHelper;
import com.kim.apidoc.core.schema.Method; import com.github.fengyuchenglun.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.kim.apidoc.springmvc; package com.github.fengyuchenglun.apidoc.springmvc;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Data; import lombok.Data;
......
package com.kim.apidoc.springmvc; package com.github.fengyuchenglun.apidoc.springmvc;
import com.github.fengyuchenglun.apidoc.core.common.helper.AnnotationHelper;
import com.github.fengyuchenglun.apidoc.core.common.helper.ClassDeclarationHelper;
import com.github.fengyuchenglun.apidoc.core.common.helper.ExpressionHelper;
import com.github.fengyuchenglun.apidoc.core.common.helper.StringHelper;
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;
import com.github.javaparser.ast.expr.AnnotationExpr; import com.github.javaparser.ast.expr.AnnotationExpr;
import com.github.javaparser.ast.expr.Expression; import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.type.ClassOrInterfaceType; import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.URI; import com.github.fengyuchenglun.apidoc.core.common.URI;
import com.kim.apidoc.core.common.description.ObjectTypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.ObjectTypeDescription;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.helper.*; import com.github.fengyuchenglun.apidoc.core.parser.ParserStrategy;
import com.kim.apidoc.core.parser.ParserStrategy; import com.github.fengyuchenglun.apidoc.core.schema.Chapter;
import com.kim.apidoc.core.schema.Chapter; import com.github.fengyuchenglun.apidoc.core.schema.Header;
import com.kim.apidoc.core.schema.Header; import com.github.fengyuchenglun.apidoc.core.schema.Row;
import com.kim.apidoc.core.schema.Row; import com.github.fengyuchenglun.apidoc.core.schema.Section;
import com.kim.apidoc.core.schema.Section; import com.github.fengyuchenglun.apidoc.springmvc.resovler.SpringComponentTypeResolver;
import com.kim.apidoc.springmvc.resovler.SpringComponentTypeResolver;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static com.kim.apidoc.core.schema.RequestParameterType.*; import static com.github.fengyuchenglun.apidoc.core.schema.RequestParameterType.*;
/** /**
...@@ -157,7 +160,7 @@ public class SpringParser implements ParserStrategy { ...@@ -157,7 +160,7 @@ public class SpringParser implements ParserStrategy {
if (ParameterHelper.isPathVariable(parameter)) { if (ParameterHelper.isPathVariable(parameter)) {
section.getPathVariable().put(parameter.getNameAsString(), ""); section.getPathVariable().put(parameter.getNameAsString(), "");
Row row = new Row(); Row row = new Row();
row.setRequestParameterType(PATH.name()); row.setRequestParameterType(PATH.getMsg());
row.setKey(parameter.getNameAsString()); row.setKey(parameter.getNameAsString());
row.setType(parameter.getType().toString()); row.setType(parameter.getType().toString());
// 路径参数必填 // 路径参数必填
...@@ -236,7 +239,7 @@ public class SpringParser implements ParserStrategy { ...@@ -236,7 +239,7 @@ public class SpringParser implements ParserStrategy {
} else if (description.isObject()) { } else if (description.isObject()) {
section.setParameter(description.asObject().getValue()); section.setParameter(description.asObject().getValue());
} }
section.addRequestRows(description.rows(BODY.name())); section.addRequestRows(description.rows(BODY.getMsg()));
} }
break; break;
} }
...@@ -295,11 +298,11 @@ public class SpringParser implements ParserStrategy { ...@@ -295,11 +298,11 @@ public class SpringParser implements ParserStrategy {
} }
} }
section.setParameter(objectTypeDescription.getValue()); section.setParameter(objectTypeDescription.getValue());
section.addRequestRows(objectTypeDescription.rows(QUERY.name())); section.addRequestRows(objectTypeDescription.rows(QUERY.getMsg()));
} }
/** /**
* 解析方法返回参 * 解析方法返回参数
* *
* @param n the n * @param n the n
* @param chapter the chapter * @param chapter the chapter
......
package com.kim.apidoc.springmvc.resovler; package com.github.fengyuchenglun.apidoc.springmvc.resovler;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.description.TypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.TypeDescription;
import com.kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.github.fengyuchenglun.apidoc.core.common.description.UnAvailableTypeDescription;
import com.kim.apidoc.core.common.helper.TypeParameterHelper; import com.github.fengyuchenglun.apidoc.core.common.helper.TypeParameterHelper;
import com.kim.apidoc.core.resolver.TypeNameResolver; import com.github.fengyuchenglun.apidoc.core.resolver.TypeNameResolver;
import com.kim.apidoc.core.resolver.TypeResolver; import com.github.fengyuchenglun.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.github.fengyuchenglun.apidoc.springmvc.SpringParser
\ No newline at end of file
package com.kim.apidoc.springmvc; package com.github.fengyuchenglun.apidoc.springmvc;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.Context; import com.github.fengyuchenglun.apidoc.core.Context;
import com.kim.apidoc.core.common.diff.FileMatcher; import com.github.fengyuchenglun.apidoc.core.common.diff.FileMatcher;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
...@@ -17,7 +17,7 @@ public class SpringTest { ...@@ -17,7 +17,7 @@ public class SpringTest {
Context context = new Context(); Context context = new Context();
context.setId("test"); context.setId("test");
context.setName("测试项目"); context.setName("测试项目");
context.addSource(Paths.get("K:\\@project-dianli@\\tool\\apidoc\\apidoc-springmvc\\src\\test\\java")); context.addSource(Paths.get("F:\\@project@\\@dianli@\\tool\\apidoc\\apidoc-springmvc\\src\\test\\java"));
// context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css"); // context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css");
ApiDoc apigcc = new ApiDoc(context); ApiDoc apigcc = new ApiDoc(context);
......
package com.kim.apidoc.example; package com.github.fengyuchenglun.example;
import com.kim.apidoc.core.ApiDoc; import com.github.fengyuchenglun.apidoc.core.ApiDoc;
import com.kim.apidoc.core.Context; import com.github.fengyuchenglun.apidoc.core.Context;
import org.junit.Test; import org.junit.Test;
import java.nio.file.Paths; import java.nio.file.Paths;
/** /**
* @title Apigcc示例文档 * @title Apigcc示例文档
* @description 通过javadoc设置文档描述信息 * @description 通过javadoc设置文档描述信息
* 优先级大于通过Environment.description()设置的值 * 优先级大于通过Environment.description()设置的值
* @readme 所有接口均使用Https调用 * @readme 所有接口均使用Https调用
* /app路径下的接口为app专用 * /app路径下的接口为app专用
* /mini路径下的接口为小程序专用 * /mini路径下的接口为小程序专用
*/ */
public class ApigccTest { public class ApigccTest {
@Test @Test
public void testApigcc() { public void testApigcc() {
Context context = new Context(); Context context = new Context();
context.setId("test"); context.setId("test");
context.setName("测试项目"); context.setName("测试项目");
context.addSource(Paths.get("D:/apigcc/apigcc-demo-spring")); context.addSource(Paths.get("D:/apigcc/apigcc-demo-spring"));
//context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css"); //context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css");
ApiDoc apigcc = new ApiDoc(context); ApiDoc apigcc = new ApiDoc(context);
apigcc.parse(); apigcc.parse();
apigcc.render(); apigcc.render();
} }
} }
\ No newline at end of file
package com.kim.apidoc.example.annotation; package com.github.fengyuchenglun.example.annotation;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
......
package com.kim.apidoc.example.annotation; package com.github.fengyuchenglun.example.annotation;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
......
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
/** /**
* @code * @code
*/ */
public enum Code{ public enum Code{
OK(0,"ok"), OK(0,"ok"),
ERROR(-1,"error"), ERROR(-1,"error"),
NoAuth(1,"no auth"); NoAuth(1,"no auth");
private int code; private int code;
private String text; private String text;
Code(int code, String text) { Code(int code, String text) {
this.code = code; this.code = code;
this.text = text; this.text = text;
} }
} }
\ No newline at end of file
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
@Getter @Getter
@Setter @Setter
public class Menu { public class Menu {
int id; int id;
String name; String name;
List<Menu> menus; List<Menu> menus;
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.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;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Setter @Setter
@Getter @Getter
public class Page extends Query { public class Page extends Query {
/** /**
* 第几页 * 第几页
*/ */
@JsonProperty @JsonProperty
int page = 1; int page = 1;
/* 每页条数 */ /* 每页条数 */
@JSONField(name = "limit") @JSONField(name = "limit")
int sizs = 20; int sizs = 20;
@SerializedName("totalPage") @SerializedName("totalPage")
int total = 0; int total = 0;
@JsonProperty("max") @JsonProperty("max")
int maxPage = 0; int maxPage = 0;
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Setter @Setter
@Getter @Getter
public class Query { public class Query {
/** /**
* static will be ignore * static will be ignore
*/ */
public static final String CONSTANS = ""; public static final String CONSTANS = "";
/** /**
* 查询关键字 * 查询关键字
*/ */
String q = "123"; String q = "123";
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
/** /**
* The type Result data. * The type Result data.
* *
* @param <T> the type parameter * @param <T> the type parameter
* @author fengyuchenglun * @author fengyuchenglun
* @version 1.0.0 * @version 1.0.0
* @resultData * @resultData
*/ */
@Setter @Setter
@Getter @Getter
public class ResultData<T> { public class ResultData<T> {
/** /**
* 返回码 * 返回码
*/ */
int code; int code;
/** /**
* The Msg. * The Msg.
*/ */
//返回信息 //返回信息
String msg; String msg;
/** /**
* The Data. * The Data.
*/ */
T data; T data;
/** /**
* Ok result data. * Ok result data.
* *
* @param <T> the type parameter * @param <T> the type parameter
* @return the result data * @return the result data
*/ */
public static <T> ResultData<T> ok(){ public static <T> ResultData<T> ok(){
return ok(null); return ok(null);
} }
/** /**
* Ok result data. * Ok result data.
* *
* @param <T> the type parameter * @param <T> the type parameter
* @param data the data * @param data the data
* @return the result data * @return the result data
*/ */
public static <T> ResultData<T> ok(T data){ public static <T> ResultData<T> ok(T data){
ResultData<T> resultData = new ResultData<>(); ResultData<T> resultData = new ResultData<>();
resultData.code = 0; resultData.code = 0;
resultData.msg = "ok"; resultData.msg = "ok";
resultData.data = data; resultData.data = data;
return resultData; return resultData;
} }
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
/** /**
* 用户角色 * 用户角色
* *
* @code * @code
*/ */
public enum Role { public enum Role {
/** /**
* Admin role. * Admin role.
*/ */
ADMIN("管理员"), ADMIN("管理员"),
/** /**
* User role. * User role.
*/ */
USER("用户"), USER("用户"),
/** /**
* Vip role. * Vip role.
*/ */
VIP("会员"); VIP("会员");
/** /**
* The Text. * The Text.
*/ */
String text; String text;
/** /**
* Instantiates a new Role. * Instantiates a new Role.
* *
* @param text the text * @param text the text
*/ */
Role(String text) { Role(String text) {
this.text = text; this.text = text;
} }
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
/** /**
* @code * @code
*/ */
public class StaticFinalCode { public class StaticFinalCode {
/** /**
* 成功 * 成功
*/ */
public static final int SUCCESS = 1; public static final int SUCCESS = 1;
/** /**
* 失败 * 失败
*/ */
public static final int ERROR = -1; public static final int ERROR = -1;
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
/** /**
* 用户对象 * 用户对象
* *
* @author fengyuchenglun * @author fengyuchenglun
* @version 1.0.0 * @version 1.0.0
*/ */
@Setter @Setter
@Getter @Getter
public class User { public class User {
/** /**
* 用户编号. * 用户编号.
*/ */
int id; int id;
/** /**
* 用户名称. * 用户名称.
*/ */
@NotBlank @NotBlank
String name; String name;
/** /**
* 用户年龄. * 用户年龄.
*/ */
@Min(1) @Min(1)
@NotNull @NotNull
Integer age; Integer age;
/** /**
* 创建时间. * 创建时间.
*/ */
Date createAt; Date createAt;
/** /**
* 性别. * 性别.
*/ */
@NotBlank @NotBlank
@JsonProperty("Sex") @JsonProperty("Sex")
String sex; String sex;
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Setter @Setter
@Getter @Getter
public class UserDTO { public class UserDTO {
/** /**
* 编号 * 编号
*/ */
Integer id; Integer id;
/*姓名*/ /*姓名*/
@Size(min = 5, max = 20) @Size(min = 5, max = 20)
@NotEmpty @NotEmpty
String name; String name;
//年龄 //年龄
@Min(1) @Min(1)
int age; int age;
/** /**
* 生日,还是推荐使用javadoc * 生日,还是推荐使用javadoc
*/ */
@NotNull @NotNull
Date birthday; Date birthday;
/** /**
* 用户标签 * 用户标签
*/ */
@Size(min = 1, max = 2) @Size(min = 1, max = 2)
List<String> tags; List<String> tags;
List<?> data; List<?> data;
/** /**
* 用户图标 * 用户图标
*/ */
String[] icons; String[] icons;
Map<String, String> attrs; Map<String, String> attrs;
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
/** /**
* 某些用户信息框架,如spring security的用户登录信息 * 某些用户信息框架,如spring security的用户登录信息
* 此处只是模拟,真实的将调用security中的类 * 此处只是模拟,真实的将调用security中的类
*/ */
public class UserDetails { public class UserDetails {
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Setter @Setter
@Getter @Getter
public class UserQuery extends Page { public class UserQuery extends Page {
/** /**
* 名称 * 名称
* @value apigcc * @value apigcc
*/ */
String name; String name;
} }
package com.kim.apidoc.example.common; package com.github.fengyuchenglun.example.common;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Setter @Setter
@Getter @Getter
public class Wrapper<T> { public class Wrapper<T> {
String wrapper; String wrapper;
T data; T data;
} }
package com.github.fengyuchenglun.example.spring.advanced;
import com.github.fengyuchenglun.example.annotation.KimController;
import com.github.fengyuchenglun.example.common.Query;
import com.github.fengyuchenglun.example.common.User;
import lombok.Data;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
/**
* 用户接口.
*
* @author duanledexianxianxian
* @version 1.0.0
* @date 2020 /3/25 1:00
* @index 20
* @since 1.0.0
*/
@KimController
@RequestMapping("/api/v1/users")
public class UserController {
/**
* 查看用户详情
*
* @param userId 用户编号
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/{userId}")
public User detail(@PathVariable String userId, Query query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/detail1")
public User detail1( Query query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/detail3")
public User detail3(@RequestParam Query query) {
User user = new User();
return user;
}
/**
* 用户表单对象.
*
* @author duanledexianxianxian
*/
@Data
public static class UserForm implements Serializable {
private static final long serialVersionUID = 5681371348688016281L;
/**
* 用户名
*/
private String userName;
/**
* 地址
*/
private String address;
/**
* 年龄
*/
private Integer age;
}
/**
* 添加用户
*
* @param form 用户表单对象
* @return integer integer
*/
@PostMapping
public Integer add(@RequestBody UserForm form) {
return null;
}
}
package com.kim.apidoc.example.spring.advanced;
import com.kim.apidoc.example.annotation.KimController;
import com.kim.apidoc.example.common.Query;
import com.kim.apidoc.example.common.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* The type Kim user controller.
*
* @author duanledexianxianxian
* @version 1.0.0
* @date 2020 /3/25 1:00
* @index 20
* @since 1.0.0
*/
@KimController
@RequestMapping("/api/v1")
public class UserController {
/**
* 查看用户详情
*
* @param userId 用户编号
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/{userId}")
public User detail(@PathVariable String userId, Query query) {
User user = new User();
return user;
}
/**
* Add integer.
*
* @return integer integer
*/
@PostMapping
public Integer add() {
return null;
}
}
...@@ -4,8 +4,8 @@ allprojects { ...@@ -4,8 +4,8 @@ allprojects {
apply plugin: 'maven' apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release' apply plugin: 'com.novoda.bintray-release'
group 'com.apidoc' group 'com.github.fengyuchenglun'
version '1.7.0' version '1.0.0'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
...@@ -28,8 +28,8 @@ allprojects { ...@@ -28,8 +28,8 @@ allprojects {
ext { ext {
DESCRIPTION = 'A rest document generator with parse the source code.' DESCRIPTION = 'A rest document generator with parse the source code.'
SITE_URL = 'https://github.com/apigcc/apigcc' SITE_URL = 'http://platform.kuopu.net:9999/gitlab/duanledexianxianxian/apidoc'
GIT_URL = 'https://github.com/apigcc/apigcc.git' GIT_URL = 'http://platform.kuopu.net:9999/gitlab/duanledexianxianxian/apidoc.git'
LICENSE = 'MIT License' LICENSE = 'MIT License'
......
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