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; }