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 77cd63ef82..72506c3151 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 @@ -434,6 +434,9 @@ public class Swagger3Parser implements ImportParser { queryParam.setMinLength(queryParameter.getSchema().getMinLength()); queryParam.setMaxLength(queryParameter.getSchema().getMaxLength()); } + if (queryParameter.getExample() != null) { + queryParam.setValue(getDefaultObjectValue(queryParameter.getExample())); + } arguments.add(queryParam); } @@ -445,6 +448,9 @@ public class Swagger3Parser implements ImportParser { if (cookieParameter.getSchema() != null) { headerParams.setValue(getDefaultObjectValue(cookieParameter.getSchema().getExample())); } + if (cookieParameter.getExample() != null) { + headerParams.setValue(getDefaultObjectValue(cookieParameter.getExample())); + } headers.add(headerParams); } @@ -455,6 +461,9 @@ public class Swagger3Parser implements ImportParser { if (headerParameter.getSchema() != null) { headerParams.setValue(getDefaultObjectValue(headerParameter.getSchema().getExample())); } + if (headerParameter.getExample() != null) { + headerParams.setValue(getDefaultObjectValue(headerParameter.getExample())); + } headers.add(headerParams); } @@ -470,6 +479,9 @@ public class Swagger3Parser implements ImportParser { restParam.setMinLength(parameter.getSchema().getMinLength()); restParam.setMaxLength(parameter.getSchema().getMaxLength()); } + if (parameter.getExample() != null) { + restParam.setValue(getDefaultObjectValue(parameter.getExample())); + } rest.add(restParam); }