softwaremill / tapir

Rapid development of self-documenting APIs
https://tapir.softwaremill.com
Apache License 2.0
1.36k stars 411 forks source link

[BUG] route won't match if `extractFromRequest` is followed by a static path or path parameter input #3907

Closed phfroidmont closed 3 months ago

phfroidmont commented 3 months ago

Tapir version: v1.10.12

Scala version: 3.3.3

Describe the bug With zio-http interpreter, if I use an extractFromRequest input followed by a static path and/or path parameter, it won't match any request.

How to reproduce? The following route won't match any request (GET /fr/myroute/test for instance)

ZioHttpInterpreter().toHttp(
  endpoint.get
    .in(path[String])
    .in(extractFromRequest(_.method))
    .in("myroute" / path[String])
    .out(htmlBodyUtf8)
    .zServerLogic(i => ZIO.succeed(s"""<div>$i</div>"""))
)

If I replace .in("myroute" / path[String]) by .in(paths) it matches fine.

Additional information I've rolled back to Tapir v1.10.10 for now, and it works fine. I suspect the culprit is around here: https://github.com/softwaremill/tapir/blame/951d7360de9c3f4c02207bb5c019055e0fa6845a/server/zio-http-server/src/main/scala/sttp/tapir/server/ziohttp/ZioHttpInterpreter.scala#L100C28-L100C42

phfroidmont commented 3 months ago

Thank you !