== Camel Rest OpenApi example

This example shows how to call a REST service defined using OpenAPI
specification with the help of Camel Rest OpenApi component.

== Trying out the example on your local machine

Start the server providing the OpenAPI specification with:

----
docker run --name swaggerapi-petstore3 -d -p 8081:8080 swaggerapi/petstore3:unstable
----

=== How to run the example

The example is a standalong Spring Boot application that acts as a REST
client, you can run simply by issuing:

....
$ mvn spring-boot:run
....

Or by packaging it and running it using `+java+` CLI:

....
$ mvn package
$ java -jar target/camel-example-spring-boot-rest-openapi-simple-*.jar
....

The example periodically retrieves a pet using an incremental id from the petstore using the `getPetById` operation defined in the OpenAPI document.
The server contains only 10 pets in its database by default, so an exception in the log with the HTTP 404 code is expected for id greater than 10.

After running the application, you will see following log:

----

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.6)

2023-07-25T10:30:36.438+02:00  INFO 33848 --- [           main] org.apache.camel.example.Application     : Starting Application using Java 17.0.5 with PID 33848 (/git/camel-spring-boot-examples/rest-openapi-simple/target/classes started by avano in /git/camel-spring-boot-examples/rest-openapi-simple)
2023-07-25T10:30:36.440+02:00  INFO 33848 --- [           main] org.apache.camel.example.Application     : No active profile set, falling back to 1 default profile: "default"
2023-07-25T10:30:36.924+02:00  INFO 33848 --- [           main] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 4.0.0.M3-redhat-00009 (camel-1) is starting
2023-07-25T10:30:37.768+02:00  INFO 33848 --- [           main] c.s.b.CamelSpringBootApplicationListener : Starting CamelMainRunController to ensure the main thread keeps running
2023-07-25T10:30:37.768+02:00  INFO 33848 --- [inRunController] org.apache.camel.main.MainSupport        : Apache Camel (Main) 4.0.0.M3-redhat-00009 is starting
2023-07-25T10:30:37.771+02:00  INFO 33848 --- [           main] o.a.c.impl.engine.AbstractCamelContext   : Using 2 instances of same component class: org.apache.camel.component.http.HttpComponent with names: http, https
2023-07-25T10:30:37.772+02:00  INFO 33848 --- [           main] o.a.c.impl.engine.AbstractCamelContext   : Routes startup (started:1)
2023-07-25T10:30:37.772+02:00  INFO 33848 --- [           main] o.a.c.impl.engine.AbstractCamelContext   :     Started route1 (timer://t)
2023-07-25T10:30:37.772+02:00  INFO 33848 --- [           main] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 4.0.0.M3-redhat-00009 (camel-1) started in 847ms (build:0ms init:0ms start:847ms)
2023-07-25T10:30:37.790+02:00  INFO 33848 --- [           main] org.apache.camel.example.Application     : Started Application in 1.473 seconds (process running for 1.611)
2023-07-25T10:30:38.774+02:00  INFO 33848 --- [ #1 - timer://t] route1                                   : Retrieving pet with id 1
2023-07-25T10:30:39.271+02:00  INFO 33848 --- [ #1 - timer://t] route1                                   : {"id":1,"category":{"id":2,"name":"Cats"},"name":"Cat 1","photoUrls":["url1","url2"],"tags":[{"id":1,"name":"tag1"},{"id":2,"name":"tag2"}],"status":"available"}
2023-07-25T10:30:43.771+02:00  INFO 33848 --- [ #1 - timer://t] route1                                   : Retrieving pet with id 2
2023-07-25T10:30:43.890+02:00  INFO 33848 --- [ #1 - timer://t] route1                                   : {"id":2,"category":{"id":2,"name":"Cats"},"name":"Cat 2","photoUrls":["url1","url2"],"tags":[{"id":1,"name":"tag2"},{"id":2,"name":"tag3"}],"status":"available"}
----

=== Help and contributions

If you hit any problem using Camel or have some feedback, then please
https://camel.apache.org/support.html[let us know].

We also love contributors, so
https://camel.apache.org/contributing.html[get involved] :-)

The Camel riders!
