You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Scalatra] collectionFormat=csv not handled correctly #3806
val assayIdsString = params.getAs[String]("assayIds")
val assayIds = if("csv".equals("default")) {
assayIdsString match {
case Some(str) => str.split(",")
case None => List()
}
}
else
List()
The main issue here is that the comparison "csv" == "default" will clearly never be true, so the string will never be split. We will always get an empty list back.
According to the swagger specification, supported values for collectionFormat are 'csv', 'tsv', 'ssv', 'pipes' and 'multi'.
This is in the latest github snapshot.
A secondary issue is that the type of assayIds is inferred to be simply Serializable in this case, which is not very helpful (the value becomes unusable). This is because Array[String] and List[Any] do not unify to a common supertype.
This can be solved, for example, by generating either this code (which I tested):
assayIdsString match {
case Some(str) => str.split(",").toSeq
case None => Seq()
}
Or this:
assayIdsString match {
case Some(str) => str.split(",")
case None => Array[String]()
}
I could, but I'm not confident that I know how the main issue should be addressed.
Probably, this codegen only supports the csv format so far (?) and I could fix that, but if so, the other formats would remain unsupported.
Activity
wing328 commentedon Sep 16, 2016
@jtnystrom thanks for reporting the issue. Would you please submit a PR so that we can review the change?
jtnystrom commentedon Sep 16, 2016
I could, but I'm not confident that I know how the main issue should be addressed.
Probably, this codegen only supports the csv format so far (?) and I could fix that, but if so, the other formats would remain unsupported.
wing328 commentedon Sep 19, 2016
If there're demand to support other formats, we can ask the contributors to file a fix with reference to the enhancement you're going to make.
jtnystrom commentedon Sep 19, 2016
OK - I will try to submit something this week. Thanks.
bull-xu commentedon Oct 16, 2016
This is also issue for generating Swift code. AlamofireRequestBuilder passes in Alamofire.ParameterEncoding.URL encoding type, and Alamofire ParameterEncoding is using
queryComponents("\(key)[]", value)which not a single value ofcomma separated values foo,bar.described in http://swagger.io/specification/wing328 commentedon Oct 17, 2016
@bull-xu-stride for the issue with the
swiftAPI client, please kindly open a separate issue for tracking.jtnystrom commentedon Dec 19, 2016
I've just submitted a PR for this.