【问题标题】:How to use Azure API Management portal or API to edit the description string for Ocp-Apim-Subscription-Key in the Request Header?如何使用 Azure API 管理门户或 API 编辑请求标头中 Ocp-Apim-Subscription-Key 的描述字符串?
【发布时间】:2018-04-05 18:56:12
【问题描述】:

我正在寻找一种方法来使用 Azure API 管理(管理门户或 API 调用)来编辑 Ocp-Apim-Subscription-Key 请求标头字段的文本描述。该字符串显示在自动生成的文档中,但我不知道它的设置位置。到目前为止,我已经尝试在 swagger 文件和 API Management Publisher Portal 中查找 Ocp-Apim-Subscription-Key 的描述字符串,但一直找不到。

这是一个屏幕截图,突出显示了生成的 API 文档中我要编辑的字段:

这是 Azure API 管理发布者门户中的页面,我在该页面中查找了“请求标头”部分但找不到它:

有关 Azure API 管理的问题的其他答案让我想知道是否有 REST API 调用来编辑此字符串(如果它在发布者门户中不可用),但我似乎无法找到有关它的 API 文档的活动链接.

【问题讨论】:

  • 我在开发者门户中检查了“操作”模板。似乎特定文本没有直接包含在模板中 - 它是由后端在进入模板的数据结构中提供的。

标签: documentation-generation azure-api-management


【解决方案1】:

我为此使用了 Azure PowerShell。先决条件是您已登录 (Login-AzureRmAccount) 并选择了您的订阅 (Select-AzureRmSubscription)。

 $ApiMgmtContext = New-AzureRmApiManagementContext -ResourceGroupName $resourceGroup -ServiceName $serviceName

if($ApiMgmtContext)
{
    foreach($apiEntry in (Get-AzureRmApiManagementApi -Context $ApiMgmtContext))
    {
        $api = Get-AzureRmApiManagementApi -Context $ApiMgmtContext -ApiId $apiEntry.ApiId

        Write-Host "setting header for" $api.Name

        $api.SubscriptionKeyHeaderName = "MyApi-Subscription-Key"
        $api | Set-AzureRmApiManagementApi -Context $ApiMgmtContext
    }
}

【讨论】:

  • 谢谢 - 似乎这可以设置标题名称,将其从原来的 Ocp-Apim-Subscription-Key 更改为 MyApi-Subscription-Key。有没有办法也设置与此标头关联的描述?例如,如果生成的文档中的原始描述显示“在认知服务中查找此密钥”,而我想将其更改为“在帐户设置中查找此密钥”?
  • 对不起@DeniseMak,我没有仔细阅读您的问题,并跳出了另一个解决方案。
猜你喜欢
  • 2021-06-01
  • 1970-01-01
  • 2021-12-22
  • 2018-04-04
  • 1970-01-01
  • 2017-04-13
  • 2016-12-04
  • 2020-03-16
  • 1970-01-01
相关资源
最近更新 更多