Skip to content

Commit 8996fcf

Browse files
committed
修复#11
1 parent 304adf0 commit 8996fcf

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.github.nobugboy</groupId>
1212
<artifactId>ydoc-spring-boot-starter</artifactId>
13-
<version>1.0.8</version>
13+
<version>1.0.9</version>
1414
<name>ydoc-spring-boot-starter</name>
1515
<packaging>jar</packaging>
1616
<description>YDoc一款低侵入性、简洁并同时支持SwaggerUi和YApi的文档生成器</description>

src/main/java/com/github/ydoc/core/RequestTypeMatchingSwagger.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ public static void returnBuild(Method method, JSONObject json) {
185185
private static void get(String name, String path, JSONObject api, Method method, String outPath, String tag) {
186186
// 方法对象
187187
JSONObject apiMethod = Factory.get();
188-
api.put(outPath + path, apiMethod);
188+
if(api.containsKey(outPath + path)){
189+
//路径已经存在
190+
apiMethod = (JSONObject)api.get(outPath + path);
191+
}else{
192+
api.put(outPath + path, apiMethod);
193+
}
189194
// body
190195
JSONObject content = Factory.get();
191196
apiMethod.put("get", content);
@@ -273,7 +278,12 @@ private static void get(String name, String path, JSONObject api, Method method,
273278
private static void post(String name, String path, JSONObject api, Method method, String outPath, String tag) {
274279
// 方法对象
275280
JSONObject apiMethod = Factory.get();
276-
api.put(outPath + path, apiMethod);
281+
if(api.containsKey(outPath + path)){
282+
//路径已经存在
283+
apiMethod = (JSONObject)api.get(outPath + path);
284+
}else{
285+
api.put(outPath + path, apiMethod);
286+
}
277287
// body
278288
JSONObject content = Factory.get();
279289
apiMethod.put("post", content);
@@ -293,7 +303,12 @@ private static void post(String name, String path, JSONObject api, Method method
293303
private static void delete(String name, String path, JSONObject api, Method method, String outPath, String tag) {
294304
// 方法对象
295305
JSONObject apiMethod = Factory.get();
296-
api.put(outPath + path, apiMethod);
306+
if(api.containsKey(outPath + path)){
307+
//路径已经存在
308+
apiMethod = (JSONObject)api.get(outPath + path);
309+
}else{
310+
api.put(outPath + path, apiMethod);
311+
}
297312
// body
298313
JSONObject content = Factory.get();
299314
apiMethod.put("delete", content);
@@ -313,7 +328,12 @@ private static void delete(String name, String path, JSONObject api, Method meth
313328
private static void put(String name, String path, JSONObject api, Method method, String outPath, String tag) {
314329
// 方法对象
315330
JSONObject apiMethod = Factory.get();
316-
api.put(outPath + path, apiMethod);
331+
if(api.containsKey(outPath + path)){
332+
//路径已经存在
333+
apiMethod = (JSONObject)api.get(outPath + path);
334+
}else{
335+
api.put(outPath + path, apiMethod);
336+
}
317337
// body
318338
JSONObject content = Factory.get();
319339
apiMethod.put("put", content);

src/main/java/com/github/ydoc/core/ScanControllerSwagger.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public void scan() {
6262
swagger.setBasePath(basePath.get());
6363
List<Swagger.Tag> tags = new ArrayList<>();
6464
JSONObject paths = Factory.get();
65+
swagger.setPaths(paths);
6566
for (Map.Entry<String, Object> object : restControllerMap.entrySet()) {
6667
// 组装swagger-api
6768
Class<?> aClass = object.getValue().getClass();
@@ -84,7 +85,7 @@ public void scan() {
8485
RequestTypeMatchingSwagger.matching(paths, method, outPath, object.getKey());
8586
}
8687
}
87-
swagger.setPaths(paths);
88+
8889
swagger.setTags(tags);
8990
Factory.json = JSON.toJSONString(swagger);
9091

@@ -182,13 +183,10 @@ private boolean access() {
182183
&& StringUtils.hasText(propertiesConfig.getYapiUserPassword());
183184
}
184185
private void printBanner(){
185-
System.out.println("__ __ ______ ____ ____ ");
186-
System.out.println(") \\ / ( (_ __ \\ / __ \\ / ___) ");
187-
System.out.println(" \\ \\ / / ) ) \\ \\ / / \\ \\ / / ");
188-
System.out.println(" \\ \\/ / ( ( ) ) ( () () ) ( ( ");
189-
System.out.println(" \\ / ) ) ) ) ( () () ) ( ( ");
190-
System.out.println(" \\ / ) ) ) ) ( () () ) ( ( ");
191-
System.out.println(" )( / /__/ / \\ \\__/ / \\ \\___ ");
192-
System.out.println(" /__\\ (______/ \\____/ \\____)");
186+
System.out.println(" _ _ ____ _____ ___ ");
187+
System.out.println("( \\/ )( _ \\( _ )/ __)");
188+
System.out.println(" \\ / )(_) ))(_)(( (__ ");
189+
System.out.println(" (__) (____/(_____)\\___)");
190+
System.out.println(" v1.0.9 ");
193191
}
194192
}

0 commit comments

Comments
 (0)