mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-06-05 13:29:29 +08:00
兼容1.x版本
This commit is contained in:
@@ -7,10 +7,7 @@ import org.ssssssss.magicapi.adapter.Resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -27,7 +24,7 @@ public class ZipResource implements Resource {
|
||||
private Resource parent;
|
||||
|
||||
public ZipResource(InputStream is) throws IOException {
|
||||
cachedContent = new HashMap<>();
|
||||
cachedContent = new TreeMap<>();
|
||||
try (ZipArchiveInputStream zis = new ZipArchiveInputStream(is)) {
|
||||
ArchiveEntry entry;
|
||||
byte[] buf = new byte[4096];
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ApiInfo extends PathMagicEntity {
|
||||
this.paths = paths;
|
||||
}
|
||||
|
||||
public Map<String, String> getOptionMap() {
|
||||
public Map<String, String> options() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (this.jsonNode == null) {
|
||||
return null;
|
||||
@@ -110,17 +110,22 @@ public class ApiInfo extends PathMagicEntity {
|
||||
} else {
|
||||
this.jsonNode.fieldNames().forEachRemaining(it -> map.put(it, this.jsonNode.get(it).asText()));
|
||||
}
|
||||
// MagicRequestDynamicMappingRegistry.findGroups(this.groupId)
|
||||
// .stream()
|
||||
// .flatMap(it -> it.getOptions().stream())
|
||||
// .forEach(option -> {
|
||||
// if (!map.containsKey(option.getName())) {
|
||||
// map.put(option.getName(), String.valueOf(option.getValue()));
|
||||
// }
|
||||
// });
|
||||
MagicConfiguration.getMagicResourceService().getGroupsByFileId(this.groupId)
|
||||
.stream()
|
||||
.flatMap(it -> it.getOptions().stream())
|
||||
.forEach(option -> {
|
||||
if (!map.containsKey(option.getName())) {
|
||||
map.put(option.getName(), String.valueOf(option.getValue()));
|
||||
}
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
// 兼容1.x处理。
|
||||
public void setOptionMap(Map<String, Object> optionMap) {
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
@@ -137,6 +142,11 @@ public class ApiInfo extends PathMagicEntity {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public void setOption(String json) {
|
||||
this.options = JsonUtils.readValue(Objects.toString(json, "[]"), new TypeReference<List<Option>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public List<Parameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
@@ -145,11 +155,6 @@ public class ApiInfo extends PathMagicEntity {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public void setRequestHeader(String requestHeader) {
|
||||
this.headers = JsonUtils.readValue(Objects.toString(requestHeader, "[]"), new TypeReference<List<Header>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public List<Header> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user