[ 
https://issues.apache.org/jira/browse/CAMEL-12222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Darius Cooper updated CAMEL-12222:
----------------------------------
    Description: 
The method within RestSwaggerServlet, looks for the last "/" in the context 
root, and drops anything after that slash.
{code:java}
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;
}{code}
Even thought 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() 

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

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


{code:java}
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;
}{code}

Even thought 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.

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


> ResrSwaggerServlet removes last part of context root
> ----------------------------------------------------
>
>                 Key: CAMEL-12222
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12222
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-swagger
>            Reporter: Darius Cooper
>            Priority: Minor
>
> The method within RestSwaggerServlet, looks for the last "/" in the context 
> root, and drops anything after that slash.
> {code:java}
> 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;
> }{code}
> Even thought 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() 
> I plan on working on this. Creating a Jira to get feedback on the approach



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to