Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
<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.

...