## Apache Camel Example using Swagger Java

This example shows how to use Servlet REST to define REST endpoints in Camel routes using the Rest DSL, and using camel-swagger-java to expose the REST service APIs.
This example is implemented in XML DSL.
The XML DSL the routes are define in XML code, in the `src/main/resources/camel-config-xml.xml` file.

There is a user REST service that supports the following operations

- GET /user/{id} - to view a user with the given id
- GET /user/final - to view all users
- PUT /user - to update/create an user

The view operations are HTTP GET, and update is using HTTP PUT. From a web browser you can access the first two services using the following links

- user/123 - to view the user with id 123
- user/findAll - to list all users

From the command shell you can use curl to access the service as shown below:

        curl -X GET -H "Accept: application/json" http://localhost:8080/camel-example-swagger-java/rest/user/123
        curl -X GET -H "Accept: application/json" http://localhost:8080/camel-example-swagger-java/rest/user/findAll
        curl -X PUT -d "{ \"id\": 666, \"name\": \"The devil\"}" -H "Accept: application/json" http://localhost:8080/camel-example-swagger-java/rest/user

Notice when trying to get user with id 789 then there is a built-in delay of 0.5-2 seconds, to simulate some slowness in the service.

This example offers an API browser using Swagger which is accessible from the following link

- api-docs - list all CamelContexts in the JVM that may have REST services
- api-docs/myCamel - myCamel - overview of the apis from the REST services
- api-docs/myCamel/user - myCamel - api of the user REST service

To use the swagger ui, follow this link. Replace the URL value with this one to access the REST local resources http://localhost:8080/camel-example-swagger-java/rest/api-docs/myCamel

- swagger - swagger ui page

If you hit any problems please let us know on the Camel Forums
Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
The Camel riders!