From d7c68f28ae939d4ece584eb6c39f2a235600c3c4 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Wed, 2 Oct 2024 13:08:52 +0200 Subject: [PATCH] fix(api): generate string ID parameters for meters Signed-off-by: Mark Sagi-Kazar --- api/spec/src/meters.tsp | 2 +- api/spec/src/types.tsp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/spec/src/meters.tsp b/api/spec/src/meters.tsp index f3e73c423..3175498bf 100644 --- a/api/spec/src/meters.tsp +++ b/api/spec/src/meters.tsp @@ -194,7 +194,7 @@ enum WindowSize { /** * A unique meter identifier. */ -alias MeterIdentifier = ULID | Key; +alias MeterIdentifier = ULIDOrKey; /** * Meter query parameters. diff --git a/api/spec/src/types.tsp b/api/spec/src/types.tsp index b02731250..162caa717 100644 --- a/api/spec/src/types.tsp +++ b/api/spec/src/types.tsp @@ -17,6 +17,19 @@ scalar ULID extends string; @maxLength(64) scalar Key extends string; +/** + * ULID (Universally Unique Lexicographically Sortable Identifier). + * A key is a unique string that is used to identify a resource. + * + * TODO: this is a temporary solution to support both ULID and Key in the same spec for codegen. + */ +@pattern( + "^[a-z0-9]+(?:_[a-z0-9]+)*$|^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$", +) +@minLength(1) +@maxLength(64) +scalar ULIDOrKey extends string; + // NOTE (andras): key format enforcement isn't supported by TypeSpec (patternProperties). See: https://github.com/microsoft/typespec/discussions/1626 /** * Set of key-value pairs.