Currently, we will use @path to decorate the resource key property to make the generated swagger right.
e.g.,
@doc("A ContosoProviderHub resource")
model Employee is TrackedResource<EmployeeProperties> {
@doc("Name of employee")
@pattern("^[a-zA-Z0-9-]{3,24}$")
@key("employeeName")
@path
@segment("employees")
name: string;
}
"Employee": {
"type": "object",
"description": "A ContosoProviderHub resource",
"properties": {
"properties": {
"$ref": "#/definitions/EmployeeProperties",
"description": "The resource-specific properties for this resource.",
"x-ms-client-flatten": true,
"x-ms-mutability": [
"read",
"create"
]
}
},
"allOf": [
{
"$ref": "../../common-types/resource-management/v5/types.json#/definitions/TrackedResource"
}
]
}
But for TSP ARM template, TrackedResource does not contain name property, while emitter will filter any property with @path, thus result to the final generated model losing the name property. This will not happen for .NET as they will have core resource model, but for some languages such as Go will generate resource model directly from the TSP definition.
/**
* Base model that defines common properties for all ARM resources.
*/
@doc("Common properties for all ARM resources.")
model ArmResource extends ArmResourceBase {
@doc("Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}")
@visibility("read")
id: string;
// The name property must be included by the resource type author!
@doc("The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"")
@visibility("read")
type: string;
@doc("Azure Resource Manager metadata containing createdBy and modifiedBy information.")
@visibility("read")
systemData?: SystemData;
}
/** Base class used for type definitions */
model ArmResourceBase {}
/**
* The base tracked resource.
*/
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v5)
@doc("The resource model definition for an Azure Resource Manager tracked top level resource")
model TrackedResourceBase extends ArmResource {
@doc("The geo-location where the resource lives")
@visibility("read", "create")
location: string;
...ArmTagsProperty;
}
Currently, we will use
@path
to decorate the resource key property to make the generated swagger right. e.g.,But for TSP ARM template,
TrackedResource
does not containname
property, while emitter will filter any property with@path
, thus result to the final generated model losing thename
property. This will not happen for .NET as they will have core resource model, but for some languages such as Go will generate resource model directly from the TSP definition.