fix: swagger 参数描述中带有/导入报错

This commit is contained in:
chenjianxing 2020-08-05 20:06:21 +08:00
parent ec3276edff
commit cef3c8dea7
1 changed files with 8 additions and 1 deletions

View File

@ -130,8 +130,15 @@ public class Swagger2Parser extends ApiImportAbstractParser {
Model schema = bodyParameter.getSchema(); Model schema = bodyParameter.getSchema();
if (schema instanceof RefModel) { if (schema instanceof RefModel) {
String simpleRef = "";
RefModel refModel = (RefModel) bodyParameter.getSchema(); RefModel refModel = (RefModel) bodyParameter.getSchema();
Model model = definitions.get(refModel.getSimpleRef()); String originalRef = refModel.getOriginalRef();
if (refModel.getOriginalRef().split("/").length > 3) {
simpleRef = originalRef.replace("#/definitions/", "");
} else {
simpleRef = refModel.getSimpleRef();
}
Model model = definitions.get(simpleRef);
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions); JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions);
body.setRaw(bodyParameters.toJSONString()); body.setRaw(bodyParameters.toJSONString());
} else if (schema instanceof ArrayModel) { } else if (schema instanceof ArrayModel) {