From 709302218e4a0931e1823ea5a523d2e96306055d Mon Sep 17 00:00:00 2001 From: tanghc Date: Wed, 17 Apr 2019 09:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DOptional.of=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sop/websiteserver/manager/DocManagerImpl.java | 12 ------------ .../sop/websiteserver/manager/SwaggerDocParser.java | 9 ++++++--- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java index d829ca9e..95fd61d5 100644 --- a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java +++ b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java @@ -66,18 +66,6 @@ public class DocManagerImpl implements DocManager { ServiceInfoVO serviceInfoVo = entry.getValue().get(0); loadDocInfo(serviceInfoVo); } -// Map itemMap = docDefinitionMap.values() -// .stream() -// .map(DocInfo::getDocModuleList) -// .map(list->{ -// for (DocModule docModule : list) { -// -// } -// }) -// .map(DocModule::getDocItems) -// .flatMap(docItems -> docItems.stream()) -// .collect(Collectors.toMap(DocItem::getNameVersion, Function.identity())); -// this.docItemMap.putAll(itemMap); } catch (IOException e) { log.error("加载失败", e); } diff --git a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java index 0bba3cab..85000a79 100644 --- a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java +++ b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java @@ -15,6 +15,8 @@ import java.util.Set; import java.util.stream.Collectors; /** + * 解析swagger的json内容 + * * @author tanghc */ public class SwaggerDocParser implements DocParser { @@ -103,10 +105,11 @@ public class SwaggerDocParser implements DocParser { protected String getResponseRef(JSONObject docInfo) { String ref = Optional.ofNullable(docInfo.getJSONObject("responses")) - .flatMap(jsonObject -> Optional.of(jsonObject.getJSONObject("200"))) - .flatMap(jsonObject -> Optional.of(jsonObject.getJSONObject("schema"))) - .flatMap(jsonObject -> Optional.of(jsonObject.getString("originalRef"))) + .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("200"))) + .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("schema"))) + .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getString("originalRef"))) .orElse(""); return ref; } + }