Open wyatt-herkamp opened 2 weeks ago
Okay, I am not quite sure what are you after with this? This seems to be quite special case and is not something that is generic for all users of utoipa?
Basically you should be able to set pattern or regex patterns on new types. Specifically a new type string
On Sun, Oct 20, 2024, 10:11 AM Juha Kukkonen @.***> wrote:
Okay, I am not quite sure what are you after with this? This seems to be quite special case and is not something that is generic for all users of utoipa?
— Reply to this email directly, view it on GitHub https://github.com/juhaku/utoipa/issues/1150#issuecomment-2424988829, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ5NZ2RUBB433GZE4IFQY3Z4O2YJAVCNFSM6AAAAABQFY3OXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRUHE4DQOBSHE . You are receiving this because you authored the thread.Message ID: @.***>
So for example
#[derive(ToSchema)]
#[schema(pattern = r#"^([a-zA-Z0-9_\-]{3,32}$)"#)]
struct Username(String);
It would generate the code like the above.
P.S I noticed that the way I worded my original issue was confusing.
Right, now I get it. thanks :slightly_smiling_face: This seems duplicate for this https://github.com/juhaku/utoipa/issues/572.
If you find time please go ahead and submit a PR. This should be quite simple to do. It would need the unnamed struct features to parse some of those features currently parsed by named field features. It would be beneficial to add not just pattern, but other useful features as well.
The ability to apply pattern to new types(Tuple structs with only one data type)
I am willing to add this feature. But I won't be able to look at it til next week.