This example shows how to use Servlet REST to define REST endpoints in Camel routes using the Rest DSL in XML,
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.xml file.
There is a order REST service that supports the following operations
- GET /order/{id} - to view an order with the given id
- POST /order - to create an order
- PUT /order - to update an order
- DELETE /order/{id} - to delete an order
From a web browser you can access the first service using the following links
- order/1 - to view the order with id 1
- order/2 - to view the order with id 2
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/chapter10-servlet-swagger-xml/rest/orders/1
curl -X GET -H "Accept: application/json" http://localhost:8080/chapter10-servlet-swagger-xml/rest/orders/2
curl -X POST -H "Content-Type: application/json" -d '{ "partName": "brake", "amount": 4, "customerName": "nissan" }' http://localhost:8080/chapter10-servlet-swagger-xml/rest/orders
The example comes with Swagger API documentation which you can access from the following url:
http://localhost:8080/chapter10-servlet-swagger-xml/rest/api-doc/camel-1