fix(接口测试): 修复swagger定时同步值为null的缺陷
--bug=1024805 --user=王孝刚 【接口测试】swagger定时导入-后端报错-空值显示为null https://www.tapd.cn/55049933/s/1355712
This commit is contained in:
parent
17581ff415
commit
fa10011aa9
|
@ -7,9 +7,9 @@ import io.metersphere.api.dto.definition.request.variable.JsonSchemaItem;
|
||||||
import io.metersphere.api.dto.definition.response.HttpResponse;
|
import io.metersphere.api.dto.definition.response.HttpResponse;
|
||||||
import io.metersphere.api.dto.scenario.Body;
|
import io.metersphere.api.dto.scenario.Body;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.commons.constants.RequestTypeConstants;
|
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.commons.constants.PropertyConstant;
|
import io.metersphere.commons.constants.PropertyConstant;
|
||||||
|
import io.metersphere.commons.constants.RequestTypeConstants;
|
||||||
import io.metersphere.commons.constants.SwaggerParameterType;
|
import io.metersphere.commons.constants.SwaggerParameterType;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.JSON;
|
import io.metersphere.commons.utils.JSON;
|
||||||
|
@ -265,7 +265,9 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
||||||
|
|
||||||
private void parsePathParameters(Parameter parameter, List<KeyValue> rests) {
|
private void parsePathParameters(Parameter parameter, List<KeyValue> rests) {
|
||||||
PathParameter pathParameter = (PathParameter) parameter;
|
PathParameter pathParameter = (PathParameter) parameter;
|
||||||
rests.add(new KeyValue(pathParameter.getName(), getDefaultValue(pathParameter), getDefaultStringValue(parameter.getDescription()), pathParameter.getRequired()));
|
rests.add(new KeyValue(pathParameter.getName(),
|
||||||
|
pathParameter.getExample() != null ? String.valueOf(pathParameter.getExample()) : null,
|
||||||
|
getDefaultStringValue(parameter.getDescription()), pathParameter.getRequired()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultValue(AbstractSerializableParameter parameter) {
|
private String getDefaultValue(AbstractSerializableParameter parameter) {
|
||||||
|
@ -281,12 +283,16 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
||||||
|
|
||||||
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
CookieParameter cookieParameter = (CookieParameter) parameter;
|
CookieParameter cookieParameter = (CookieParameter) parameter;
|
||||||
addCookie(headers, cookieParameter.getName(), getDefaultValue(cookieParameter), getDefaultStringValue(cookieParameter.getDescription()), parameter.getRequired());
|
addCookie(headers, cookieParameter.getName(),
|
||||||
|
cookieParameter.getExample() != null ? String.valueOf(cookieParameter.getExample()) : null,
|
||||||
|
getDefaultStringValue(cookieParameter.getDescription()), parameter.getRequired());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
||||||
addHeader(headers, headerParameter.getName(), getDefaultValue(headerParameter), getDefaultStringValue(headerParameter.getDescription()),
|
addHeader(headers, headerParameter.getName(),
|
||||||
|
headerParameter.getExample() != null ? String.valueOf(headerParameter.getExample()) : null,
|
||||||
|
getDefaultStringValue(headerParameter.getDescription()),
|
||||||
StringUtils.EMPTY, parameter.getRequired());
|
StringUtils.EMPTY, parameter.getRequired());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,8 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
|
|
||||||
private void parsePathParameters(Parameter parameter, List<KeyValue> rests) {
|
private void parsePathParameters(Parameter parameter, List<KeyValue> rests) {
|
||||||
PathParameter pathParameter = (PathParameter) parameter;
|
PathParameter pathParameter = (PathParameter) parameter;
|
||||||
rests.add(new KeyValue(pathParameter.getName(), pathParameter.getExample() != null ? String.valueOf(pathParameter.getExample()) : null,
|
rests.add(new KeyValue(pathParameter.getName(),
|
||||||
|
pathParameter.getExample() != null ? String.valueOf(pathParameter.getExample()) : null,
|
||||||
getDefaultStringValue(parameter.getDescription())));
|
getDefaultStringValue(parameter.getDescription())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,13 +239,15 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
|
|
||||||
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
CookieParameter cookieParameter = (CookieParameter) parameter;
|
CookieParameter cookieParameter = (CookieParameter) parameter;
|
||||||
addCookie(headers, cookieParameter.getName(), cookieParameter.getExample() != null ? String.valueOf(cookieParameter.getExample()) : null,
|
addCookie(headers, cookieParameter.getName(),
|
||||||
|
cookieParameter.getExample() != null ? String.valueOf(cookieParameter.getExample()) : null,
|
||||||
getDefaultStringValue(cookieParameter.getDescription()), parameter.getRequired());
|
getDefaultStringValue(cookieParameter.getDescription()), parameter.getRequired());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
||||||
addHeader(headers, headerParameter.getName(), headerParameter.getExample() != null ? String.valueOf(headerParameter.getExample()) : null,
|
addHeader(headers, headerParameter.getName(),
|
||||||
|
headerParameter.getExample() != null ? String.valueOf(headerParameter.getExample()) : null,
|
||||||
getDefaultStringValue(headerParameter.getDescription()), StringUtils.EMPTY, parameter.getRequired());
|
getDefaultStringValue(headerParameter.getDescription()), StringUtils.EMPTY, parameter.getRequired());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue