diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java index 5a8b51e0e7..7819b02cd7 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java @@ -262,7 +262,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { if (model != null) { propertyList.add(getBodyParameters(model.getProperties(), refSet)); } else { - propertyList.add(new JSONObject()); + propertyList.add(new JSONObject(true)); } } return propertyList.toString(); @@ -278,7 +278,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { } private JSONObject getBodyParameters(Map properties, HashSet refSet) { - JSONObject jsonObject = new JSONObject(); + JSONObject jsonObject = new JSONObject(true); if (properties != null) { properties.forEach((key, value) -> { if (value instanceof ObjectProperty) { @@ -301,7 +301,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { if (model != null) { propertyList.add(getBodyParameters(model.getProperties(), refSet)); } else { - propertyList.add(new JSONObject()); + propertyList.add(new JSONObject(true)); } jsonObject.put(key, propertyList); } else if (items instanceof ObjectProperty) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java index 358ab56d8c..261260c0f1 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java @@ -340,12 +340,12 @@ public class Swagger3Parser extends SwaggerAbstractParser { private Object parseSchema(Schema schema, Set refSet, Map infoMap) { if (schema == null) { - return new JSONObject(); + return new JSONObject(true); } infoMap.put(schema.getName(), schema); if (StringUtils.isNotBlank(schema.get$ref())) { if (refSet.contains(schema.get$ref())) { - return new JSONObject(); + return new JSONObject(true); } refSet.add(schema.get$ref()); Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, infoMap); @@ -386,7 +386,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { if (MapUtils.isEmpty(properties)) { return null; } - JSONObject jsonObject = new JSONObject(); + JSONObject jsonObject = new JSONObject(true); properties.forEach((key, value) -> { jsonObject.put(key, parseSchema(value, refSet, infoMap)); });