From f45bf56307eed95434e0ff90664a8e53ba28633a Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 20 Aug 2024 20:32:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1045492 --user=王旭 [接口测试]github#32739相同的swagger文件导入接口定义,在V2导入成功,V3导入失败 https://www.tapd.cn/55049933/s/1566276 --- .../io/metersphere/api/parser/api/Swagger3Parser.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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());