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