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 3c09da6040..5ca0bcde61 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 @@ -736,7 +736,9 @@ public class Swagger3Parser extends SwaggerAbstractParser { } catch (Exception e1) { // 若请求体 json 不合法,则忽略错误,原样字符串导出/导入 bodyInfo = new JSONObject(); ((JSONObject) bodyInfo).put("type", "string"); - ((JSONObject) bodyInfo).put("example", body.get("raw").toString()); + if (body != null && body.get("raw") != null) { + ((JSONObject) bodyInfo).put("example", body.get("raw").toString()); + } } } else if(bodyType.equals("XML")) { String xmlText = body.getString("raw");