Search code examples
javaswaggercxfweb.xml

Pass multiple parameters to org.apache.cxf.jaxrs.swagger.Swagger2Feature in web.xml


I have a java REST server projects built with CXFNonSpringJaxrsServlet class. I need to configure Swagger2Feature passing multiple parameters into on web.xml.

this is my Actual web.xml:

<servlet>
<display-name>CXFNonSpringJaxrsServlet</display-name>
<servlet-name>CXFNonSpringJaxrsServlet</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>  
...
<init-param>
  <param-name>jaxrs.features</param-name>
  <param-value> 
   org.apache.cxf.jaxrs.swagger.Swagger2Feature
   <!-- Here I need to pass "scan", "title", "description".. etc -->
   (basePath=/rest)       
  </param-value>
  <load-on-startup>1</load-on-startup>
</init-param>
...

Is there a way to pass more properties to the Swagger2 class? Otherwise, can I get the Swagger2Feature instance from ContextListener to modify the other properties ?


Solution

  • Simply pass other parameters divided by a blank space:

    org.apache.cxf.jaxrs.swagger.Swagger2Feature (basePath=/rest prettyPrint=true resourcePackage=com.your.package.name description=Your_description title=Your_title contact=info@domain.com)