Azure / Azure/autorest.powershell

Fix incorrect usage of x-ms-parameterized-host across specs

Open
#458 0 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
C#
Stars
123
Forks
99
PR merge metrics
No merged PRs in 30d

Description

(we may end up transferring this issue to the specs repository)

There are cases of an `x-ms-parameterized-host` property being incorrectly modeled in a service's spec. For example, KeyVault has the following set:

```
"x-ms-parameterized-host": {
"hostTemplate": "{vaultBaseUrl}",
"useSchemePrefix": false,
"positionInOperation": "first",
"parameters": [
{
"name": "vaultBaseUrl",
"description": "The vault name, for example https://myvault.vault.azure.net.",
"required": true,
"type": "string",
"in": "path",
"x-ms-skip-url-encoding": true
}
]
}
```

This results in the generation of a `-VaultBaseUrl` parameter for all KeyVault data plane cmdlets; however, we would ideally break down this URL into two components: vault name and suffix. This would look like the following:

```
"x-ms-parameterized-host": {
"hostTemplate": "https://{vaultName}.{keyVaultDnsSuffix}/",
"useSchemePrefix": false,
"positionInOperation": "first",
"parameters": [
{
"name": "vaultName",
"description": "The name of the vault to execute operations on.",
"required": true,
"type": "string",
"in": "path",
"x-ms-skip-url-encoding": true
},
{
"name": "keyVaultDnsSuffix",
"description": "The URI used as the base for all key vault requests.",
"required": true,
"type": "string",
"in": "path",
"x-ms-skip-url-encoding": true,
"default": "vault.azure.net",
"x-ms-parameter-location": "client"
}
]
}
```

This results in the generation of both `-VaultName` and `-KeyVaultDnsSuffix` parameters for KeyVault data plane cmdlets, and from here, we can use default parameters to assign the value to `-KeyVaultDnsSuffix` based on the default context's environment and allow the user to provide a value for `-VaultName`.

This reformatting of the `x-ms-parameterized-host` should be done for any other service that does not correctly make this split.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.