@armCommonDefinition(
"ManagedServiceIdentity",
{
version: Azure.ResourceManager.CommonTypes.Versions.v4,
isDefault: true,
},
"managedidentity.json"
)
@armCommonDefinition(
"ManagedServiceIdentity",
Azure.ResourceManager.CommonTypes.Versions.v5,
"managedidentity.json"
)
@doc("The properties of the managed service identities assigned to this resource.")
model ManagedIdentityProperties {
@doc("The Active Directory tenant id of the principal.")
@visibility("read")
tenantId?: string;
@doc("The active directory identifier of this principal.")
@visibility("read")
principalId?: string;
@doc("The type of managed identity assigned to this resource.")
type: ManagedIdentityType;
@doc("The identities assigned to this resource by the user.")
userAssignedIdentities?: Record<UserAssignedIdentity>;
}
"identity": {
"$ref": "../../../../../common-types/resource-management/v4/managedidentity.json#/definitions/ManagedServiceIdentity",
"description": "The managed service identities assigned to this resource."
}
We ask typespec-azure-resource-manager to fix the mismatched model property(ManagedServiceIdentityType instead of ManagedIdentityType).
Reason: Why define the model and its properties if it's properties are wrong?
Con: Each version(e.g. v4, v5) may have common models different from each other.
We replace the model with the common referenced one(like m4 did).
Reason: Totally align with current swagger.
Con: Needs more effort. Do we want to implement it ourselves? Or do we do it in TCGC?
Hard code the property names, make it predefined models in codegen.
Reason: Easiest way.
Con: same as 1.
Network analytics: https://github.com/Azure/azure-rest-api-specs/blob/f776434f63fb6505926273db8d4f9a93b75ee4a1/specification/networkanalytics/NetworkAnalytics.Management/main.tsp#L147
After spreading, it's a model decorated with
@armCommonDefinition
: https://github.com/Azure/typespec-azure/blob/ebfe63960277356c611f15b2404a0ae6f2d9e6ed/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp#L363-L377typespec-autorest
will generate it to refer to the common model: https://github.com/Azure/azure-rest-api-specs/blob/f776434f63fb6505926273db8d4f9a93b75ee4a1/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/networkanalytics.json#L1617Their name and properties defer:
ManagedServiceIdentity
(swagger) vsManagedIdentityProperties
(tsp).ManagedIdentityProperties
has@armCommonDefinition
, maybe it can be solved by getting the decorator value.ManagedServiceIdentityType
(swagger) vsManagedIdentityType
(tsp)ManagedIdentityType
doesn't have@armCommonDefinition
on it.. This one's trickier.Potential solution
typespec-azure-resource-manager
to fix the mismatched model property(ManagedServiceIdentityType instead of ManagedIdentityType). Reason: Why define the model and its properties if it's properties are wrong? Con: Each version(e.g. v4, v5) may have common models different from each other.