fix(接口测试): 导入失败

--bug=1045492 --user=王旭 [接口测试]github#32739相同的swagger文件导入接口定义,在V2导入成功,V3导入失败 https://www.tapd.cn/55049933/s/1566276
This commit is contained in:
WangXu10 2024-08-20 20:32:34 +08:00 committed by Craftsman
parent d370961a28
commit f45bf56307
1 changed files with 6 additions and 2 deletions

View File

@ -303,7 +303,9 @@ public class Swagger3Parser extends ApiImportAbstractParser<ApiDefinitionImport>
case MediaType.TEXT_PLAIN_VALUE -> { case MediaType.TEXT_PLAIN_VALUE -> {
body.setBodyType(Body.BodyType.RAW.name()); body.setBodyType(Body.BodyType.RAW.name());
RawBody rawBody = new RawBody(); 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); body.setRawBody(rawBody);
} }
default -> body.setBodyType(Body.BodyType.NONE.name()); default -> body.setBodyType(Body.BodyType.NONE.name());
@ -352,7 +354,9 @@ public class Swagger3Parser extends ApiImportAbstractParser<ApiDefinitionImport>
case MediaType.TEXT_PLAIN_VALUE -> { case MediaType.TEXT_PLAIN_VALUE -> {
body.setBodyType(Body.BodyType.RAW.name()); body.setBodyType(Body.BodyType.RAW.name());
RawBody rawBody = new RawBody(); 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); body.setRawBody(rawBody);
} }
default -> body.setBodyType(Body.BodyType.NONE.name()); default -> body.setBodyType(Body.BodyType.NONE.name());