...
Code Block |
---|
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-swagger</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> |
Using with Camel 2.15 onwards
The default servlet supports any environment using JMX to discover the CamelContext(s) to use.
The name of the servlet is org.apache.camel.component.swagger.DefaultCamelSwaggerServlet
.
Using with Camel 2.14.x
The Swagger servlet is integrated with Spring or ServletListener Component.
...
The servlet support the same options when using spring or servletlistener.
Warning |
---|
The servlets above from Camel 2.14.x is deprecated and replaced with a single default servlet from Camel 2.15 onwards. |
For example when When using Spring you need to configure the org.apache.camel.component.swagger.spring.SpringRestSwaggerApiDeclarationServlet
in the WEB-INF/web.xml
file as shown below:
Tip |
---|
If you use Camel 2.15 onwards then just use the default servlet in any kind of environment. |
Code Block |
---|
<!-- to setup Camel Swagger api servlet when using Spring --> <servlet> <!-- Camel 2.14.x --> <servlet-name>ApiDeclarationServlet</servlet-name> <servlet-class>org.apache.camel.component.swagger.spring.SpringRestSwaggerApiDeclarationServlet</servlet-class> <!-- Camel 2.15 onwards --> <servlet-name>ApiDeclarationServlet</servlet-name> <servlet-class>org.apache.camel.component.swagger.DefaultCamelSwaggerServlet</servlet-class> <init-param> <param-name>base.path</param-name> <param-value>http://localhost:8080/rest</param-value> </init-param> <init-param> <param-name>api.path</param-name> <param-value>http://localhost:8080/api-docs</param-value> </init-param> <init-param> <param-name>api.version</param-name> <param-value>1.2.3</param-value> </init-param> <init-param> <param-name>api.title</param-name> <param-value>User Services</param-value> </init-param> <init-param> <param-name>api.description</param-name> <param-value>Camel Rest Example with Swagger that provides an User REST service</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- swagger api declaration --> <servlet-mapping> <servlet-name>ApiDeclarationServlet</servlet-name> <url-pattern>/api-docs/*</url-pattern> </servlet-mapping> |
...
The org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet
and org.apache.camel.component.swagger.DefaultCamelSwaggerServlet
supports the following options which can be configured as context-param in the web.xml file.
...