refactor imports format
This commit is contained in:
parent
10ec54b5cf
commit
0fed5573d5
@ -31,12 +31,12 @@ import cz.trask.migration.model.TokenResponse;
|
||||
public abstract class AbstractProcess {
|
||||
|
||||
private static Logger log = LogManager.getLogger(AbstractProcess.class);
|
||||
|
||||
|
||||
protected static final String PARAM_SOURCE_APIM = "source_apim";
|
||||
protected static final String VERSION_32 = "v32";
|
||||
|
||||
protected ObjectMapper mapper;
|
||||
|
||||
|
||||
protected ObjectMapper mapperYaml;
|
||||
|
||||
protected ConfigManager config = ConfigManager.getInstance();
|
||||
|
||||
@ -239,38 +239,39 @@ public class ImportToApicurio extends AbstractProcess {
|
||||
/* Helper methods */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
private void updateSwagger(ObjectNode swagger, Map<String, Object> apiMap, String description) {
|
||||
// Update "info.description"
|
||||
ObjectNode info = (ObjectNode) swagger.get("info");
|
||||
if (info != null) {
|
||||
info.put("description", description);
|
||||
}
|
||||
private void updateSwagger(ObjectNode swagger, Map<String, Object> apiMap, String description) {
|
||||
// Update "info.description"
|
||||
ObjectNode info = (ObjectNode) swagger.get("info");
|
||||
if (info != null) {
|
||||
info.put("description", description);
|
||||
}
|
||||
|
||||
// Build "servers" array
|
||||
ArrayNode servers = mapper.createArrayNode();
|
||||
// Build "servers" array
|
||||
ArrayNode servers = mapper.createArrayNode();
|
||||
|
||||
List<Map<String, Object>> endpoints = (List<Map<String, Object>>) apiMap.get("endpointURLs");
|
||||
if (endpoints != null) {
|
||||
for (Map<String, Object> env : endpoints) {
|
||||
Map<String, String> urls = (Map<String, String>) env.get("URLs");
|
||||
if (urls == null || urls.isEmpty()) continue;
|
||||
List<Map<String, Object>> endpoints = (List<Map<String, Object>>) apiMap.get("endpointURLs");
|
||||
if (endpoints != null) {
|
||||
for (Map<String, Object> env : endpoints) {
|
||||
Map<String, String> urls = (Map<String, String>) env.get("URLs");
|
||||
if (urls == null || urls.isEmpty())
|
||||
continue;
|
||||
|
||||
ObjectNode server = mapper.createObjectNode();
|
||||
urls.forEach((k, v) -> {
|
||||
if (v != null && !v.isBlank()) {
|
||||
if (k.equals("https") || k.equals("wss")) {
|
||||
server.put("url", v);
|
||||
}
|
||||
}
|
||||
});
|
||||
server.put("description", "Gateway: " + env.getOrDefault("environmentName", ""));
|
||||
servers.add(server);
|
||||
}
|
||||
}
|
||||
ObjectNode server = mapper.createObjectNode();
|
||||
urls.forEach((k, v) -> {
|
||||
if (v != null && !v.isBlank()) {
|
||||
if (k.equals("https") || k.equals("wss")) {
|
||||
server.put("url", v);
|
||||
}
|
||||
}
|
||||
});
|
||||
server.put("description", "Gateway: " + env.getOrDefault("environmentName", ""));
|
||||
servers.add(server);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace "servers" node
|
||||
swagger.set("servers", servers);
|
||||
}
|
||||
// Replace "servers" node
|
||||
swagger.set("servers", servers);
|
||||
}
|
||||
|
||||
private void addSubscriptionsToProps(Map<String, String> props, Map<String, Object> subsMap) {
|
||||
if (subsMap == null || !subsMap.containsKey("list"))
|
||||
@ -315,8 +316,9 @@ public class ImportToApicurio extends AbstractProcess {
|
||||
List<ArtifactReference> references = new ArrayList<>();
|
||||
for (ZipEntryData entry : zipEntries) {
|
||||
String artifactId = api.getName() + "/" + api.getVersion() + "/" + entry.getName();
|
||||
|
||||
//ApiDefinition apiDef = mapper.readValue(entry.getContent(), ApiDefinition.class);
|
||||
|
||||
// ApiDefinition apiDef = mapper.readValue(entry.getContent(),
|
||||
// ApiDefinition.class);
|
||||
|
||||
// Create the artifact (versioned)
|
||||
try (ByteArrayInputStream is = new ByteArrayInputStream(entry.getContent())) {
|
||||
|
||||
@ -77,8 +77,8 @@ public class ZipUtils {
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] prepareApiZipFile32to45(RegistryClient client, SearchedVersion ver, List<ArtifactReference> ref)
|
||||
throws IOException {
|
||||
public static byte[] prepareApiZipFile32to45(RegistryClient client, SearchedVersion ver,
|
||||
List<ArtifactReference> ref) throws IOException {
|
||||
|
||||
String baseDir = ver.getName() + "-" + ver.getVersion() + "/";
|
||||
|
||||
|
||||
@ -79,31 +79,31 @@ public class ApiDefinition {
|
||||
}
|
||||
|
||||
public static class EndpointConfig {
|
||||
public String endpoint_type;
|
||||
public Endpoint sandbox_endpoints;
|
||||
public Endpoint production_endpoints;
|
||||
public EndpointSecurity endpoint_security;
|
||||
public String endpoint_type;
|
||||
public Endpoint sandbox_endpoints;
|
||||
public Endpoint production_endpoints;
|
||||
public EndpointSecurity endpoint_security;
|
||||
|
||||
public static class Endpoint {
|
||||
public String url;
|
||||
}
|
||||
public static class Endpoint {
|
||||
public String url;
|
||||
}
|
||||
|
||||
public static class EndpointSecurity {
|
||||
public SecurityConfig production;
|
||||
public SecurityConfig sandbox;
|
||||
public static class EndpointSecurity {
|
||||
public SecurityConfig production;
|
||||
public SecurityConfig sandbox;
|
||||
|
||||
public static class SecurityConfig {
|
||||
public String password;
|
||||
public String tokenUrl;
|
||||
public String clientId;
|
||||
public String clientSecret;
|
||||
public String customParameters;
|
||||
public String type;
|
||||
public String grantType;
|
||||
public boolean enabled;
|
||||
public String username;
|
||||
}
|
||||
}
|
||||
public static class SecurityConfig {
|
||||
public String password;
|
||||
public String tokenUrl;
|
||||
public String clientId;
|
||||
public String clientSecret;
|
||||
public String customParameters;
|
||||
public String type;
|
||||
public String grantType;
|
||||
public boolean enabled;
|
||||
public String username;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Hlavní pole ---
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user