akka/akka-http

Parameters directive (and maybe also formFields?) should (optionally?) report all malformed fields

Open

#1,490 opened on 2017年10月24日

GitHub で見る
 (5 comments) (0 reactions) (0 assignees)Scala (598 forks)batch import
1 - triagedhelp wantedt:routing

Repository metrics

Stars
 (1,311 stars)
PR merge metrics
 (平均マージ 1d 10h) (30d で 2 merged PRs)

説明

I have (OData) query params defined in my route like so:

parameters(('$top.as[Int].?, '$skip.as[Int].?)) { (top, skip) =>

I have the following rejection handler to handle all invalid parameters (handleAll):

RejectionHandler.newBuilder()
  .handleAll[MalformedQueryParamRejection] { paramRejections =>
    // paramRejections is a Seq[MalformedQueryParamRejection]
    ...
  }

The problem is that when called with the following

some-endpoint?$top=invalid&$skip=invalid

The paramRejections in the rejection handler has 2 entries, both for $top, instead of one for $top and one for $skip.

Seems related to the dollar sign on the params, since when I remove this things work as expected. Is this a known issue or is there a workaround available (that doesn't include removing the dollar sign; clients should be allowed to use dollar sign, as per OData standards odata.org/documentation/odata-version-2-0/uri-conventions)

Note, it seems its only the RejectionHandler that has a problem with multiple params starting with the dollar sign, since this line in the route correctly assigns top and skip to the variables when $top and $skip are supplied with valid values in the URI:

parameters(('$top.as[Int].?, '$skip.as[Int].?)) { (top, skip) =>

コントリビューターガイド