Paths components without ``/`` separator

Hi, I have an endpoint that looks like this: /foo/<param>.json.

I am not sure how to describe path components not separated by a / ?

I used this workaround but it’s a bit ugly:

  val ep = endpoint.in("foo" / pathWithSuffix[LocalDate]("bar", ".json"))

  def pathWithSuffix[T](name: String, suffix: String)(using c: PlainCodec[T]): EndpointInput.PathCapture[T] =
    path[String](name)
      .map(_.stripSuffix(suffix))(_ + suffix)
      .mapDecode(c.rawDecode)(c.encode)

Path segments are always separated by a / - I think your solution is the correct one from tapir’s point of view.

OK, do you think it is worth an addition to the tapir DSL ? Maybe I can come up with some syntax on PathCapture to end up like:

endpoint.in("foo" / path[T]("bar").withPrefix("baz"))
endpoint.in("foo" / path[T]("bar").withSuffix(".json"))
endpoint.in("foo" / path[T]("bar").surroundedBy("baz", ".json"))

Or in the style of scodec:

endpoint.in("foo" / "baz" ~ path[T]("bar"))
endpoint.in("foo" / path[T]("bar") ~ ".json")
endpoint.in("foo" / "baz" ~ path[T]("bar") ~ ".json")

Sure, this might be a good idea :slight_smile: I think I prefer the named variants much more (withPrefix etc.). The withSuffix should be especially useful.