fix(接口测试): 解决swagger3导入时高级配置的问题
--user=郭雨琦 --bug=1014740 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014740
This commit is contained in:
parent
2306bfda73
commit
d380b20a6d
|
@ -456,6 +456,9 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
|
||||
private JsonSchemaItem parseSchema(Schema schema, Set<String> refSet) {
|
||||
if (schema == null) return null;
|
||||
if (StringUtils.isBlank(schema.get$ref()) && schema.getProperties() == null && refSet.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
JsonSchemaItem item = new JsonSchemaItem();
|
||||
if (schema.getRequired() != null) {
|
||||
item.setRequired(schema.getRequired());
|
||||
|
@ -478,16 +481,28 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
} else if (schema instanceof ObjectSchema) {
|
||||
item.setType("object");
|
||||
item.setProperties(parseSchemaProperties(schema, refSet));
|
||||
} else if (schema instanceof StringSchema) {
|
||||
item.setType("string");
|
||||
} else if (schema instanceof IntegerSchema) {
|
||||
item.setType("integer");
|
||||
} else if (schema instanceof NumberSchema) {
|
||||
item.setType("number");
|
||||
} else if (schema instanceof BooleanSchema) {
|
||||
item.setType("boolean");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (schema.getExample() != null) {
|
||||
item.getMock().put("mock", schema.getExample());
|
||||
} else {
|
||||
item.getMock().put("mock", "");
|
||||
}
|
||||
|
||||
item.setDescription(schema.getDescription());
|
||||
item.setPattern(schema.getPattern());
|
||||
item.setMaxLength(schema.getMaxLength());
|
||||
item.setMinLength(schema.getMinLength());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,11 @@ public class JsonSchemaItem {
|
|||
private Map<String, Object> mock;
|
||||
private Map<String, JsonSchemaItem> properties;
|
||||
private JsonSchemaItem additionalProperties;
|
||||
private List<String> required ;
|
||||
private List<String> required;
|
||||
private String pattern;
|
||||
private Integer maxLength;
|
||||
private Integer minLength;
|
||||
|
||||
|
||||
@JSONField(name = "$schema")
|
||||
private String schema;
|
||||
|
|
|
@ -222,11 +222,13 @@ export default {
|
|||
const MsConvert = new Convert();
|
||||
|
||||
if (this.body.format === 'JSON-SCHEMA') {
|
||||
if (this.body.raw && !this.body.jsonSchema) {
|
||||
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
|
||||
} else {
|
||||
let data = MsConvert.format(JSON.parse(this.body.raw));
|
||||
this.body.jsonSchema = this.deepAssign(this.body.jsonSchema, data);
|
||||
if (this.body.raw) {
|
||||
if (!this.body.jsonSchema) {
|
||||
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
|
||||
} else {
|
||||
let data = MsConvert.format(JSON.parse(this.body.raw));
|
||||
this.body.jsonSchema = this.deepAssign(this.body.jsonSchema, data);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.body.jsonSchema) {
|
||||
|
|
Loading…
Reference in New Issue