|
@@ -1,31 +1,26 @@
|
|
|
package com.primeton.dgs.kernel.core.configure;
|
|
package com.primeton.dgs.kernel.core.configure;
|
|
|
|
|
|
|
|
-import com.google.common.collect.ImmutableMap;
|
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.common.collect.Multimap;
|
|
import com.google.common.collect.Multimap;
|
|
|
import com.google.common.collect.Sets;
|
|
import com.google.common.collect.Sets;
|
|
|
import com.google.common.net.MediaType;
|
|
import com.google.common.net.MediaType;
|
|
|
import com.primeton.dgs.kernel.core.web.AppBaseDispatchCommand;
|
|
import com.primeton.dgs.kernel.core.web.AppBaseDispatchCommand;
|
|
|
-import io.swagger.models.Path;
|
|
|
|
|
-import io.swagger.models.Response;
|
|
|
|
|
-import io.swagger.models.Swagger;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
-import org.springframework.context.ApplicationContext;
|
|
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
|
|
-import springfox.documentation.builders.ResponseMessageBuilder;
|
|
|
|
|
-import springfox.documentation.schema.ModelRef;
|
|
|
|
|
-import springfox.documentation.service.Operation;
|
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.InitializingBean;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.ApplicationListener;
|
|
import org.springframework.context.ApplicationListener;
|
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
import org.springframework.context.event.ContextRefreshedEvent;
|
|
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.stereotype.Repository;
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
|
+import springfox.documentation.builders.ResponseMessageBuilder;
|
|
|
|
|
+import springfox.documentation.schema.ModelRef;
|
|
|
import springfox.documentation.service.ApiDescription;
|
|
import springfox.documentation.service.ApiDescription;
|
|
|
import springfox.documentation.service.ApiListing;
|
|
import springfox.documentation.service.ApiListing;
|
|
|
import springfox.documentation.service.Documentation;
|
|
import springfox.documentation.service.Documentation;
|
|
|
|
|
+import springfox.documentation.service.Operation;
|
|
|
|
|
+import springfox.documentation.service.Parameter;
|
|
|
import springfox.documentation.service.ResponseMessage;
|
|
import springfox.documentation.service.ResponseMessage;
|
|
|
import springfox.documentation.service.Tag;
|
|
import springfox.documentation.service.Tag;
|
|
|
import springfox.documentation.spring.web.DocumentationCache;
|
|
import springfox.documentation.spring.web.DocumentationCache;
|
|
@@ -37,11 +32,10 @@ import java.lang.reflect.Method;
|
|
|
import java.lang.reflect.Modifier;
|
|
import java.lang.reflect.Modifier;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
-import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
-import java.util.TreeSet;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
@@ -164,11 +158,31 @@ public class SwaggerExtentionSupport implements ApplicationListener<ContextRefre
|
|
|
tags.add(tag);
|
|
tags.add(tag);
|
|
|
|
|
|
|
|
// 注意 position,必须是不重复的值
|
|
// 注意 position,必须是不重复的值
|
|
|
|
|
+ ArrayList<Parameter> parameters = new ArrayList<>();
|
|
|
|
|
+ /*
|
|
|
|
|
+ 暂时先不要参数
|
|
|
|
|
+ Parameter parameter = new Parameter(
|
|
|
|
|
+ "invoke",
|
|
|
|
|
+ "Invoke Method",
|
|
|
|
|
+ methodName,
|
|
|
|
|
+ true,
|
|
|
|
|
+ false,
|
|
|
|
|
+ false,
|
|
|
|
|
+ new ModelRef("string"),
|
|
|
|
|
+ null, null,
|
|
|
|
|
+ "string","", false, null, null, 0, null,
|
|
|
|
|
+ ArrayListMultimap.create(),
|
|
|
|
|
+ Collections.emptyList()
|
|
|
|
|
+ );
|
|
|
|
|
+ parameters.add(parameter);
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
Operation operaGet = new Operation(
|
|
Operation operaGet = new Operation(
|
|
|
HttpMethod.GET,
|
|
HttpMethod.GET,
|
|
|
"do exec " + optGroup + "." + methodName,
|
|
"do exec " + optGroup + "." + methodName,
|
|
|
"",
|
|
"",
|
|
|
- new ModelRef("ResponseCode"),
|
|
|
|
|
|
|
+ new ModelRef("string"),
|
|
|
optId+"UsingGET",
|
|
optId+"UsingGET",
|
|
|
0,
|
|
0,
|
|
|
Sets.newHashSet(tag.getName()),
|
|
Sets.newHashSet(tag.getName()),
|
|
@@ -176,20 +190,20 @@ public class SwaggerExtentionSupport implements ApplicationListener<ContextRefre
|
|
|
Sets.newHashSet(MediaType.create("application", "json").toString()),
|
|
Sets.newHashSet(MediaType.create("application", "json").toString()),
|
|
|
new HashSet<>(),
|
|
new HashSet<>(),
|
|
|
new ArrayList<>(),
|
|
new ArrayList<>(),
|
|
|
- new ArrayList<>(),
|
|
|
|
|
|
|
+ parameters,
|
|
|
Sets.newHashSet(v200, v401, v403, v404),
|
|
Sets.newHashSet(v200, v401, v403, v404),
|
|
|
"",
|
|
"",
|
|
|
false,
|
|
false,
|
|
|
new ArrayList<>()
|
|
new ArrayList<>()
|
|
|
);
|
|
);
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
// Operation 只需要 tag name,他决定了该 api 在 Swagger 上挂载的tag
|
|
// Operation 只需要 tag name,他决定了该 api 在 Swagger 上挂载的tag
|
|
|
- /*
|
|
|
|
|
Operation operaPost = new Operation(
|
|
Operation operaPost = new Operation(
|
|
|
HttpMethod.POST,
|
|
HttpMethod.POST,
|
|
|
"do exec " + optGroup + "." + methodName,
|
|
"do exec " + optGroup + "." + methodName,
|
|
|
"",
|
|
"",
|
|
|
- new ModelRef("ResponseCode"),
|
|
|
|
|
|
|
+ new ModelRef("string"),
|
|
|
optId+"UsingPOST",
|
|
optId+"UsingPOST",
|
|
|
0,
|
|
0,
|
|
|
Sets.newHashSet(tag.getName()),
|
|
Sets.newHashSet(tag.getName()),
|
|
@@ -197,18 +211,16 @@ public class SwaggerExtentionSupport implements ApplicationListener<ContextRefre
|
|
|
Sets.newHashSet(MediaType.create("application", "json").toString()),
|
|
Sets.newHashSet(MediaType.create("application", "json").toString()),
|
|
|
new HashSet<>(),
|
|
new HashSet<>(),
|
|
|
new ArrayList<>(),
|
|
new ArrayList<>(),
|
|
|
- new ArrayList<>(),
|
|
|
|
|
|
|
+ parameters,
|
|
|
Sets.newHashSet(v200, v401, v403, v404),
|
|
Sets.newHashSet(v200, v401, v403, v404),
|
|
|
"",
|
|
"",
|
|
|
false,
|
|
false,
|
|
|
new ArrayList<>()
|
|
new ArrayList<>()
|
|
|
);
|
|
);
|
|
|
- */
|
|
|
|
|
|
|
|
|
|
- operations.add(operaGet);
|
|
|
|
|
- //operations.add(operaPost);
|
|
|
|
|
|
|
+ operations.add(operaPost);
|
|
|
|
|
|
|
|
- String url = "/" + beanName + "?invoke=" + methodName;
|
|
|
|
|
|
|
+ String url = "/appsapi/" + optGroup + "/" + methodName;
|
|
|
apis1.add(new ApiDescription(groupName,
|
|
apis1.add(new ApiDescription(groupName,
|
|
|
url,
|
|
url,
|
|
|
beanName+"." + methodName,
|
|
beanName+"." + methodName,
|