fix: swagger 3 堆栈溢出

This commit is contained in:
chenjianxing 2020-12-31 10:48:01 +08:00
parent 5977cfca59
commit ab495f21f4
2 changed files with 5 additions and 2 deletions

View File

@ -51,7 +51,7 @@ public class Swagger3Parser extends ApiImportAbstractParser {
public ApiDefinitionImport parse(String sourceStr, ApiTestImportRequest request) { public ApiDefinitionImport parse(String sourceStr, ApiTestImportRequest request) {
SwaggerParseResult result; SwaggerParseResult result;
if (StringUtils.isNotBlank(request.getSwaggerUrl())) { if (StringUtils.isNotBlank(request.getSwaggerUrl())) {
result = new OpenAPIParser().readLocation("https://petstore3.swagger.io/api/v3/openapi.json", null, null); result = new OpenAPIParser().readLocation(request.getSwaggerUrl(), null, null);
} else { } else {
result = new OpenAPIParser().readContents(sourceStr, null, null); result = new OpenAPIParser().readContents(sourceStr, null, null);
} }
@ -317,6 +317,9 @@ public class Swagger3Parser extends ApiImportAbstractParser {
private Object parseSchema(Schema schema, Set<String> refSet, Map<String, String> binaryKeyMap) { private Object parseSchema(Schema schema, Set<String> refSet, Map<String, String> binaryKeyMap) {
if (StringUtils.isNotBlank(schema.get$ref())) { if (StringUtils.isNotBlank(schema.get$ref())) {
if (refSet.contains(schema.get$ref())) {
return new JSONObject();
}
refSet.add(schema.get$ref()); refSet.add(schema.get$ref());
Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, binaryKeyMap); Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, binaryKeyMap);
return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult; return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult;

View File

@ -194,7 +194,7 @@
}, },
refresh() { refresh() {
this.list(); this.list();
this.$emit("refreshTable"); this.$emit("refresh");
}, },
} }
} }