[ https://issues.apache.org/jira/browse/CAMEL-12222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16360029#comment-16360029 ]
ASF GitHub Bot commented on CAMEL-12222: ---------------------------------------- GitHub user DariusX opened a pull request: https://github.com/apache/camel/pull/2220 CAMEL-12222: RestSwaggerServlet - added option to suppress "translate… Added an option to suppress "translateContextPath" Also, added a fix to allow this class to be used in the 2.20.1 version, even though it is deprecated You can merge this pull request into a Git repository by running: $ git pull https://github.com/DariusX/camel CAMEL-12222-Rest-Swagger-Context Alternatively you can review and apply these changes as the patch at: https://github.com/apache/camel/pull/2220.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2220 ---- commit ec87c965f92ca04e874bae115f16f01c5034985e Author: realistTheorist <realisttheorist@...> Date: 2018-02-11T17:35:22Z CAMEL-12222: RestSwaggerServlet - added option to suppress "translateContextPath" ---- > 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 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 -- This message was sent by Atlassian JIRA (v7.6.3#76005)