Now that we have that cleared, let’s make a plan for what we actually want to do.
Steps to perform
Adjust the URL parameter descriptions of {ID} to mark them as a kind of UUID.
Adjust the ID attribute of our Product model to mark it as a kind of UUID.
Adjust the lang attribute of our Translation model to mark it as an ISO-639-1 language code.
How can we do that?
Using regular expression from refined type
If we take a look at the code within the tapir library, we see that the Schema and SchemaFor code, which is used for codecs does not yet support a dedicated UUID type. There is a detour for it using Schema.SString.
Currently, there is active discussion about changing and extending the schema code in tapir regarding more future possibilities and better documentation options.
Now, we look a bit further into the OpenAPI code and find that it supports several interesting attributes that we might use. For now, we will stick to the attribute pattern of the Schema class in that part. It is intended to hold a pattern (regular expression) that describes the format of a string type. We need to define some (or better, exactly 2) regular expressions. We already have one for our language code!
How do we use the existing regular expression from our refined type? Using some shapeless magic, we might use an implicit Witness, which should be provided by our refined type.