From b5a06b9faf5d0921374db6ba679031c25409710e Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 22 Aug 2019 20:12:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E6=A1=A3=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sop/websiteserver/manager/SwaggerDocParser.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 7435df42..c75e22bf 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 @@ -203,7 +203,18 @@ public class SwaggerDocParser implements DocParser { String ref = Optional.ofNullable(docInfo.getJSONObject("responses")) .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("200"))) .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getJSONObject("schema"))) - .flatMap(jsonObject -> Optional.ofNullable(jsonObject.getString("originalRef"))) + .flatMap(jsonObject -> { + // #/definitions/Category + String $ref = jsonObject.getString("$ref"); + if ($ref == null) { + return Optional.empty(); + } + int index = $ref.lastIndexOf("/"); + if (index > -1) { + $ref = $ref.substring(index + 1); + } + return Optional.of($ref); + }) .orElse(""); return ref; }