fix: 接口定义导出swagger报错

This commit is contained in:
chenjianxing 2021-06-10 16:31:31 +08:00 committed by jianxing
parent 74cd21ce5e
commit 5033aa4d2c
1 changed files with 3 additions and 1 deletions

View File

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