Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7746

Swagger2Feature - SwaggerUiResolver & JBoss 7.0 EAP

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.4
    • 3.2.5
    • JAX-RS
    • None
    • Unknown

    Description

      Hi,

      Same problem as CXF-7474, but for JBoss EAP 7.0 & CXF 3.2.4.

      The SwaggerUiResolver is not able to find the swagger-ui jar, included in our war via maven; the path returned by the class loader ends with ".jar/" instead of the expected ".jar" or ".jar!/".

      To bypass the problem, we modified the checkUiRoot as follow:

      // Artifact: cxf-rt-rs-service-description-swagger
      // Class: org.apache.cxf.jaxrs.swagger.SwaggerUiResolver
      protected static String checkUiRoot(String urlStr, String swaggerUiVersion)
      {
        int swaggerUiIndex = urlStr.lastIndexOf("/swagger-ui-");
        if (swaggerUiIndex != -1)
        {
          boolean urlEndsWithJarSep = urlStr.endsWith(".jar!/");
          int offset = -1;
      
          if (urlEndsWithJarSep || urlStr.endsWith(".jar"))
          {
            offset = urlEndsWithJarSep ? 6 : 4;
          }
          else if (urlStr.endsWith(".jar/"))
          {
            offset = 5;
            urlEndsWithJarSep = true;
          }
      
          if (offset > -1)
          {
            String version = urlStr.substring(swaggerUiIndex + 12, urlStr.length() - offset);
            if (swaggerUiVersion != null && !swaggerUiVersion.equals(version))
            {
              return null;
            }
            else
            {
              if (!urlEndsWithJarSep)
              {
                urlStr = "jar:" + urlStr + "!/";
              }
      
              return urlStr + "META-INF/resources/webjars/swagger-ui/" + version + "/";
            }
          }
        }
      
        return null;
      }
      

       

      Attachments

        Issue Links

          Activity

            People

              deki Dennis Kieselhorst
              Edumdum Etienne Dumont
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: