Este contenido no está disponible en el idioma seleccionado.

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:

  1. Open the Camel Context file in the route editor.
  2. Click the REST tab to the view the Rest DSL components.

    RESTtab

    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.
  3. Click a REST element to view its associated operations (for example, GET, POST, PUT, and DELETE) in the REST Operations section.
  4. Click a REST element or a REST operation to view its properties in the Properties view.

    RESTproperties

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:

    1. In the REST elements section, click the + button. A REST element is added to the list of REST elements.
    2. In the Properties view, edit the REST element properties.

      RESTAddElement2
  • To add a REST operation to a REST element:

    1. In the list of REST elements, select a REST element.
    2. In the REST operations section, click the + button.

      The Add REST Operation dialog box opens.

      RESTAddOperation
    3. Specify the ID, URI, and Operation Type. Optionally, select a Referenced Route ID.
    4. 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:

  1. Open the Camel Context file in the route editor.
  2. Click the route editor’s Source tab and then edit the code.

    RESTsourcetab
  3. Optionally, click the REST tab to see the changes in the graphical view.
  4. To save your changes, select File Save.
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.