Firstly, let me thank you for the great library you have created.
I’m currently trying to make MIME-based versioning (via accept header) work in Tapir,
i.e. I would like to have an endpoint accepting 2 (or more) custom media types (e.g. application/resource-v1+json, application/resource-v2+json) and based on the accept header of the request answering a JSON representing resource of the desired version.
I can make the endpoint accept one custom version (application/resource-v1+json) – with custom codecs for the new media type.
Although, as soon as I define multiple media types in accept header of the endpoint, e.g.:
a high-level one, using oneOf inputs. Each variant’s body can have a different content type, and this should be used by tapir to implement content negotiation
a low-level one, by manually checking the Accept header. In your current code, you require that as part of the request, there’s an Accept header with the value equal to application/resource-v1+json, application/resource-v2+json - that’s what the fixed-header input does. And that’s also the behavior you are observing. Instead, you want to check that the header matches one of these values. The following input should do the trick:
This input checks that the value is in the allowed range, and reports a mismatch otherwise. In fact, I think adding an enumeration validator will be even better, as you should see the possibilities in the documentation: