# Wildcard and concrete paths result in shadowed endpoints in Tapir, but are allowed in openapi spec

**URL:** <https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143>\
**Category:** tapir\
**Created:** [March 1, 2023, 8:53pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143 "2023-03-01T20:53:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bclouser](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/bclouser/32/108_2.png) [@bclouser](https://softwaremill.community/u/bclouser)\
**Post date:** [March 1, 2023, 8:53pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143/1 "2023-03-01T20:53:04Z")

</div>

Hello, I have been trying to get some clarity surrounding tapir’s pattern matching when wildcards are in the mix, but i haven’t yet found a precise answer to this in tapir.

If i have one path like `devices/{deviceId}` (where deviceId is a UUID, or an int, or any type)  
and then another like `devices/networking`

It will fail validations because `devices/networking` is shadowed by `devices/{deviceId}`. This makes sense, except that per openapi spec on “Path Templating Matching” ([OpenAPI Specification - Version 3.0.3 | Swagger](https://swagger.io/specification/)) it actually should work, and apparently match the concrete path first (`devices/networking`).

So my question becomes, is this expected behavior from Tapir?

---

<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:** [March 2, 2023, 4:45pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143/2 "2023-03-02T16:45:45Z")

</div>

Tapir’s server interpreters try to decode endpoints in the order in which they are given. So there’s no reordering, or checking which path is more specific.

So we don’t implement it the way that OpenAPI describes. Might be a candidate feature for 2.0 🙂

---

<div class="post-metadata">

**Author:** ![bclouser](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/bclouser/32/108_2.png) [@bclouser](https://softwaremill.community/u/bclouser)\
**Post date:** [March 2, 2023, 6:30pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143/3 "2023-03-02T18:30:14Z")

</div>

Ok cool! I just wanted to get a decisive answer on whether or not Tapir will allow such routes to work and whether or not the problem is my usage of Tapir vs Tapir Itself.

It’s not me! 😄

Thanks so much!

---

<div class="post-metadata">

**Author:** ![bclouser](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/bclouser/32/108_2.png) [@bclouser](https://softwaremill.community/u/bclouser)\
**Post date:** [March 2, 2023, 7:55pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143/4 "2023-03-02T19:55:28Z")

</div>

I should clarify. I was able to modify the order of documentation endpoints to avoid the “shadow” validation-error which is mostly what my original question deals with.

However, i was not able to change the order of the tapir routes (at least in akka-http) so that my requests would be parsed as i intended with concrete vs wildcard endpoints. I’m trying to dig into the code and see exactly how tapir routes are translated into akka routes to better understand why this is… however it’s not trivial (for me anyways).

---

<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:** [March 2, 2023, 8:15pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143/5 "2023-03-02T20:15:02Z")

</div>

It should be enough to change the ordering of endpoints on the list that is being passed to the interpreter. E.g.:

```plaintext
val deviceIdEndpoint = ...
val networkingEndpoint = ...

AkkaHttpInterpreter().toRoutes(List(networkingEndpoint, deviceIdEndpoint))

```

---

<div class="post-metadata">

**Author:** ![bclouser](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/bclouser/32/108_2.png) [@bclouser](https://softwaremill.community/u/bclouser)\
**Post date:** [March 3, 2023, 8:59pm UTC](https://softwaremill.community/t/wildcard-and-concrete-paths-result-in-shadowed-endpoints-in-tapir-but-are-allowed-in-openapi-spec/143/6 "2023-03-03T20:59:38Z")

</div>

yeahhhhh, turns out I had some other stuff broken causing me to think this didn’t work. 😒

It does indeed work as you pointed out. Thanks!
