-
Bug
-
Resolution: Done
-
Major
-
4.7.6.Final
-
None
-
None
If using a @ApplicationPath("") or @ApplicationPath("/") the JSAPIWriter appends a trailing slash onto the uri. The endpoint is then also appended in the generated javascript client which results in a double slash in the final url.
For example from generated client javascript:
REST.apiURL = 'https://localhost:17080/api/';
var ListApi = {};
// POST /list/contact
ListApi.contact = function(_params){
var params = _params ? _params : {};
var request = new REST.Request();
request.setMethod('POST');
var uri = params.$apiURL ? params.$apiURL : REST.apiURL;
uri += '/list/contact';
The end url is: https://localhost:17080/api//list/contact which fails due to the double slash.
The buggy code in question is in JSAPIWriter at line 51:
for (Map.Entry<String, ServiceRegistry> entry : serviceRegistries.entrySet())
{
String uri = base;
if (entry.getKey() != null) uri += entry.getKey();
For a empty @ApplicationPath(""), the service registry will have an entry.getKey() of "/" which erroneously gets appended to the uri.
Fix could maybe be:
if (entry.getKey() != null && !entry.getKey().equals("/")) uri += entry.getKey();