Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
4.5. Swagger Integration
Overview
Copier lienLien copié sur presse-papiers!
					Integrated with the REST DSL, the 
camel-swagger component enables users to create API docs for any REST-defined routes and endpoints in a CamelContext file. The camel-swagger component creates a servlet integrated with the CamelContext that pulls the information from each REST endpoint to generate the API docs (JSON file).
				
					If using Maven, you need to add the 
camel-swagger component to your pom.xml file:
				Configuring the camelContext
Copier lienLien copié sur presse-papiers!
					To enable Swagger, add to the CamelContext file:
				
- Theserviceelement, which exposes the camel-swagger servlet and initializes its parameters.In the service element, add the servlet (org.apache.camel.component.swagger.DefaultCamelSwaggerServlet) and theservice-propertiesthat configure the servlet's parameters.For details on servlet parameters, see chapter "Swagger" in "Apache Camel Component Reference".
- Configure the REST implementationDefine the REST service within thecamelContextelement using therestConfigurationandrestelements.For details on configuring REST services in the CamelContext, see Section 4.2, “Defining Services with REST DSL”.
					For OSGi deployments, you need to configure the servlet options
 and REST configuration in the 
blueprint.xml file; for example:
				
					The following parameters are used in the above example as described here:
				
-  service
- Theserviceelement exposes the camel swagger servlet (<bean class="org.apache.camel.component.swagger.DefaultCamelSwaggerServlet"/>) and initializes several servlet properties.
-  alias
- Thealiasproperty binds the camel swagger servlet to/api-docs/*.
-  init-prefix
- Theinit-prefixproperty sets the prefix for all camel swagger servlet properties toinit.. This is analogous to usinginit-paramelements in theweb.xmlconfiguration for WAR implementations (see chapter "Swagger" in "Apache Camel Component Reference").
-  restConfiguration
- In thecamelContextelement, therestConfigurationelement specifies the REST implementation to use. In this case, it is Jetty web servlet on port 8080.
-  rest
- In thecamelContextelement, therestelement defines a REST service and provides the base path (/say) to it. In this case, the service consists of two REST endpoints,helloandbye, which are routed to their corresponding camel endpoints defined in therouteelements.