diff --git a/.chronus/changes/azure-location-2024-6-9-16-54-5.md b/.chronus/changes/azure-location-2024-6-9-16-54-5.md new file mode 100644 index 0000000000..0746ccb477 --- /dev/null +++ b/.chronus/changes/azure-location-2024-6-9-16-54-5.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +LocationResourceParameter should be azureLocation instead of string \ No newline at end of file diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 25d0cfc0f9..c9c685550d 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -187,9 +187,9 @@ model Azure.ResourceManager.ArmLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ----------------------------- | -| location | `string` | The name of the Azure region. | +| Name | Type | Description | +| -------- | -------------------- | ----------------------------- | +| location | `Core.azureLocation` | The name of the Azure region. | ### `ArmLroLocationHeader` {#Azure.ResourceManager.ArmLroLocationHeader} @@ -657,9 +657,9 @@ model Azure.ResourceManager.ResourceGroupLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ----------------------------- | -| location | `string` | The name of the Azure region. | +| Name | Type | Description | +| -------- | -------------------- | ----------------------------- | +| location | `Core.azureLocation` | The name of the Azure region. | ### `ResourceInstanceParameters` {#Azure.ResourceManager.ResourceInstanceParameters} @@ -851,9 +851,9 @@ model Azure.ResourceManager.SubscriptionLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ----------------------------- | -| location | `string` | The name of the Azure region. | +| Name | Type | Description | +| -------- | -------------------- | ----------------------------- | +| location | `Core.azureLocation` | The name of the Azure region. | ### `TenantLocationResource` {#Azure.ResourceManager.TenantLocationResource} @@ -866,9 +866,9 @@ model Azure.ResourceManager.TenantLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ----------------------------- | -| location | `string` | The name of the Azure region. | +| Name | Type | Description | +| -------- | -------------------- | ----------------------------- | +| location | `Core.azureLocation` | The name of the Azure region. | ### `TrackedResource` {#Azure.ResourceManager.TrackedResource} @@ -1216,9 +1216,9 @@ model Azure.ResourceManager.CommonTypes.LocationResourceParameter #### Properties -| Name | Type | Description | -| -------- | -------- | ----------------------------- | -| location | `string` | The name of the Azure region. | +| Name | Type | Description | +| -------- | -------------------- | ----------------------------- | +| location | `Core.azureLocation` | The name of the Azure region. | ### `ManagedServiceIdentity` {#Azure.ResourceManager.CommonTypes.ManagedServiceIdentity} diff --git a/packages/samples/common-types/gen.ts b/packages/samples/common-types/gen.ts index 84f120d859..24dccbfb67 100644 --- a/packages/samples/common-types/gen.ts +++ b/packages/samples/common-types/gen.ts @@ -81,21 +81,22 @@ function cleanupDocument(original: OpenAPI2Document): OpenAPI2Document { } document.paths = {}; - replaceUuidRefs(document); + replaceUuidRefs(document, "Azure.Core.uuid"); + replaceUuidRefs(document, "Azure.Core.azureLocation"); return document; } -function replaceUuidRefs(document: OpenAPI2Document) { - if (document.definitions?.["Azure.Core.uuid"]) { - const uuidDef = document.definitions["Azure.Core.uuid"]; - delete document.definitions["Azure.Core.uuid"]; +function replaceUuidRefs(document: OpenAPI2Document, refId: string) { + if (document.definitions?.[refId]) { + const refDef = document.definitions[refId]; + delete document.definitions[refId]; for (const definition of Object.values(document.definitions)) { for (const property of Object.values(definition.properties || {})) { - if ("$ref" in property && property.$ref === "#/definitions/Azure.Core.uuid") { + if ("$ref" in property && property.$ref === `#/definitions/${refId}`) { delete (property as any).$ref; - Object.assign(property, { ...uuidDef, ...property }); + Object.assign(property, { ...refDef, ...property }); } } } diff --git a/packages/typespec-azure-resource-manager/lib/common-types/types.tsp b/packages/typespec-azure-resource-manager/lib/common-types/types.tsp index ed32e5828a..d8c386b134 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/types.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/types.tsp @@ -515,7 +515,7 @@ model LocationResourceParameter { @minLength(1) @segment("locations") @key - location: string; + location: azureLocation; } /**