Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12222

ResrSwaggerServlet removes last part of context root

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.19.5, 2.20.3, 2.21.0
    • Component/s: camel-swagger
    • Labels:
      None
    • Estimated Complexity:
      Moderate

      Description

      The method within RestSwaggerServlet, looks for the last "/" in the context root, and drops anything after that slash.

      private String translateContextPath(HttpServletRequest request) {
        String path = request.getContextPath();
        if (path.isEmpty() || path.equals("/")) {
            return "";
        } else {
           int idx = path.lastIndexOf("/");
           if (idx > 0) {
               return path.substring(0, idx);
           }
        }
        return path;
      }

      Even though this has been deprecated, it would be good to fix it. 

      An approach could be to add a servlet init parameter named "translateContextPath" which would default to true, and would work exactly as it does today by default. if set to false, it would return whatever value is in request.getContextPath() , with no translation.

      Also, to avoid the NPE thrown, pass in an empty RestConfiguration to RestSwaggerSupport.renderResourceListing() 

      (See: https://issues.apache.org/jira/browse/CAMEL-12038

      I plan on working on this. Creating a Jira to get feedback on the approach

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              dariusx Darius Cooper
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: