Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ under the License.
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>2.16.7.Final</quarkus-plugin.version>
<quarkus-plugin.version>3.20.3</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>2.16.7.Final</quarkus.platform.version>
<quarkus.platform.version>3.20.3</quarkus.platform.version>
<surefire-plugin.version>3.0.0</surefire-plugin.version>
<version.camel-quarkus>2.16.0</version.camel-quarkus>
<version.camel-classic>3.20.5</version.camel-classic>
<version.camel-quarkus>3.20.3</version.camel-quarkus>
<version.camel-classic>4.10.7</version.camel-classic>
<version.camel-kamelet>3.20.4</version.camel-kamelet>
<version.maven-artifact>3.8.6</version.maven-artifact>
</properties>
Expand Down Expand Up @@ -102,10 +102,17 @@ under the License.
<groupId>org.apache.camel.kamelets</groupId>
<artifactId>camel-kamelets-catalog</artifactId>
<version>${version.camel-kamelet}</version>
<exclusions>
<exclusion>
<artifactId>classgraph</artifactId>
<groupId>io.github.classgraph</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>camel-k-model-v1alpha1</artifactId>
<version>6.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down Expand Up @@ -146,6 +153,11 @@ under the License.
<artifactId>camel-openapi-rest-dsl-generator</artifactId>
<version>${version.camel-classic}</version>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.184</version>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/apache/camel/kameleon/WarmUpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package org.apache.camel.kameleon;

import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.runtime.configuration.ProfileManager;
import io.quarkus.vertx.ConsumeEvent;
import io.vertx.core.json.JsonArray;
import io.vertx.mutiny.core.eventbus.EventBus;
Expand All @@ -27,9 +27,9 @@
import org.apache.camel.kameleon.generator.ProjectGeneratorService;
import org.jboss.logging.Logger;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -52,7 +52,7 @@ public class WarmUpService {

void onStart(@Observes StartupEvent ev) {
LOGGER.info("Data warmup start...");
if (!ProfileManager.getLaunchMode().isDevOrTest()) {
if (!LaunchMode.current().isDevOrTest()) {
configurationResource.getKc().getTypes()
.forEach(camelType -> camelType.getVersions()
.forEach(camelVersion -> camelVersion.getJavaVersions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.camel.kameleon.model.CamelComponent;
import org.apache.maven.artifact.versioning.ComparableVersion;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import io.vertx.core.json.JsonArray;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/component")
public class ComponentResource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.camel.kameleon.model.KameletComponent;
import org.apache.camel.kamelets.catalog.KameletsCatalog;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.List;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.camel.catalog.quarkus.QuarkusRuntimeProvider;
import org.apache.camel.kameleon.model.CamelComponent;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.camel.kameleon.model.CamelComponent;
import org.apache.camel.springboot.catalog.SpringBootRuntimeProvider;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -61,9 +61,11 @@ public JsonArray components() throws Exception {

catalog.findOtherNames().forEach(name -> {
String json = catalog.otherJSonSchema(name);
CamelComponent component = getCamelComponent(json, "other");
if (!component.getDeprecated()) {
if(json != null) {
CamelComponent component = getCamelComponent(json, "other");
if (!component.getDeprecated()) {
list.add(component);
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.apache.camel.kameleon.model.KameleonConfiguration;
import org.eclipse.microprofile.config.inject.ConfigProperty;

import javax.enterprise.event.Observes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import jakarta.enterprise.event.Observes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
import java.io.*;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/
package org.apache.camel.kameleon.generator;

import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import java.io.File;

@Path("/generator")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.apache.maven.shared.invoker.*;
import org.codehaus.plexus.util.xml.Xpp3Dom;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.apicurio.datamodels.Library;
import io.apicurio.datamodels.openapi.models.OasDocument;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.OpenAPIV3Parser;
import io.swagger.v3.parser.core.models.SwaggerParseResult;
import org.apache.camel.CamelContext;
import org.apache.camel.generator.openapi.RestDslGenerator;
import org.apache.camel.impl.lw.LightweightCamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

import javax.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;
import java.io.FileNotFoundException;
import java.util.Map;

Expand All @@ -36,10 +38,11 @@ public class RestDslGeneratorService {
public String generate(String filename, String openapi) throws Exception {
System.out.println(filename);
System.out.println(openapi);
final JsonNode node = filename.endsWith("json") ? readNodeFromJson(openapi) : readNodeFromYaml(openapi);
OasDocument document = (OasDocument) Library.readDocument(node);
try (CamelContext context = new LightweightCamelContext()) {
return RestDslGenerator.toYaml(document).generate(context, true);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(openapi);
OpenAPI openAPI = result.getOpenAPI();

try (CamelContext context = new DefaultCamelContext()) {
return RestDslGenerator.toYaml(openAPI).generate(context, true);
}
}

Expand All @@ -50,7 +53,7 @@ private JsonNode readNodeFromJson(String openapi) throws Exception {

private JsonNode readNodeFromYaml(String openapi) throws FileNotFoundException {
final ObjectMapper mapper = new ObjectMapper();
Yaml loader = new Yaml(new SafeConstructor());
Yaml loader = new Yaml(new SafeConstructor(new LoaderOptions()));
Map map = loader.load(openapi);
return mapper.convertValue(map, JsonNode.class);
}
Expand Down
40 changes: 20 additions & 20 deletions src/test/java/org/apache/camel/kameleon/ComponentResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.restassured.response.Response;
import org.junit.jupiter.api.Test;

import javax.inject.Inject;
import jakarta.inject.Inject;

import java.util.HashMap;
import java.util.List;
Expand All @@ -34,25 +34,25 @@
@QuarkusTest
public class ComponentResourceTest {

@Inject
ConfigurationResource configurationResource;

@Test
public void testComponents() {
KameleonConfiguration kc = configurationResource.getKc();
kc.getTypes().forEach(camelType ->
camelType.getVersions().forEach(
camelVersion -> test(camelType.getName(), camelVersion.getName())
)
);
}

private void test(String type, String version){
Response resp = given()
.pathParam("type", type)
.pathParam("version", version)
.when().get("/component/{type}/{version}")
.then().extract().response();
@Inject
ConfigurationResource configurationResource;

@Test
public void testComponents() {
KameleonConfiguration kc = configurationResource.getKc();
kc.getTypes().forEach(camelType ->
camelType.getVersions().forEach(
camelVersion -> test(camelType.getName(), camelVersion.getName())
)
);
}

private void test(String type, String version) {
Response resp = given()
.pathParam("type", type)
.pathParam("version", version)
.when().get("/component/{type}/{version}")
.then().extract().response();

List<HashMap<String, String>> list = resp.getBody().jsonPath().getList("");
Assertions.assertTrue(list.size() > 100);
Expand Down