This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new c0da90e Fix #976 REST OpenApi support (JVM only) c0da90e is described below commit c0da90ea2eb0706849aa64f9f47bd899df0b7cc9 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Wed Mar 25 15:51:57 2020 +0100 Fix #976 REST OpenApi support (JVM only) --- .../pages/list-of-camel-quarkus-extensions.adoc | 4 + extensions-jvm/pom.xml | 1 + extensions-jvm/rest-openapi/deployment/pom.xml | 75 +++++++++++++++++ .../openapi/deployment/RestOpenapiProcessor.java | 46 +++++++++++ .../rest-openapi/integration-test/pom.xml | 94 ++++++++++++++++++++++ .../rest/openapi/it/RestOpenapiResource.java | 51 ++++++++++++ .../component/rest/openapi/it/RestOpenapiTest.java | 34 ++++++++ extensions-jvm/rest-openapi/pom.xml | 40 +++++++++ extensions-jvm/rest-openapi/runtime/pom.xml | 83 +++++++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 30 +++++++ poms/bom-deployment/pom.xml | 5 ++ poms/bom/pom.xml | 10 +++ 12 files changed, 473 insertions(+) diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 032be73..dd1151e 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -517,6 +517,10 @@ Level | Since | Description `rest-api:path/contextIdPattern` | Native + Stable | 0.2.0 | The rest-api component is used for providing Swagger API of the REST services which has been defined using the rest-dsl in Camel. +| link:https://camel.apache.org/components/latest/rest-openapi-component.html[REST OpenApi] (camel-quarkus-rest-openapi) + +`rest-openapi:specificationUri#operationId` | JVM + + Preview | 1.0.0-M6 | An awesome REST endpoint backed by OpenApi specifications. + | link:https://camel.apache.org/components/latest/salesforce-component.html[Salesforce] (camel-quarkus-salesforce) + `salesforce:operationName:topicName` | Native + Stable | 0.2.0 | The salesforce component is used for integrating Camel with the massive Salesforce API. diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index e268ad7..0dce45b 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -72,6 +72,7 @@ <module>protobuf</module> <module>pubnub</module> <module>rabbitmq</module> + <module>rest-openapi</module> <module>sap-netweaver</module> </modules> diff --git a/extensions-jvm/rest-openapi/deployment/pom.xml b/extensions-jvm/rest-openapi/deployment/pom.xml new file mode 100644 index 0000000..55fd8f5 --- /dev/null +++ b/extensions-jvm/rest-openapi/deployment/pom.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-rest-openapi-deployment</artifactId> + <name>Camel Quarkus :: REST OpenApi :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions-jvm/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/RestOpenapiProcessor.java b/extensions-jvm/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/RestOpenapiProcessor.java new file mode 100644 index 0000000..4206391 --- /dev/null +++ b/extensions-jvm/rest-openapi/deployment/src/main/java/org/apache/camel/quarkus/component/rest/openapi/deployment/RestOpenapiProcessor.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.rest.openapi.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.pkg.steps.NativeBuild; +import org.apache.camel.quarkus.core.JvmOnlyRecorder; +import org.jboss.logging.Logger; + +class RestOpenapiProcessor { + + private static final Logger LOG = Logger.getLogger(RestOpenapiProcessor.class); + private static final String FEATURE = "camel-rest-openapi"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + /** + * Remove this once this extension starts supporting the native mode. + */ + @BuildStep(onlyIf = NativeBuild.class) + @Record(value = ExecutionTime.RUNTIME_INIT) + void warnJvmInNative(JvmOnlyRecorder recorder) { + JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time + recorder.warnJvmInNative(FEATURE); // warn at runtime + } +} diff --git a/extensions-jvm/rest-openapi/integration-test/pom.xml b/extensions-jvm/rest-openapi/integration-test/pom.xml new file mode 100644 index 0000000..d961597 --- /dev/null +++ b/extensions-jvm/rest-openapi/integration-test/pom.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-rest-openapi-integration-test</artifactId> + <name>Camel Quarkus :: REST OpenApi :: Integration Test</name> + <description>Integration tests for Camel Quarkus REST OpenApi extension</description> + + <properties> + <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd --> + <!-- The following rule tells mvnd to build the listed deployment modules before this module. --> + <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> + <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> + <!-- Please update rule whenever you change the dependencies of this module by running --> + <!-- mvn process-resources -Pformat from the root directory --> + <mvnd.builder.rule>camel-quarkus-rest-openapi-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/extensions-jvm/rest-openapi/integration-test/src/main/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiResource.java b/extensions-jvm/rest-openapi/integration-test/src/main/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiResource.java new file mode 100644 index 0000000..792da0e --- /dev/null +++ b/extensions-jvm/rest-openapi/integration-test/src/main/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiResource.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.rest.openapi.it; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.camel.CamelContext; +import org.jboss.logging.Logger; + +@Path("/rest-openapi") +@ApplicationScoped +public class RestOpenapiResource { + + private static final Logger LOG = Logger.getLogger(RestOpenapiResource.class); + + private static final String COMPONENT_REST_OPENAPI = "rest-openapi"; + @Inject + CamelContext context; + + @Path("/load/component/rest-openapi") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response loadComponentRestOpenapi() throws Exception { + /* This is an autogenerated test */ + if (context.getComponent(COMPONENT_REST_OPENAPI) != null) { + return Response.ok().build(); + } + LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_REST_OPENAPI); + return Response.status(500, COMPONENT_REST_OPENAPI + " could not be loaded from the Camel context").build(); + } +} diff --git a/extensions-jvm/rest-openapi/integration-test/src/test/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiTest.java b/extensions-jvm/rest-openapi/integration-test/src/test/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiTest.java new file mode 100644 index 0000000..8ad554e --- /dev/null +++ b/extensions-jvm/rest-openapi/integration-test/src/test/java/org/apache/camel/quarkus/component/rest/openapi/it/RestOpenapiTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.rest.openapi.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class RestOpenapiTest { + + @Test + public void loadComponentRestOpenapi() { + /* A simple autogenerated test */ + RestAssured.get("/rest-openapi/load/component/rest-openapi") + .then() + .statusCode(200); + } + +} diff --git a/extensions-jvm/rest-openapi/pom.xml b/extensions-jvm/rest-openapi/pom.xml new file mode 100644 index 0000000..40f51be --- /dev/null +++ b/extensions-jvm/rest-openapi/pom.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-rest-openapi-parent</artifactId> + <name>Camel Quarkus :: REST OpenApi</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + <module>integration-test</module> + </modules> +</project> diff --git a/extensions-jvm/rest-openapi/runtime/pom.xml b/extensions-jvm/rest-openapi/runtime/pom.xml new file mode 100644 index 0000000..2f3b567 --- /dev/null +++ b/extensions-jvm/rest-openapi/runtime/pom.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-rest-openapi</artifactId> + <name>Camel Quarkus :: REST OpenApi :: Runtime</name> + <description>An awesome REST endpoint backed by OpenApi specifications.</description> + + <properties> + <firstVersion>1.0.0-M6</firstVersion> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-rest-openapi</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/extensions-jvm/rest-openapi/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-jvm/rest-openapi/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..87c7fc5 --- /dev/null +++ b/extensions-jvm/rest-openapi/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +--- +name: "REST OpenApi" +description: "An awesome REST endpoint backed by OpenApi specifications." +metadata: + unlisted: true + keywords: + - "http" + - "openapi" + - "rest" + guide: "https://camel.apache.org/components/latest/rest-openapi-component.html" + categories: + - "integration" + status: "preview" diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index dd42233..ccc8ee3 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -659,6 +659,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-salesforce-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 9673068..f9f9496 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -836,6 +836,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-rest-openapi</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-salesforce</artifactId> <version>${camel.version}</version> </dependency> @@ -1614,6 +1619,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest-openapi</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-salesforce</artifactId> <version>${camel-quarkus.version}</version> </dependency>