This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 01929781aa4580a89af6cd464dc12a2654b50647 Author: lburgazzoli <[email protected]> AuthorDate: Mon Jun 1 16:27:36 2020 +0200 Create extension for camel-openapi-java #1281 --- .github/test-categories.yaml | 1 + .../ROOT/pages/extensions/openapi-java.adoc | 28 +++++ .../pages/list-of-camel-quarkus-extensions.adoc | 4 +- extensions/openapi-java/deployment/pom.xml | 83 ++++++++++++++ .../java/deployment/OpenApiJavaProcessor.java | 30 +++++ extensions/openapi-java/pom.xml | 39 +++++++ extensions/openapi-java/runtime/pom.xml | 107 +++++++++++++++++ .../java/graal/RestOpenApiReaderSubstitutions.java | 32 ++++++ .../main/resources/META-INF/quarkus-extension.yaml | 29 +++++ extensions/pom.xml | 1 + integration-tests/openapi-java/pom.xml | 126 +++++++++++++++++++++ .../component/openapijava/it/OpenApiRoutes.java | 43 +++++++ .../component/openapijava/it/model/Fruit.java | 31 +++++ .../src/main/resources/application.properties | 28 +++++ .../component/openapijava/it/OpenApiIT.java | 23 ++++ .../component/openapijava/it/OpenApiTest.java | 54 +++++++++ integration-tests/pom.xml | 1 + poms/bom-deployment/pom.xml | 5 + poms/bom/pom.xml | 10 ++ 19 files changed, 674 insertions(+), 1 deletion(-) diff --git a/.github/test-categories.yaml b/.github/test-categories.yaml index f2043ef..dd4a937 100644 --- a/.github/test-categories.yaml +++ b/.github/test-categories.yaml @@ -93,6 +93,7 @@ networking: - websocket-jsr356 platform: - microprofile + - openapi-java - opentracing - platform-http - platform-http-engine diff --git a/docs/modules/ROOT/pages/extensions/openapi-java.adoc b/docs/modules/ROOT/pages/extensions/openapi-java.adoc new file mode 100644 index 0000000..4c6877f --- /dev/null +++ b/docs/modules/ROOT/pages/extensions/openapi-java.adoc @@ -0,0 +1,28 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-package-maven-plugin:update-extension-doc-page + +[[openapi-java]] += OpenAPI Java + +[.badges] +[.badge-key]##Since Camel Quarkus##[.badge-version]##1.0.0-CR2## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported## + +Rest-dsl support for using OpenAPI doc + +== What's inside + +* https://camel.apache.org/components/latest/others/openapi-java.html[Openapi Java] + +Please refer to the above link for usage and configuration details. + +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-openapi-java</artifactId> +</dependency> +---- + +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. 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 9fa4fe3..12d5c49 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -425,7 +425,7 @@ Number of Camel languages: 13 in 7 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 13 in 13 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 14 in 14 JAR artifacts (0 deprecated) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -447,6 +447,8 @@ Number of miscellaneous extensions: 13 in 13 JAR artifacts (0 deprecated) | xref:extensions/microprofile-health.adoc[Microprofile Health] | camel-quarkus-microprofile-health | Native + Stable | 0.3.0 | Bridging Eclipse MicroProfile Health with Camel health checks +| xref:extensions/openapi-java.adoc[Openapi Java] | camel-quarkus-openapi-java | Native + Stable | 1.0.0-CR2 | Rest-dsl support for using openapi doc + | xref:extensions/opentracing.adoc[OpenTracing] | camel-quarkus-opentracing | Native + Stable | 0.3.0 | Distributed tracing using OpenTracing | xref:extensions/qute.adoc[Qute] | camel-quarkus-qute | Native + Stable | 1.0.0-M6 | Transform messages using Quarkus Qute templating engine diff --git a/extensions/openapi-java/deployment/pom.xml b/extensions/openapi-java/deployment/pom.xml new file mode 100644 index 0000000..df93e6c --- /dev/null +++ b/extensions/openapi-java/deployment/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-openapi-java-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-openapi-java-deployment</artifactId> + <name>Camel Quarkus :: OpenAPI Java :: 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-xml-jaxb-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-xalan-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-openapi-java</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/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java b/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java new file mode 100644 index 0000000..9f6ac2e --- /dev/null +++ b/extensions/openapi-java/deployment/src/main/java/org/apache/camel/quarkus/component/openapi/java/deployment/OpenApiJavaProcessor.java @@ -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. + */ +package org.apache.camel.quarkus.component.openapi.java.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class OpenApiJavaProcessor { + + private static final String FEATURE = "camel-openapi-java"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/openapi-java/pom.xml b/extensions/openapi-java/pom.xml new file mode 100644 index 0000000..287c29d --- /dev/null +++ b/extensions/openapi-java/pom.xml @@ -0,0 +1,39 @@ +<?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-openapi-java-parent</artifactId> + <name>Camel Quarkus :: OpenAPI Java</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/openapi-java/runtime/pom.xml b/extensions/openapi-java/runtime/pom.xml new file mode 100644 index 0000000..ac28ebd --- /dev/null +++ b/extensions/openapi-java/runtime/pom.xml @@ -0,0 +1,107 @@ +<?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-openapi-java-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-openapi-java</artifactId> + <name>Camel Quarkus :: OpenAPI Java :: Runtime</name> + <description>Rest-dsl support for using OpenAPI doc</description> + + <properties> + <firstVersion>1.0.0-CR2</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.quarkus</groupId> + <artifactId>camel-quarkus-xml-jaxb</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-xalan</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-openapi-java</artifactId> + </dependency> + <dependency> + <groupId>org.graalvm.nativeimage</groupId> + <artifactId>svm</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-package-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals><goal>update-extension-doc-page</goal></goals> + <phase>process-resources</phase> + </execution> + </executions> + </plugin> + <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/openapi-java/runtime/src/main/java/org/apache/camel/quarkus/component/openapi/java/graal/RestOpenApiReaderSubstitutions.java b/extensions/openapi-java/runtime/src/main/java/org/apache/camel/quarkus/component/openapi/java/graal/RestOpenApiReaderSubstitutions.java new file mode 100644 index 0000000..950cd24 --- /dev/null +++ b/extensions/openapi-java/runtime/src/main/java/org/apache/camel/quarkus/component/openapi/java/graal/RestOpenApiReaderSubstitutions.java @@ -0,0 +1,32 @@ +/* + * 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.openapi.java.graal; + +import java.util.List; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import io.apicurio.datamodels.core.models.ExtensibleNode; +import org.apache.camel.openapi.RestOpenApiReader; + +@TargetClass(RestOpenApiReader.class) +public final class RestOpenApiReaderSubstitutions { + @Substitute + private static void convertAndSetItemsEnum(ExtensibleNode items, List<String> allowableValues, Class<?> type) { + throw new UnsupportedOperationException("RestOpenApiReader::convertAndSetItemsEnum should not be invoked"); + } +} diff --git a/extensions/openapi-java/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/openapi-java/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..5df1042 --- /dev/null +++ b/extensions/openapi-java/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,29 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel OpenAPI Java" +description: "Rest-dsl support for using OpenAPI doc" +metadata: + guide: "https://camel.apache.org/components/latest/openapi-java-other.html" + categories: + - "integration" diff --git a/extensions/pom.xml b/extensions/pom.xml index a88918b..2aa4025 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -117,6 +117,7 @@ <module>netty</module> <module>netty-http</module> <module>olingo4</module> + <module>openapi-java</module> <module>opentracing</module> <module>paho</module> <module>pdf</module> diff --git a/integration-tests/openapi-java/pom.xml b/integration-tests/openapi-java/pom.xml new file mode 100644 index 0000000..025a79b --- /dev/null +++ b/integration-tests/openapi-java/pom.xml @@ -0,0 +1,126 @@ +<?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-integration-tests</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-openapi-java</artifactId> + <name>Camel Quarkus :: Integration Tests :: OpenApi Java</name> + <description>Integration tests for Camel Quarkus OpenApi Java 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-direct-deployment,camel-quarkus-netty-http-deployment,camel-quarkus-rest-openapi-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jackson</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-openapi-java</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-platform-http</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jsonb</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-support</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> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java b/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java new file mode 100644 index 0000000..beb1dc7 --- /dev/null +++ b/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiRoutes.java @@ -0,0 +1,43 @@ +/* + * 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.openapijava.it; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Set; + +import javax.ws.rs.core.MediaType; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.component.openapijava.it.model.Fruit; + +public class OpenApiRoutes extends RouteBuilder { + @Override + public void configure() throws Exception { + Set<Fruit> fruits = Collections.newSetFromMap(Collections.synchronizedMap(new LinkedHashMap<>())); + fruits.add(new Fruit("Apple", "Winter fruit")); + fruits.add(new Fruit("Pineapple", "Tropical fruit")); + + rest() + .get("/fruits/list") + .id("list") + .produces(MediaType.APPLICATION_JSON) + .route() + .setBody().constant(fruits) + .marshal().json(); + } +} diff --git a/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/model/Fruit.java b/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/model/Fruit.java new file mode 100644 index 0000000..44ee9a1 --- /dev/null +++ b/integration-tests/openapi-java/src/main/java/org/apache/camel/quarkus/component/openapijava/it/model/Fruit.java @@ -0,0 +1,31 @@ +/* + * 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.openapijava.it.model; + +import io.quarkus.runtime.annotations.RegisterForReflection; + +@RegisterForReflection +public class Fruit { + + public String name; + public String description; + + public Fruit(String name, String description) { + this.name = name; + this.description = description; + } +} diff --git a/integration-tests/openapi-java/src/main/resources/application.properties b/integration-tests/openapi-java/src/main/resources/application.properties new file mode 100644 index 0000000..3189809 --- /dev/null +++ b/integration-tests/openapi-java/src/main/resources/application.properties @@ -0,0 +1,28 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Quarkus +# +quarkus.log.level = INFO +quarkus.log.category."org.apache.camel".level = DEBUG + +# +# Camel - REST +# +camel.rest.component = platform-http +camel.rest.api-context-path=/openapi.json diff --git a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiIT.java b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiIT.java new file mode 100644 index 0000000..2ee66cc --- /dev/null +++ b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiIT.java @@ -0,0 +1,23 @@ +/* + * 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.openapijava.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class OpenApiIT extends OpenApiTest { +} diff --git a/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiTest.java b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiTest.java new file mode 100644 index 0000000..7da09f1 --- /dev/null +++ b/integration-tests/openapi-java/src/test/java/org/apache/camel/quarkus/component/openapijava/it/OpenApiTest.java @@ -0,0 +1,54 @@ +/* + * 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.openapijava.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.is; + +@QuarkusTest +class OpenApiTest { + @Test + public void invokeApiEndpoint() { + RestAssured.given() + .get("/fruits/list") + .then() + .contentType(ContentType.JSON) + .statusCode(200) + .body( + "description", containsInAnyOrder("Winter fruit", "Tropical fruit"), + "name", containsInAnyOrder("Apple", "Pineapple")); + } + + @Test + public void invokeApiDocumentEndpoint() { + RestAssured.given() + .get("/openapi.json") + .then() + .contentType(ContentType.JSON) + .statusCode(200) + .body( + "paths.'/fruits/list'", hasKey("get"), + "paths.'/fruits/list'.get.operationId", is("list")); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 5732ddc..c3ea1ac 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -100,6 +100,7 @@ <module>mustache</module> <module>netty</module> <module>olingo4</module> + <module>openapi-java</module> <module>opentracing</module> <module>pdf</module> <module>platform-http</module> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index 42584b7..b6ee2a5 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -604,6 +604,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-openapi-java-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-openstack-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 9cc48f5..6188b05 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -841,6 +841,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-openapi-java</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-openstack</artifactId> <version>${camel.version}</version> <exclusions> @@ -1650,6 +1655,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-openapi-java</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-openstack</artifactId> <version>${camel-quarkus.version}</version> </dependency>
