Skip to content

Commit

Permalink
fix(api): generate string ID parameters for meters
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <[email protected]>
  • Loading branch information
sagikazarmark committed Oct 2, 2024
1 parent 9ef9f43 commit d7c68f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/spec/src/meters.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ enum WindowSize {
/**
* A unique meter identifier.
*/
alias MeterIdentifier = ULID | Key;
alias MeterIdentifier = ULIDOrKey;

/**
* Meter query parameters.
Expand Down
13 changes: 13 additions & 0 deletions api/spec/src/types.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d7c68f2

Please sign in to comment.