修复Optional.of异常问题

1.x
tanghc 6 years ago
parent dc00bcad2e
commit 709302218e
  1. 12
      sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java
  2. 9
      sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java

@ -66,18 +66,6 @@ public class DocManagerImpl implements DocManager {
ServiceInfoVO serviceInfoVo = entry.getValue().get(0); ServiceInfoVO serviceInfoVo = entry.getValue().get(0);
loadDocInfo(serviceInfoVo); loadDocInfo(serviceInfoVo);
} }
// Map<String, DocItem> 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) { } catch (IOException e) {
log.error("加载失败", e); log.error("加载失败", e);
} }

@ -15,6 +15,8 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* 解析swagger的json内容
*
* @author tanghc * @author tanghc
*/ */
public class SwaggerDocParser implements DocParser { public class SwaggerDocParser implements DocParser {
@ -103,10 +105,11 @@ public class SwaggerDocParser implements DocParser {
protected String getResponseRef(JSONObject docInfo) { protected String getResponseRef(JSONObject docInfo) {
String ref = Optional.ofNullable(docInfo.getJSONObject("responses")) String ref = Optional.ofNullable(docInfo.getJSONObject("responses"))
.flatMap(jsonObject -> Optional.of(jsonObject.getJSONObject("200"))) .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("200")))
.flatMap(jsonObject -> Optional.of(jsonObject.getJSONObject("schema"))) .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("schema")))
.flatMap(jsonObject -> Optional.of(jsonObject.getString("originalRef"))) .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getString("originalRef")))
.orElse(""); .orElse("");
return ref; return ref;
} }
} }

Loading…
Cancel
Save