# Paths components without \`\`/\`\` separator

**URL:** <https://softwaremill.community/t/paths-components-without-separator/317>\
**Category:** tapir\
**Created:** [November 3, 2023, 7:08pm UTC](https://softwaremill.community/t/paths-components-without-separator/317 "2023-11-03T19:08:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jni](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jni](https://softwaremill.community/u/jni)\
**Post date:** [November 3, 2023, 7:08pm UTC](https://softwaremill.community/t/paths-components-without-separator/317/1 "2023-11-03T19:08:12Z")

</div>

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:

```auto
  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)

```

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [November 3, 2023, 8:21pm UTC](https://softwaremill.community/t/paths-components-without-separator/317/2 "2023-11-03T20:21:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jni](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jni](https://softwaremill.community/u/jni)\
**Post date:** [November 4, 2023, 9:22am UTC](https://softwaremill.community/t/paths-components-without-separator/317/3 "2023-11-04T09:22:29Z")

</div>

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:

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [November 6, 2023, 7:06pm UTC](https://softwaremill.community/t/paths-components-without-separator/317/4 "2023-11-06T19:06:33Z")

</div>

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