diff --git a/pom.xml b/pom.xml index 50a99f1..eb51101 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ com.github.shalousun common-util - 2.0.5 + 2.0.6 com.google.code.gson diff --git a/src/main/java/com/power/doc/builder/OpenApiBuilder.java b/src/main/java/com/power/doc/builder/OpenApiBuilder.java index cd2626e..a08715a 100644 --- a/src/main/java/com/power/doc/builder/OpenApiBuilder.java +++ b/src/main/java/com/power/doc/builder/OpenApiBuilder.java @@ -29,12 +29,10 @@ import com.power.common.util.FileUtil; import com.power.common.util.StringUtil; import com.power.doc.constants.DocGlobalConstants; import com.power.doc.constants.Methods; -import com.power.doc.constants.TornaConstants; import com.power.doc.model.*; import com.power.doc.template.SpringBootDocBuildTemplate; import com.power.doc.utils.DocUtil; import com.thoughtworks.qdox.JavaProjectBuilder; -import jdk.nashorn.internal.runtime.GlobalConstants; import java.util.*; @@ -283,7 +281,7 @@ public class OpenApiBuilder { /** * content body 的schema 信息 * - * @param apiMethodDoc 请求方法参数 + * @param apiMethodDoc 请求方法参数 去除server * @param isRep 是否是返回数据 * @return */ @@ -297,8 +295,8 @@ public class OpenApiBuilder { String requestRef = "#/components/schemas/" + apiMethodDoc.getPath().replaceAll(PATH_REGEX, "_") + "request"; //如果是数组类型 - if(TornaConstants.ARRAY.equals(apiMethodDoc.getType())){ - schema.put("type",TornaConstants.ARRAY); + if(DocGlobalConstants.ARRAY.equals(apiMethodDoc.getType())){ + schema.put("type",DocGlobalConstants.ARRAY); if (isRep) { innerScheme.put("$ref", responseRef); } else { diff --git a/src/main/java/com/power/doc/constants/DocGlobalConstants.java b/src/main/java/com/power/doc/constants/DocGlobalConstants.java index 167029f..45f6638 100644 --- a/src/main/java/com/power/doc/constants/DocGlobalConstants.java +++ b/src/main/java/com/power/doc/constants/DocGlobalConstants.java @@ -200,4 +200,6 @@ public interface DocGlobalConstants { String YAPI_JSON = "/yapi.json"; String DUBBO_SWAGGER = "org.apache.dubbo.rpc.protocol.rest.integration.swagger.DubboSwaggerApiListingResource"; + + String ARRAY = "array"; } diff --git a/src/main/java/com/power/doc/helper/JsonBuildHelper.java b/src/main/java/com/power/doc/helper/JsonBuildHelper.java index 996493b..38ffb0a 100644 --- a/src/main/java/com/power/doc/helper/JsonBuildHelper.java +++ b/src/main/java/com/power/doc/helper/JsonBuildHelper.java @@ -163,7 +163,7 @@ public class JsonBuildHelper { data.append("{\"mapKey\":{}}"); return data.toString(); } - if (!DocGlobalConstants.JAVA_STRING_FULLY.equals(getKeyValType[0])) { + if ((!DocGlobalConstants.JAVA_STRING_FULLY.equals(getKeyValType[0])) && apiConfig.isStrict()) { throw new RuntimeException("Map's key can only use String for json,but you use " + getKeyValType[0]); } String gicName = gNameTemp.substring(gNameTemp.indexOf(",") + 1, gNameTemp.lastIndexOf(">"));