Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openapi-contract-first example #219

Merged
Merged
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
2 changes: 1 addition & 1 deletion aws-lambda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<description>Camel Quarkus Example :: Deploying a Camel Route in AWS Lambda</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion cluster-leader-election/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<description>Camel Quarkus Example :: Cluster leader election</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion cxf-soap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<description>Camel Quarkus Example :: CXF SOAP</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
5 changes: 5 additions & 0 deletions docs/modules/ROOT/attachments/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
"description": "Demonstrates how to add support for metrics, health checks and distributed tracing",
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/observability"
},
{
"title": "OpenAPI Contract First",
"description": "Shows how to run with Contract First OpenAPI.",
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/openapi-contract-first"
},
{
"title": "Platform HTTP security with Keycloak",
"description": "Shows how to secure platform HTTP with Keycloak",
Expand Down
2 changes: 1 addition & 1 deletion file-bindy-ftp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: File Bindy FTP</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion file-split-log-xml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: File To Log XML DSL</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion health/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: Health Check</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion http-log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: HTTP to Log</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion jdbc-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<name>Camel Quarkus :: Examples :: Jdbc - DatataSource - Log</name>
<description>Camel Quarkus Example :: Connect to Database using Datasource</description>
<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion jms-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<name>Camel Quarkus :: Examples :: JMS JPA</name>
<description>Camel Quarkus Example :: JMS JPA</description>
<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>
<quarkiverse-artemis.version>3.3.0</quarkiverse-artemis.version>

Expand Down
2 changes: 1 addition & 1 deletion jpa-idempotent-repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<description>Camel Quarkus Example :: JPA Idempotent Repository</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion jta-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<name>Camel Quarkus :: Examples :: JTA JPA</name>
<description>Camel Quarkus Example :: JTA JPA</description>
<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: Kafka</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion kamelet-chucknorris/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: Kamelet Chuck Norris</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<!-- TODO: https://github.com/apache/camel-quarkus/issues/3156 -->
Expand Down
2 changes: 1 addition & 1 deletion message-bridge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<description>Camel Quarkus Example :: Configure XA Transactions and connection pooling</description>

<properties>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
2 changes: 1 addition & 1 deletion observability/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<properties>

<quarkus.platform.version>3.10.0</quarkus.platform.version>
<quarkus.platform.version>3.11.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.11.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
Expand Down
87 changes: 87 additions & 0 deletions openapi-contract-first/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
= OpenAPI Contract First: A Camel Quarkus example
:cq-example-description: An example that shows how to run with Contract First OpenAPI.

{cq-description}

This example uses Camel to expose REST APIs from an existing OpenAPI specification (contract first).

From the contract we generate Java POJO classes (using quarkus-maven-plugin, see `pom.xml`).

In the Camel route `PetStoreRoute.java` we use Rest DSL using OpenAPI in contract-first mode.
This makes it possible to expose all the APIs very easily, and map this to corresponding Camel
routes via `direct:operationId` naming convention.

The example uses the Petstore OpenAPI example which comes with 18 APIs. This example has only
implemented 2 of these APIs, and to ignore the remaining APIs. This is handy during development,
so you can implement the APIs one by one.

TIP: Check the https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus User guide] for prerequisites
and other general information.

== Start in the Development mode

[source,shell]
----
$ mvn clean compile quarkus:dev
----

The above command compiles the project, starts the application and lets the Quarkus tooling watch for changes in your
workspace. Any modifications in your project will automatically take effect in the running application.

TIP: Please refer to the Development mode section of
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel Quarkus User guide] for more details.

// TODO: Describe how the user should interact with the example here

=== Package and run the application

Once you are done with developing you may want to package and run the application.

TIP: Find more details about the JVM mode and Native mode in the Package and run section of
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_package_and_run_the_application[Camel Quarkus User guide]

==== JVM mode

[source,shell]
----
$ mvn clean package
$ java -jar target/quarkus-app/quarkus-run.jar
...
[io.quarkus] (main) camel-quarkus-examples-... started in 1.163s.
----

==== Native mode

IMPORTANT: Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section
of https://camel.apache.org/camel-quarkus/latest/first-steps.html#_prerequisites[Camel Quarkus User guide].

To prepare a native executable using GraalVM, run the following command:

[source,shell]
----
$ mvn clean package -Pnative
$ ./target/*-runner
...
[io.quarkus] (main) camel-quarkus-examples-... started in 0.013s.
...
----

==== How to run

Test the service endpoint from another terminal:

[source,shell]
----
curl http://localhost:8080/api/v3/pet/123
----

You should get some results like:
[source]
----
{"id":123,"name":"Tony the tiger","photoUrls":[],"status":"available"}
----


== Feedback

Please report bugs and propose improvements via https://github.com/apache/camel-quarkus/issues[GitHub issues of Camel Quarkus] project.
Loading
Loading