diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java index a42898693f..9308b49a61 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java @@ -303,7 +303,9 @@ public class Swagger3Parser extends ApiImportAbstractParser case MediaType.TEXT_PLAIN_VALUE -> { body.setBodyType(Body.BodyType.RAW.name()); RawBody rawBody = new RawBody(); - rawBody.setValue(value.getSchema().getExample().toString()); + if (ObjectUtils.isNotEmpty(value.getSchema().getExample())) { + rawBody.setValue(value.getSchema().getExample().toString()); + } body.setRawBody(rawBody); } default -> body.setBodyType(Body.BodyType.NONE.name()); @@ -352,7 +354,9 @@ public class Swagger3Parser extends ApiImportAbstractParser case MediaType.TEXT_PLAIN_VALUE -> { body.setBodyType(Body.BodyType.RAW.name()); RawBody rawBody = new RawBody(); - rawBody.setValue(value.getSchema().getExample().toString()); + if (ObjectUtils.isNotEmpty(value.getSchema().getExample())) { + rawBody.setValue(value.getSchema().getExample().toString()); + } body.setRawBody(rawBody); } default -> body.setBodyType(Body.BodyType.NONE.name());