Chapter 3. Viewing and editing Rest DSL components
Apache Camel supports multiple approaches to defining REST services. In particular, Apache Camel provides the REST DSL (Domain Specific Language), which is a simple but powerful API that can be layered over any REST component and provides integration with the OpenAPI 2.0 specification. OpenAPI (formerly Swagger) is a vendor-neutral and portable open description format for API services.
For information about using the Camel Rest DSL, see the “Defining REST services” chapter of the Apache Camel Development Guide.
With the Fuse Tooling, you can view and edit Rest DSL components that are in your Camel Context file.
You can also configure your Fuse Integration project to expose your REST API to an OpenAPI client as described here: https://access.redhat.com/articles/4296981.
3.1. Viewing a graphical representation of Rest DSL components
To view the REST DSL components in your Camel Context file in graphical mode:
- Open the Camel Context file in the route editor.
Click the REST tab to the view the Rest DSL components.
The REST Configuration section displays these configuration options:
- Component — The Camel component to use for the REST transport.
- Context Path — The leading context-path for the REST services. You can use this option for components, such as Servlet, where the web application is deployed using a context-path.
- Port — The port number that exposes the REST service.
- Binding Mode — The binding mode for JSON or XML format messages. Possible values are: off (the default), auto, json, xml, or json_xml.
- Host — The hostname to use for exposing the REST service.
-
Click a REST element to view its associated operations (for example,
GET
,POST
,PUT
, andDELETE
) in the REST Operations section. Click a REST element or a REST operation to view its properties in the Properties view.
3.2. Editing Rest DSL components in the graphical view
You can add, edit, or delete REST elements in your project’s Camel Context file in the REST tab.
To add a new REST element:
In the REST elements section, click the + button. A REST element is added to the list of REST elements.
In the Properties view, edit the REST element properties.
To add a REST operation to a REST element:
In the list of REST elements, select a REST element.
In the REST operations section, click the + button.
The Add REST Operation dialog box opens.
- Specify the ID, URI, and Operation Type. Optionally, select a Referenced Route ID.
- Click Finish. The new operation shows in the list of REST operations for the selected REST element.
- To edit a REST element or operation, select it in the REST tab and then edit its property values in the Properties tab.
- To remove a selected REST element or operation, click the x button.
3.3. Viewing and editing the Rest DSL source code
You can also view and edit Rest DSL components in the Source tab:
- Open the Camel Context file in the route editor.
Click the route editor’s Source tab and then edit the code.
- Optionally, click the REST tab to see the changes in the graphical view.
-
To save your changes, select File
Save.