{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/autorest/issues/900","repository_url":"https://api.github.com/repos/Azure/autorest","labels_url":"https://api.github.com/repos/Azure/autorest/issues/900/labels{/name}","comments_url":"https://api.github.com/repos/Azure/autorest/issues/900/comments","events_url":"https://api.github.com/repos/Azure/autorest/issues/900/events","html_url":"https://github.com/Azure/autorest/issues/900","id":144612714,"number":900,"title":"[NodeJS] [CSharp] - CSV / Arrays / Lists in URL's are not replaced correctly ","user":{"login":"aschua","id":6212814,"avatar_url":"https://avatars.githubusercontent.com/u/6212814?v=3","gravatar_id":"","url":"https://api.github.com/users/aschua","html_url":"https://github.com/aschua","followers_url":"https://api.github.com/users/aschua/followers","following_url":"https://api.github.com/users/aschua/following{/other_user}","gists_url":"https://api.github.com/users/aschua/gists{/gist_id}","starred_url":"https://api.github.com/users/aschua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschua/subscriptions","organizations_url":"https://api.github.com/users/aschua/orgs","repos_url":"https://api.github.com/users/aschua/repos","events_url":"https://api.github.com/users/aschua/events{/privacy}","received_events_url":"https://api.github.com/users/aschua/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-30T14:37:24Z","updated_at":"2016-04-03T03:09:52Z","closed_at":null,"body":"Hello everybody,\r\n\r\nhaving a Java EE REST-Endpoint annotated like:\r\n\r\n```java\r\n  @com.my-domain.ess.interceptor.binding.ServiceOperation(\"query\")\r\n  @javax.ws.rs.GET\r\n  @javax.ws.rs.Path(\"{parentId}/query\")         \r\n  @javax.ws.rs.Produces({javax.ws.rs.core.MediaType.APPLICATION_XML, javax.ws.rs.core.MediaType.APPLICATION_JSON})\r\n  @io.swagger.annotations.ApiOperation(value=\"Wer suchet, der findet\", nickname=\"MischtabellenQuery\",\r\n      authorizations = {\r\n      @io.swagger.annotations.Authorization(\r\n          value=\"oauth\", \r\n          scopes = { @io.swagger.annotations.AuthorizationScope(scope = \"ess\", description = \"OAuth-Authentifizierung f. ESS\") }\r\n          )\r\n    }\r\n  )\r\n\r\n  @io.swagger.annotations.ApiResponses(value = \r\n  {\r\n    @io.swagger.annotations.ApiResponse(code = 200, message = \"OK\", response=com.gfi.eva.serviceschicht.zentral.SchluesseltabellenEintragQueryResponse.class), \r\n  })                                  \r\n  public javax.ws.rs.core.Response query(@javax.ws.rs.PathParam(\"parentId\") java.util.List<String> parentIds) throws Exception\r\n```\r\n\r\nI'm getting this swagger:\r\n\r\n```javascript\r\n\"/Services/Mischtabellen/{parentId}/query\" : {\r\n      \"get\" : {\r\n        \"tags\" : [ \"MischtabellenRessource\" ],\r\n        \"summary\" : \"Wer suchet, der findet\",\r\n        \"description\" : \"\",\r\n        \"operationId\" : \"MischtabellenQuery\",\r\n        \"produces\" : [ \"application/xml\", \"application/json\" ],\r\n        \"parameters\" : [ {\r\n          \"name\" : \"parentId\",\r\n          \"in\" : \"path\",\r\n          \"required\" : true,\r\n          \"type\" : \"array\",\r\n          \"items\" : {\r\n            \"type\" : \"string\"\r\n          },\r\n          \"collectionFormat\" : \"csv\"\r\n        } ],\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"OK\",\r\n            \"schema\" : {\r\n              \"$ref\" : \"#/definitions/SchluesseltabellenEintragQueryResponse\"\r\n            }\r\n          }\r\n        },\r\n        \"security\" : [ {\r\n          \"oauth\" : [ \"ess\" ]\r\n        } ]\r\n      }\r\n    }\r\n```\r\n\r\nThe relevant part of the generated client is this:\r\n\r\n```javascript\r\nESS.prototype.query = function (parentId, options, callback) {\r\n  var client = this;\r\n  if(!callback && typeof options === 'function') {\r\n    callback = options;\r\n    options = null;\r\n  }\r\n  if (!callback) {\r\n    throw new Error('callback cannot be null.');\r\n  }\r\n  // Validate\r\n  ...\r\n  // Construct URL\r\n  var requestUrl = this.baseUri +\r\n                   '//Services/Mischtabellen/{parentId:commaSeparated}/query';\r\n  requestUrl = requestUrl.replace('{parentId}', encodeURIComponent(parentId.toString()));\r\n```\r\nThe parameter `parentId` is an array and got validated correctly. In the `requestUrl` the `{parentId:commaSeparated}` should be replaced by the array in `parentId`. But the call `requestUrl.replace()` tries to replace `{parentId}` instead of `{parentId:commaSeparated}`. Hence the replacement never happenes and the called URL is wrong.\r\n\r\nFixing the replacement to `{parentId:commaSeparated}` works as expected.\r\n\r\nThe problem occurs in the NodeJS and CSharp client in the same way.\r\n\r\nThanks!\r\nAlex"},"comment":{"url":"https://api.github.com/repos/Azure/autorest/issues/comments/204859944","html_url":"https://github.com/Azure/autorest/issues/900#issuecomment-204859944","issue_url":"https://api.github.com/repos/Azure/autorest/issues/900","id":204859944,"user":{"login":"amarzavery","id":4521223,"avatar_url":"https://avatars.githubusercontent.com/u/4521223?v=3","gravatar_id":"","url":"https://api.github.com/users/amarzavery","html_url":"https://github.com/amarzavery","followers_url":"https://api.github.com/users/amarzavery/followers","following_url":"https://api.github.com/users/amarzavery/following{/other_user}","gists_url":"https://api.github.com/users/amarzavery/gists{/gist_id}","starred_url":"https://api.github.com/users/amarzavery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amarzavery/subscriptions","organizations_url":"https://api.github.com/users/amarzavery/orgs","repos_url":"https://api.github.com/users/amarzavery/repos","events_url":"https://api.github.com/users/amarzavery/events{/privacy}","received_events_url":"https://api.github.com/users/amarzavery/received_events","type":"User","site_admin":false},"created_at":"2016-04-03T03:09:52Z","updated_at":"2016-04-03T03:09:52Z","body":"@aschua - \r\n\r\nLet us assume that `var parentId = ['Foo', 'Bar', Baz'];`\r\nHow would you expect, the array value of `parentId` path parameter in this partial url `/Services/Mischtabellen/{parentId}/query`:\r\n\r\n- as a literal array with square brackets `/Services/Mischtabellen/ ['Foo', 'Bar', Baz']/query`\r\n- as a comma separated string `/Services/Mischtabellen/Foo,Bar,Baz/query`\r\n\r\nI think the second option is the correct approach if the collection format is specified as csv and if the collection format is not specified then the first option looks correct.\r\n\r\n@devigned @markcowl - Any thoughts?\r\n\r\nSome SO links: \r\n- http://stackoverflow.com/questions/9623258/passing-an-array-or-list-to-pathvariable-spring-java\r\n- http://stackoverflow.com/questions/4541338/how-to-construct-a-rest-api-that-takes-an-array-of-ids-for-the-resources\r\n\r\n"}}