How to handle extraction of two or more variables within single path segment?

The issue that I came across is that the input does not support defining advanced use cases of URI matching, such as the following:

  • multiple path variables in the same path segment, e.g., /people/{firstName}-{lastName}/SSN
  • extractor and literal within the same path segment, e.g. /people/{firstName}-some-literal/SSN or /people/some-literal-{firstName}/SSN

Just for reference: Micronaut Framework, Many other frameworks, including Spring, Quarkus, ktor, dotnet, actix-web, implement the URI template specification. But no single scala HTTP library is capable of that.

The expectation is to have something like this:

It seems that it is not possible right now to define a route that will follow Resource Oriented API with custom methods, more details here

I would like to know if it is possible to achieve this with tapir. Thanks

I am particularly interested in the implementation of the API in accordance with the specifications outlined in AIP-136, which can be found at AIP-136: Custom operations.
The main goal is to guarantee precise documentation, and I’m pleased that Tapir offers this capability. However, does this specific requirement appear to be an edge case?

Currently in tapir this is not possible - each path segment is either a capture or a fixed string.

The closest you could get is by mapping over a regular path capture and extracting the values (otherwise - if the value doesn’t match the template - reporting a decode failure). However, this has two downsides:

(1) the OpenAPI spec & docs will show a single path segment, which might have a description, but it’s not the same as separate path params
(2) you won’t be able to create two endpoints with different templates within a single segment, but otherwise identical

Maybe you could open a GitHub issue? This sounds like a good addition to tapir (since, as you mention, everybody else has it), but wouldn’t be trivial. With an issue we could also see how many other people would like to see the feature added, and prioritise accordingly. Thanks!