...
Code Block | ||||
---|---|---|---|---|
| ||||
<web-app>
<context-param>
<param-name>contextParam</param-name>
<param-value>contextParamValue</param-value>
</context-param>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>
org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
</servlet-class>
<init-param>
<param-name>jaxrs.serviceClasses</param-name>
<param-value>
org.apache.cxf.systest.jaxrs.BookStore
</param-value>
</init-param>
<init-param>
<param-name>jaxrs.features</param-name>
<param-value>
org.apache.cxf.jaxrs.swagger.Swagger2Feature
(basePath=/somepath)
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app> |
Accessing Swagger documents
When Swagger is enabled by Swagger feature, the Swagger documents will be available at the location URL constructed of the service endpoint location followed by /swagger.json or /swagger.yaml. For example, if the service endpoint is published at http://host:port/serviceroot, its Swagger documents are available at http://host:port/serviceroot/swagger.json and http://host:port/serviceroot/swagger.yaml.
If you deploy swagger-ui with your application, you can access these Swagger documents directly. For more details, please look at some of the samples listed below.
Samples
CXF's distribution contains the following samples.
- samples/jax_rs/description_swagger: Swagger 1.2 sample using SwaggerFeature programatically
- samples/jax_rs/description_swagger2: Swagger 2.0 standalone sample using Swagger2Feature programatically
- samples/jax_rs/description_swagger2_spring: Swagger 2.0 standalone sample using Swagger2Feature using Spring
- samples/jax_rs/description_swagger2_web: Swagger 2.0 web application sample using Swagger2Feature using Spring
- samples/jax_rs/description_swagger2_osgi: Swagger 2.0 OSGi application sample using Swagger2Feature using Blueprint
...