首页 > 解决方案 > 蔚蓝阿皮姆。根据 openapi 定义在模式中创建操作

问题描述

我必须创建一个架构,然后才能在 Azure APIM 中创建操作。我知道需要使用的代码是:

resource "azurerm_api_management_api_schema" "example" {
      api_name            = azurerm_api_management_api.sample-api.name
      api_management_name = azurerm_api_management_api.sample-api.api_management_name
      resource_group_name = azurerm_api_management_api.sample-api.resource_group_name
      schema_id           = "example-schema"
      content_type        = "application/vnd.oai.openapi.components+json"
      value               = <<JSON
      {
    "properties": {
        "contentType": "application/vnd.oai.openapi.components+json",
        "document": {
          "components": {
            "schemas": {
              operation Get 1
              operation Get 2
              operation post 1.....

但是我应该如何从这个 openapi 定义中提取 Get 和 POST 操作并将它们包含在该架构中? https://github.com/RaphaelYoshiga/TerraformBasics/blob/master/conference-api.json

到目前为止,我还没有找到一个明确的例子。

标签: azureterraformazure-api-management

解决方案


下面是使用 apim 服务的 Azure apim 操作示例

data "azurerm_api_management_api" "example" {
  name                = "search-api"
  api_management_name = "search-api-management"
  resource_group_name = "search-service"
  revision            = "2"
}

resource "azurerm_api_management_api_operation" "example" {
  operation_id        = "user-delete"
  api_name            = data.azurerm_api_management_api.example.name
  api_management_name = data.azurerm_api_management_api.example.api_management_name
  resource_group_name = data.azurerm_api_management_api.example.resource_group_name
  display_name        = "Delete User Operation"
  method              = "DELETE"
  url_template        = "/users/{id}/delete"
  description         = "This can only be done by the logged in user."

  response {
    status_code = 200
  }
}

欲了解更多信息,请查看此


推荐阅读