mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
fix: 字段 required 属性未获取到值
This commit is contained in:
@@ -220,6 +220,7 @@ public class SwaggerDocParser implements DocParser {
|
|||||||
JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref);
|
JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref);
|
||||||
String className = responseObject.getString("title");
|
String className = responseObject.getString("title");
|
||||||
JSONObject extProperties = docRoot.getJSONObject(className);
|
JSONObject extProperties = docRoot.getJSONObject(className);
|
||||||
|
JSONArray requiredProperties = responseObject.getJSONArray("required");
|
||||||
JSONObject properties = responseObject.getJSONObject("properties");
|
JSONObject properties = responseObject.getJSONObject("properties");
|
||||||
List<DocParameter> docParameterList = new ArrayList<>();
|
List<DocParameter> docParameterList = new ArrayList<>();
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
@@ -236,6 +237,8 @@ public class SwaggerDocParser implements DocParser {
|
|||||||
JSONObject fieldInfo = properties.getJSONObject(fieldName);
|
JSONObject fieldInfo = properties.getJSONObject(fieldName);
|
||||||
DocParameter docParameter = fieldInfo.toJavaObject(DocParameter.class);
|
DocParameter docParameter = fieldInfo.toJavaObject(DocParameter.class);
|
||||||
docParameter.setName(fieldName);
|
docParameter.setName(fieldName);
|
||||||
|
docParameter.setRequired(
|
||||||
|
com.alibaba.nacos.common.utils.CollectionUtils.contains(requiredProperties, fieldName));
|
||||||
if (extProperties != null) {
|
if (extProperties != null) {
|
||||||
JSONObject prop = extProperties.getJSONObject(fieldName);
|
JSONObject prop = extProperties.getJSONObject(fieldName);
|
||||||
if (prop != null) {
|
if (prop != null) {
|
||||||
|
Reference in New Issue
Block a user