[ARM] Introduce dedicated @@resourceRbacRoles decorator for RBAC role definitions
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
## Description
Currently, RBAC role definitions for Azure resources are passed through the generic `@@clientOption` decorator with the key `"resource-rbac-roles"`. This works but has several downsides:
1. **No type safety** — the value is an untyped record, so there's no validation that role names are valid identifiers or that GUIDs are well-formed
2. **No discoverability** — spec authors have no way to know this convention exists without reading generator source code
3. **Suppression noise** — `@@clientOption` emits `client-option` and `client-option-requires-scope` diagnostics that must be suppressed (see #4104)
4. **No cross-language support** — the `"csharp"` scope parameter makes it invisible to other language emitters that may want to use the same data
## Proposal
Introduce a dedicated `@@resourceRbacRoles` decorator (or similar) in `@azure-tools/typespec-azure-resource-manager` that:
- Takes a typed record of `Record` (role name → GUID)
- Validates that role names are valid identifiers
- Validates that GUIDs are well-formed
- Is visible to all language emitters by default
- Does not require diagnostic suppressions
### Example
```typespec
// Current workaround using @@clientOption:
#suppress "@azure-tools/typespec-client-generator-core/client-option" "..."
#suppress "@azure-tools/typespec-client-generator-core/client-option-requires-scope" "..."
@@clientOption(Vault, "resource-rbac-roles", #{
KeyVaultAdministrator: "00482a5a-887f-4fb3-b363-3b7fe8e74483",
KeyVaultContributor: "f25e0fa2-a7c8-4377-a976-54943a77a395",
}, "csharp");
// Proposed dedicated decorator:
@@resourceRbacRoles(Vault, #{
KeyVaultAdministrator: "00482a5a-887f-4fb3-b363-3b7fe8e74483",
KeyVaultContributor: "f25e0fa2-a7c8-4377-a976-54943a77a395",
});
```
## Context
This was discovered while implementing RBAC role generation for Azure Provisioning SDKs:
- Generator PR: https://github.com/Azure/azure-sdk-for-net/pull/57392
- Spec PR: https://github.com/Azure/azure-rest-api-specs/pull/41731
Contributor guide
Assessment
This issue has not been assessed yet.