Commit 2e5785bf authored by duanledexianxianxian's avatar duanledexianxianxian 😁

Refactoring code.

parent 80acc032
...@@ -2,4 +2,5 @@ dependencies { ...@@ -2,4 +2,5 @@ dependencies {
compile 'com.github.javaparser:javaparser-symbol-solver-core:3.14.4' compile 'com.github.javaparser:javaparser-symbol-solver-core:3.14.4'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.2' compile 'com.fasterxml.jackson.core:jackson-databind:2.5.2'
compile 'org.asciidoctor:asciidoctorj:2.1.0' compile 'org.asciidoctor:asciidoctorj:2.1.0'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.30'
} }
package kim.apidoc.core; package com.kim.apidoc.core;
import kim.apidoc.core.common.helper.StringHelper; import com.kim.apidoc.core.common.helper.StringHelper;
import kim.apidoc.core.parser.ParserStrategy; import com.kim.apidoc.core.parser.ParserStrategy;
import kim.apidoc.core.parser.VisitorParser; import com.kim.apidoc.core.parser.VisitorParser;
import kim.apidoc.core.render.ProjectRender; import com.kim.apidoc.core.render.ProjectRender;
import kim.apidoc.core.resolver.TypeResolvers; import com.kim.apidoc.core.resolver.TypeResolvers;
import kim.apidoc.core.schema.Project; import com.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;
...@@ -135,15 +135,15 @@ public class ApiDoc { ...@@ -135,15 +135,15 @@ public class ApiDoc {
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.getFramework())) {
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.getFramework(), 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.getFramework());
} }
/** /**
......
package kim.apidoc.core; package com.kim.apidoc.core;
import kim.apidoc.core.common.helper.FileHelper;
import kim.apidoc.core.render.AsciiDocRender;
import kim.apidoc.core.render.PostmanRender;
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 com.kim.apidoc.core.common.helper.FileHelper;
import com.kim.apidoc.core.render.AsciiDocRender;
import com.kim.apidoc.core.render.MarkdownRender;
import com.kim.apidoc.core.render.PostmanRender;
import com.kim.apidoc.core.render.ProjectRender;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -14,6 +15,8 @@ import java.nio.file.Paths; ...@@ -14,6 +15,8 @@ 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.
* *
...@@ -44,15 +47,16 @@ public class Context { ...@@ -44,15 +47,16 @@ public class Context {
* 设置当前解析框架 * 设置当前解析框架
*/ */
@Setter @Setter
public String framework; private String framework;
/** /**
* The Renders. * The Renders.
*/ */
@Setter @Setter
public List<ProjectRender> renders = Lists.newArrayList( private List<ProjectRender> renders = Lists.newArrayList(
new AsciiDocRender(), new AsciiDocRender(),
new PostmanRender()); new PostmanRender(),
new MarkdownRender());
/** /**
* 编译目录 * 编译目录
...@@ -102,17 +106,24 @@ public class Context { ...@@ -102,17 +106,24 @@ public class Context {
@Setter @Setter
private String css; private String css;
/**
* markdown模版文件路径
*/
@Setter
private String markdownTemplate = MARKDOWN_TEMPLATE;
/** /**
* 自定义扩展参数 * 自定义扩展参数
*/ */
private Map<String,Object> ext= Maps.newHashMap(); private Map<String, Object> ext = Maps.newHashMap();
/** /**
* Add source. * Add source.
* *
* @param path the path * @param path the path
*/ */
public void addSource(Path path){ public void addSource(Path path) {
sources.add(path); sources.add(path);
sources.addAll(FileHelper.find(path, DEFAULT_CODE_STRUCTURE)); sources.addAll(FileHelper.find(path, DEFAULT_CODE_STRUCTURE));
addDependency(path); addDependency(path);
...@@ -123,7 +134,7 @@ public class Context { ...@@ -123,7 +134,7 @@ public class Context {
* *
* @param path the path * @param path the path
*/ */
public void addDependency(Path path){ public void addDependency(Path path) {
dependencies.add(path); dependencies.add(path);
dependencies.addAll(FileHelper.find(path, DEFAULT_CODE_STRUCTURE)); dependencies.addAll(FileHelper.find(path, DEFAULT_CODE_STRUCTURE));
} }
...@@ -133,10 +144,9 @@ public class Context { ...@@ -133,10 +144,9 @@ public class Context {
* *
* @param path the path * @param path the path
*/ */
public void addJar(Path path){ public void addJar(Path path) {
jars.add(path); jars.add(path);
} }
} }
package kim.apidoc.core.common; package com.kim.apidoc.core.common;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
package com.kim.apidoc.core.common;
import java.nio.charset.StandardCharsets;
/**
* 常量类
*
* @author duanledexianxianxian
* @version 1.0.0
* @date 2020 /3/26 23:00
* @since 1.0.0
*/
public class Constants {
public static final String UTF8 = StandardCharsets.UTF_8.name();
public static final String SLASH = "/";
public static final String MARKDOWN_EXTENSION = ".md";
public static final String MARKDOWN_TEMPLATE = "/templates/markdown.ftl";
}
package kim.apidoc.core.common; package com.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 kim.apidoc.core.common; package com.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 kim.apidoc.core.common; package com.kim.apidoc.core.common;
import kim.apidoc.core.common.helper.StringHelper; import com.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 kim.apidoc.core.common.description; package com.kim.apidoc.core.common.description;
import kim.apidoc.core.common.ObjectMappers; import com.kim.apidoc.core.schema.Row;
import kim.apidoc.core.schema.Row; import com.kim.apidoc.core.common.ObjectMappers;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import java.util.ArrayList; import java.util.ArrayList;
......
package kim.apidoc.core.common.description; package com.kim.apidoc.core.common.description;
import kim.apidoc.core.common.ObjectMappers; import com.kim.apidoc.core.schema.Row;
import kim.apidoc.core.schema.Row; import com.kim.apidoc.core.common.ObjectMappers;
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 kim.apidoc.core.common.description; package com.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;
......
package kim.apidoc.core.common.description; package com.kim.apidoc.core.common.description;
public class StringTypeDescription extends TypeDescription { public class StringTypeDescription extends TypeDescription {
......
package kim.apidoc.core.common.description; package com.kim.apidoc.core.common.description;
import kim.apidoc.core.common.helper.StringHelper; import com.kim.apidoc.core.schema.Row;
import kim.apidoc.core.schema.Row; import com.kim.apidoc.core.common.helper.StringHelper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.description; package com.kim.apidoc.core.common.description;
import kim.apidoc.core.schema.Row; import com.kim.apidoc.core.schema.Row;
import java.util.Collection; import java.util.Collection;
......
package kim.apidoc.core.common.diff; package com.kim.apidoc.core.common.diff;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import lombok.Getter; import lombok.Getter;
......
package kim.apidoc.core.common.diff; package com.kim.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 kim.apidoc.core.common.diff; package com.kim.apidoc.core.common.diff;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
......
package kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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;
...@@ -32,10 +32,10 @@ public class FileHelper { ...@@ -32,10 +32,10 @@ public class FileHelper {
} }
} }
public static List<Path> find(Path start, String structure){ public static List<Path> find(Path start, String structure) {
try { try {
return Files.walk(start) return Files.walk(start)
.filter(p->p.endsWith(structure)).collect(Collectors.toList()); .filter(p -> p.endsWith(structure)).collect(Collectors.toList());
} catch (IOException e) { } catch (IOException e) {
log.warn("find path error:{} {}", start, e.getMessage()); log.warn("find path error:{} {}", start, e.getMessage());
} }
......
package kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.kim.apidoc.core.common.helper;
import java.util.Optional; import java.util.Optional;
......
package kim.apidoc.core.common.helper; package com.kim.apidoc.core.common.helper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
......
package kim.apidoc.core.common.helper; package com.kim.apidoc.core.common.helper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
package kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.helper; package com.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 kim.apidoc.core.common.markup; package com.kim.apidoc.core.common.markup;
import kim.apidoc.core.common.markup.asciidoc.AsciiDocBuilder; import com.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 kim.apidoc.core.common.markup.asciidoc; package com.kim.apidoc.core.common.markup.asciidoc;
public enum AsciiDoc implements CharSequence { public enum AsciiDoc implements CharSequence {
EXTENSION(".adoc"), EXTENSION(".adoc"),
......
package kim.apidoc.core.common.markup.asciidoc; package com.kim.apidoc.core.common.markup.asciidoc;
import kim.apidoc.core.common.Assert; import com.kim.apidoc.core.common.markup.MarkupBuilder;
import kim.apidoc.core.common.markup.MarkupBuilder; import com.kim.apidoc.core.common.Assert;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import java.util.List; import java.util.List;
......
package kim.apidoc.core.common.markup.asciidoc; package com.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 kim.apidoc.core.common.markup.markdown; package com.kim.apidoc.core.common.markup.markdown;
public enum Markdown implements CharSequence { public enum Markdown implements CharSequence {
EXTENSION(".md"), EXTENSION(".md"),
......
package kim.apidoc.core.common.markup.markdown; package com.kim.apidoc.core.common.markup.markdown;
import kim.apidoc.core.common.Assert; import com.kim.apidoc.core.common.markup.MarkupBuilder;
import kim.apidoc.core.common.markup.MarkupBuilder; import com.kim.apidoc.core.common.Assert;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import java.util.List; import java.util.List;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
/** /**
* 对应postman定义的mode * 对应postman定义的mode
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter; import lombok.Getter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import kim.apidoc.core.schema.Row; import com.kim.apidoc.core.schema.Row;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import kim.apidoc.core.schema.Header; import com.kim.apidoc.core.schema.Header;
import kim.apidoc.core.schema.Method; import com.kim.apidoc.core.schema.Method;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import kim.apidoc.core.schema.Header; import com.kim.apidoc.core.schema.Header;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.common.postman; package com.kim.apidoc.core.common.postman;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.parser; package com.kim.apidoc.core.parser;
import kim.apidoc.core.schema.Chapter; import com.kim.apidoc.core.schema.Chapter;
import kim.apidoc.core.schema.Section; import com.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 kim.apidoc.core.parser; package com.kim.apidoc.core.parser;
import kim.apidoc.core.common.helper.OptionalHelper; import com.kim.apidoc.core.schema.Chapter;
import kim.apidoc.core.schema.Chapter; import com.kim.apidoc.core.schema.Node;
import kim.apidoc.core.schema.Node; import com.kim.apidoc.core.schema.Project;
import kim.apidoc.core.schema.Project; import com.kim.apidoc.core.schema.Section;
import kim.apidoc.core.schema.Section; import com.kim.apidoc.core.common.helper.OptionalHelper;
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 kim.apidoc.core.render; package com.kim.apidoc.core.render;
import kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.helper.FileHelper;
import kim.apidoc.core.common.helper.StringHelper;
import kim.apidoc.core.common.markup.MarkupBuilder;
import kim.apidoc.core.common.markup.asciidoc.AsciiDoc;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import kim.apidoc.core.schema.*; import com.kim.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.helper.FileHelper;
import com.kim.apidoc.core.common.helper.StringHelper;
import com.kim.apidoc.core.common.markup.MarkupBuilder;
import com.kim.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;
...@@ -46,7 +46,7 @@ public class AsciiDocRender implements ProjectRender { ...@@ -46,7 +46,7 @@ public class AsciiDocRender implements ProjectRender {
project.getBooks().forEach((name, book) -> { project.getBooks().forEach((name, book) -> {
MarkupBuilder builder = MarkupBuilder.getInstance(); MarkupBuilder builder = MarkupBuilder.getInstance();
String displayName = project.getName(); String displayName = project.getName();
if(!Objects.equals(Book.DEFAULT, name)){ if (!Objects.equals(Book.DEFAULT, name)) {
displayName += " - " + name; displayName += " - " + name;
} }
builder.header(displayName, attrs); builder.header(displayName, attrs);
...@@ -61,7 +61,7 @@ public class AsciiDocRender implements ProjectRender { ...@@ -61,7 +61,7 @@ public class AsciiDocRender implements ProjectRender {
builder.title(1, chapter.getName()); builder.title(1, chapter.getName());
builder.paragraph(chapter.getDescription()); builder.paragraph(chapter.getDescription());
for (Section section : chapter.getSections()) { for (Section section : chapter.getSections()) {
if(section.isIgnore()){ if (section.isIgnore()) {
continue; continue;
} }
builder.title(2, section.getName()); builder.title(2, section.getName());
...@@ -71,7 +71,7 @@ public class AsciiDocRender implements ProjectRender { ...@@ -71,7 +71,7 @@ public class AsciiDocRender implements ProjectRender {
builder.title(4, "request"); builder.title(4, "request");
builder.listing(b -> { builder.listing(b -> {
b.textLine(section.getRequestLine()); b.textLine(section.getRequestLine());
section.getInHeaders().values().forEach(header->builder.textLine(header.toString())); section.getInHeaders().values().forEach(header -> builder.textLine(header.toString()));
if (section.hasRequestBody()) { if (section.hasRequestBody()) {
b.br(); b.br();
b.text(section.getParameterString()); b.text(section.getParameterString());
...@@ -87,7 +87,7 @@ public class AsciiDocRender implements ProjectRender { ...@@ -87,7 +87,7 @@ public class AsciiDocRender implements ProjectRender {
if (section.hasResponseBody()) { if (section.hasResponseBody()) {
b.br(); b.br();
b.text(section.getResponseString()); b.text(section.getResponseString());
}else{ } else {
b.text("N/A"); b.text("N/A");
} }
}, "source,JSON"); }, "source,JSON");
......
package com.kim.apidoc.core.render;
import com.kim.apidoc.core.ApiDoc;
import com.kim.apidoc.core.common.Constants;
import com.kim.apidoc.core.schema.Project;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.nio.file.Path;
/**
* 生成markdown api文档
*
* @author duanledexianxianxian
* @version 1.0.0
* @date 2020 /3/26 19:03
* @since 1.0.0
*/
@Slf4j
public class MarkdownRender implements ProjectRender {
private Configuration configuration;
public MarkdownRender init() {
configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
configuration.setDefaultEncoding(Constants.UTF8);
configuration.setClassForTemplateLoading(MarkdownRender.class, Constants.SLASH);
return this;
}
@Override
public void render(Project project) {
this.init();
try {
this.build(project);
} catch (Exception e) {
log.error("Build Markdown Fail {}", e.getMessage());
}
}
private void build(Project project) throws Exception {
String templatePath = ApiDoc.getInstance().getContext().getMarkdownTemplate();
String id = ApiDoc.getInstance().getContext().getId();
Path buildPath = ApiDoc.getInstance().getContext().getBuildPath();
Path markdownFile = buildPath.resolve(id).resolve(id + Constants.MARKDOWN_EXTENSION);
Template template = configuration.getTemplate(templatePath);
try (FileOutputStream fileOutputStream = new FileOutputStream(markdownFile.toString())) {
template.process(project, new OutputStreamWriter(fileOutputStream, Constants.UTF8));
}
log.info("Build Markdown {}", markdownFile);
}
}
package kim.apidoc.core.render; package com.kim.apidoc.core.render;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.ObjectMappers; import com.kim.apidoc.core.common.ObjectMappers;
import kim.apidoc.core.common.helper.FileHelper; import com.kim.apidoc.core.common.helper.FileHelper;
import kim.apidoc.core.common.postman.*; import com.kim.apidoc.core.common.postman.*;
import kim.apidoc.core.schema.*; import com.kim.apidoc.core.schema.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.nio.file.Path; import java.nio.file.Path;
...@@ -38,14 +38,14 @@ public class PostmanRender implements ProjectRender { ...@@ -38,14 +38,14 @@ public class PostmanRender implements ProjectRender {
Folder folder = new Folder(); Folder folder = new Folder();
folder.setName(book.getId()); folder.setName(book.getId());
for (Chapter chapter : book.getChapters()) { for (Chapter chapter : book.getChapters()) {
if(chapter.isIgnore() || chapter.getSections().isEmpty()){ if (chapter.isIgnore() || chapter.getSections().isEmpty()) {
continue; continue;
} }
Folder chapterFolder = new Folder(); Folder chapterFolder = new Folder();
chapterFolder.setName(chapter.getName()); chapterFolder.setName(chapter.getName());
chapterFolder.setDescription(chapter.getDescription()); chapterFolder.setDescription(chapter.getDescription());
for (Section section : chapter.getSections()) { for (Section section : chapter.getSections()) {
if(section.isIgnore()){ if (section.isIgnore()) {
continue; continue;
} }
chapterFolder.getItem().add(build(section)); chapterFolder.getItem().add(build(section));
...@@ -55,7 +55,7 @@ public class PostmanRender implements ProjectRender { ...@@ -55,7 +55,7 @@ public class PostmanRender implements ProjectRender {
postman.getItem().add(folder); postman.getItem().add(folder);
} }
if(postman.getItem().size()==1){ if (postman.getItem().size() == 1) {
Folder folder = postman.getItem().get(0); Folder folder = postman.getItem().get(0);
postman.setItem(folder.getItem()); postman.setItem(folder.getItem());
} }
...@@ -74,18 +74,18 @@ public class PostmanRender implements ProjectRender { ...@@ -74,18 +74,18 @@ public class PostmanRender implements ProjectRender {
request.setMethod(section.getMethod()); request.setMethod(section.getMethod());
request.getHeaders().addAll(section.getInHeaders().values()); request.getHeaders().addAll(section.getInHeaders().values());
if(section.isQueryParameter()){ if (section.isQueryParameter()) {
if(Method.GET.equals(request.getMethod())){ if (Method.GET.equals(request.getMethod())) {
ObjectNode objectNode = (ObjectNode)section.getParameter(); ObjectNode objectNode = (ObjectNode) section.getParameter();
for (String key : section.getRequestRows().keySet()) { for (String key : section.getRequestRows().keySet()) {
if (objectNode.has(key)) { if (objectNode.has(key)) {
Row row = section.getRequestRows().get(key); Row row = section.getRequestRows().get(key);
request.getUrl().getQuery().add(Parameter.of(row)); request.getUrl().getQuery().add(Parameter.of(row));
} }
} }
}else{ } else {
request.getBody().setMode(BodyMode.urlencoded); request.getBody().setMode(BodyMode.urlencoded);
ObjectNode objectNode = (ObjectNode)section.getParameter(); ObjectNode objectNode = (ObjectNode) section.getParameter();
for (String key : section.getRequestRows().keySet()) { for (String key : section.getRequestRows().keySet()) {
if (objectNode.has(key)) { if (objectNode.has(key)) {
Row row = section.getRequestRows().get(key); Row row = section.getRequestRows().get(key);
...@@ -93,7 +93,7 @@ public class PostmanRender implements ProjectRender { ...@@ -93,7 +93,7 @@ public class PostmanRender implements ProjectRender {
} }
} }
} }
}else{ } else {
request.getBody().setMode(BodyMode.raw); request.getBody().setMode(BodyMode.raw);
request.getBody().setRaw(section.getParameterString()); request.getBody().setRaw(section.getParameterString());
} }
......
package kim.apidoc.core.render; package com.kim.apidoc.core.render;
import kim.apidoc.core.schema.Project; import com.kim.apidoc.core.schema.Project;
/** /**
* The interface Project render. * The interface Project render.
......
package kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.ArrayTypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.helper.TypeParameterHelper; import com.kim.apidoc.core.common.helper.TypeParameterHelper;
import kim.apidoc.core.common.description.ArrayTypeDescription; import com.kim.apidoc.core.common.description.ArrayTypeDescription;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.StringTypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.StringTypeDescription; import com.kim.apidoc.core.common.description.StringTypeDescription;
import kim.apidoc.core.common.description.TypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
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 com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.description.ObjectTypeDescription; import com.kim.apidoc.core.common.description.ObjectTypeDescription;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.helper.*; import com.kim.apidoc.core.common.helper.*;
import java.util.Optional; import java.util.Optional;
......
package kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.PrimitiveTypeDescription; import com.kim.apidoc.core.common.description.PrimitiveTypeDescription;
import kim.apidoc.core.common.description.TypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.StringTypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.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 kim.apidoc.core.resolver; package com.kim.apidoc.core.resolver;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.helper.TypeNameHelper; import com.kim.apidoc.core.common.helper.TypeNameHelper;
import kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.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 kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import kim.apidoc.core.Context; import com.kim.apidoc.core.Context;
import kim.apidoc.core.common.helper.CommentHelper; import com.kim.apidoc.core.common.helper.CommentHelper;
import kim.apidoc.core.common.helper.StringHelper; import com.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 kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.*; import lombok.*;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import kim.apidoc.core.common.ObjectMappers; import com.kim.apidoc.core.common.ObjectMappers;
import kim.apidoc.core.common.QueryStringBuilder; import com.kim.apidoc.core.common.QueryStringBuilder;
import kim.apidoc.core.common.helper.StringHelper; import com.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;
......
package kim.apidoc.core.schema; package com.kim.apidoc.core.schema;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
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) {
}
}
[TOC]
<#-- ---------- BEGIN 循环遍历book ---------->
<#if books??>
<#list books as bookKey,bookValue>
${bookKey}
<#if bookValue.name??>
# ${bookValue.name}
</#if>
<#list bookValue.chapters>
<#items as chapter>
## ${chapter?counter}. ${chapter.name}
${chapter.description}
<#list chapter.sections>
<#items as section>
### ${chapter?counter}.${section?counter} ${section.name}
${section.description}
**request**
```HTTP
POST /api/v1/users HTTP/1.1
{
"loginId":"admin",
"userName":"123456",
"passwords":"123456"
}
```
**header**
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
| loginId | String | | | 用户编号 |
| userName | String | | | 用户名 |
| password | String | | | 密码 |
**query**
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
<#list section.requestRows as rowKey,rowValue>
| rowValue.key | rowValue.type | rowValue.condition | rowValue.def | rowValue.remark |
</#list>
**body**
| Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- |
| loginId | String | | | 用户编号 |
| userName | String | | | 用户名 |
| password | String | | | 密码 |
**response**
```
{
"loginId":"admin",
"userName":"123456",
"passwords":"123456"
}
```
| Field | Type | Description |
| :------- | :----- | :---------- |
| loginId | String | 用户编号 |
| userName | String | 用户名 |
| password | String | 密码 |
</#items>
</#list>
</#items>
</#list>
</#list>
</#if>
<#------------ END 循环遍历book ---------->
package com.kim.apidoc.springmvc; package com.kim.apidoc.springmvc;
import kim.apidoc.core.common.URI; import com.kim.apidoc.core.common.URI;
import kim.apidoc.core.common.helper.AnnotationHelper; import com.kim.apidoc.core.common.helper.AnnotationHelper;
import kim.apidoc.core.common.helper.ClassDeclarationHelper; import com.kim.apidoc.core.common.helper.ClassDeclarationHelper;
import kim.apidoc.core.common.helper.ExpressionHelper; import com.kim.apidoc.core.common.helper.ExpressionHelper;
import kim.apidoc.core.schema.Method; import com.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.kim.apidoc.springmvc; package com.kim.apidoc.springmvc;
import kim.apidoc.core.ApiDoc; import com.kim.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.kim.apidoc.springmvc;
import com.kim.apidoc.springmvc.resovler.SpringComponentTypeResolver; import com.kim.apidoc.springmvc.resovler.SpringComponentTypeResolver;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.URI; import com.kim.apidoc.core.common.URI;
import kim.apidoc.core.common.description.ObjectTypeDescription; import com.kim.apidoc.core.common.description.ObjectTypeDescription;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.helper.AnnotationHelper; import com.kim.apidoc.core.common.helper.AnnotationHelper;
import kim.apidoc.core.common.helper.ExpressionHelper; import com.kim.apidoc.core.common.helper.ExpressionHelper;
import kim.apidoc.core.common.helper.StringHelper; import com.kim.apidoc.core.common.helper.StringHelper;
import kim.apidoc.core.parser.ParserStrategy; import com.kim.apidoc.core.parser.ParserStrategy;
import kim.apidoc.core.schema.Chapter; import com.kim.apidoc.core.schema.Chapter;
import kim.apidoc.core.schema.Header; import com.kim.apidoc.core.schema.Header;
import kim.apidoc.core.schema.Row; import com.kim.apidoc.core.schema.Row;
import kim.apidoc.core.schema.Section; import com.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;
......
package com.kim.apidoc.springmvc.resovler; package com.kim.apidoc.springmvc.resovler;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.common.description.TypeDescription; import com.kim.apidoc.core.common.description.TypeDescription;
import kim.apidoc.core.common.description.UnAvailableTypeDescription; import com.kim.apidoc.core.common.description.UnAvailableTypeDescription;
import kim.apidoc.core.common.helper.TypeParameterHelper; import com.kim.apidoc.core.common.helper.TypeParameterHelper;
import kim.apidoc.core.resolver.TypeNameResolver; import com.kim.apidoc.core.resolver.TypeNameResolver;
import kim.apidoc.core.resolver.TypeResolver; import com.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;
......
package com.kim.apidoc.example; package com.kim.apidoc.example;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.Context; import com.kim.apidoc.core.Context;
import org.junit.Test; import org.junit.Test;
import java.nio.file.Paths; import java.nio.file.Paths;
......
package com.kim.apidoc.springmvc; package com.kim.apidoc.springmvc;
import kim.apidoc.core.ApiDoc; import com.kim.apidoc.core.ApiDoc;
import kim.apidoc.core.Context; import com.kim.apidoc.core.Context;
import kim.apidoc.core.common.diff.FileMatcher; import com.kim.apidoc.core.common.diff.FileMatcher;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
# 系统管理
## 1. 用户接口 ## 1. 用户接口
与用户相关接口。 与用户相关接口。
...@@ -10,7 +14,7 @@ ...@@ -10,7 +14,7 @@
添加用户 添加用户
#### request **request**
```HTTP ```HTTP
POST /api/v1/users HTTP/1.1 POST /api/v1/users HTTP/1.1
...@@ -22,7 +26,7 @@ POST /api/v1/users HTTP/1.1 ...@@ -22,7 +26,7 @@ POST /api/v1/users HTTP/1.1
} }
``` ```
##### header **header**
| Field | Type | Condition | Default | Description | | Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- | | :------- | :----- | :-------- | :------ | :---------- |
...@@ -30,7 +34,7 @@ POST /api/v1/users HTTP/1.1 ...@@ -30,7 +34,7 @@ POST /api/v1/users HTTP/1.1
| userName | String | | | 用户名 | | userName | String | | | 用户名 |
| password | String | | | 密码 | | password | String | | | 密码 |
##### query **query**
| Field | Type | Condition | Default | Description | | Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- | | :------- | :----- | :-------- | :------ | :---------- |
...@@ -38,7 +42,7 @@ POST /api/v1/users HTTP/1.1 ...@@ -38,7 +42,7 @@ POST /api/v1/users HTTP/1.1
| userName | String | | | 用户名 | | userName | String | | | 用户名 |
| password | String | | | 密码 | | password | String | | | 密码 |
##### body **body**
| Field | Type | Condition | Default | Description | | Field | Type | Condition | Default | Description |
| :------- | :----- | :-------- | :------ | :---------- | | :------- | :----- | :-------- | :------ | :---------- |
...@@ -46,7 +50,7 @@ POST /api/v1/users HTTP/1.1 ...@@ -46,7 +50,7 @@ POST /api/v1/users HTTP/1.1
| userName | String | | | 用户名 | | userName | String | | | 用户名 |
| password | String | | | 密码 | | password | String | | | 密码 |
#### response **response**
``` ```
{ {
......
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