refactor: swagger导入body参数的顺序不变

This commit is contained in:
AnAngle 2021-09-14 15:46:38 +08:00 committed by jianxing
parent eab143abfb
commit 35109cee86
2 changed files with 6 additions and 6 deletions

View File

@ -262,7 +262,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
if (model != null) {
propertyList.add(getBodyParameters(model.getProperties(), refSet));
} else {
propertyList.add(new JSONObject());
propertyList.add(new JSONObject(true));
}
}
return propertyList.toString();
@ -278,7 +278,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
}
private JSONObject getBodyParameters(Map<String, Property> properties, HashSet<String> refSet) {
JSONObject jsonObject = new JSONObject();
JSONObject jsonObject = new JSONObject(true);
if (properties != null) {
properties.forEach((key, value) -> {
if (value instanceof ObjectProperty) {
@ -301,7 +301,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
if (model != null) {
propertyList.add(getBodyParameters(model.getProperties(), refSet));
} else {
propertyList.add(new JSONObject());
propertyList.add(new JSONObject(true));
}
jsonObject.put(key, propertyList);
} else if (items instanceof ObjectProperty) {

View File

@ -340,12 +340,12 @@ public class Swagger3Parser extends SwaggerAbstractParser {
private Object parseSchema(Schema schema, Set<String> refSet, Map<String, Schema> infoMap) {
if (schema == null) {
return new JSONObject();
return new JSONObject(true);
}
infoMap.put(schema.getName(), schema);
if (StringUtils.isNotBlank(schema.get$ref())) {
if (refSet.contains(schema.get$ref())) {
return new JSONObject();
return new JSONObject(true);
}
refSet.add(schema.get$ref());
Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, infoMap);
@ -386,7 +386,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
if (MapUtils.isEmpty(properties)) {
return null;
}
JSONObject jsonObject = new JSONObject();
JSONObject jsonObject = new JSONObject(true);
properties.forEach((key, value) -> {
jsonObject.put(key, parseSchema(value, refSet, infoMap));
});