From eeda6b36f292950ca2a551c0556d486b0de7701c Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 17 Nov 2020 19:19:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AD=97=E6=AE=B5=20required=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=9C=AA=E8=8E=B7=E5=8F=96=E5=88=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gitee/sop/websiteserver/manager/SwaggerDocParser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java b/sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java index b4c1de0a..3fe8947a 100644 --- a/sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java +++ b/sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java @@ -220,6 +220,7 @@ public class SwaggerDocParser implements DocParser { JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref); String className = responseObject.getString("title"); JSONObject extProperties = docRoot.getJSONObject(className); + JSONArray requiredProperties = responseObject.getJSONArray("required"); JSONObject properties = responseObject.getJSONObject("properties"); List docParameterList = new ArrayList<>(); if (properties == null) { @@ -236,6 +237,8 @@ public class SwaggerDocParser implements DocParser { JSONObject fieldInfo = properties.getJSONObject(fieldName); DocParameter docParameter = fieldInfo.toJavaObject(DocParameter.class); docParameter.setName(fieldName); + docParameter.setRequired( + com.alibaba.nacos.common.utils.CollectionUtils.contains(requiredProperties, fieldName)); if (extProperties != null) { JSONObject prop = extProperties.getJSONObject(fieldName); if (prop != null) {