【问题标题】:The Swagger version specified is unknown. Azure APIM ARM Template指定的 Swagger 版本未知。 Azure APIM ARM 模板
【发布时间】:2020-12-08 14:08:48
【问题描述】:

只有当我通过 ARM 模板部署时,当我从门户尝试成功时,我才会遇到这个问题。我认为问题可能与我正在使用的版本有关,所以我更改了模板中的最后 3 个版本(https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/service/apis),仍然是同样的问题。有人可以指出我这里出了什么问题吗?我添加了最小复制。

大摇大摆:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Test",
    "description": "Test",
    "version": "1.0"
  },
  "paths": {
    "/api/v1/test": {
      "get": {
        "tags": [
          "Test"
        ],
        "summary": "Test",
        "parameters": [
          {
            "name": "TestName",
            "in": "query",
            "schema": {
              "minLength": 3,
              "type": "string",
              "nullable": true
            }
          }
        ],
        "responses": {
          "500": {
            "description": "Server Error",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {

      "Error": {
        "type": "object",
        "properties": {
          "errorCode": {
            "type": "string",
            "nullable": true
          },
          "errorDescription": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }

    }
  }
}

ARM 模板

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "ApimServiceName": {
      "type": "string"
    }
  },
  "resources": [
    {
      "properties": {
        "serviceUrl": "https://test.url",
        "path": "projects",
        "value": ***"swaggerstorageaccounturl.json",***
        "format": "swagger-link-json"
      },
      "name": "[concat(parameters('ApimServiceName'), '/Test')]",
      "type": "Microsoft.ApiManagement/service/apis",
      "apiVersion": "2020-06-01-preview",
      "dependsOn": []
    }
  ]
}

当我尝试使用此处提到的 petstore 示例https://github.com/Azure/azure-quickstart-templates/blob/master/201-api-management-create-all-resources/azuredeploy.json#L139 时,它从模板和门户都成功。

【问题讨论】:

    标签: azure-devops openapi azure-api-management arm-template


    【解决方案1】:

    我已经让它工作了。问题是,对于开放 API 3.0.1,我们应该将格式指定为 openapi-link 而不是 swagger-json-link。这里提到, https://github.com/pulumi/pulumi-azure-nextgen/issues/160

     "properties": {
                    "serviceUrl": "https;//test.url",
                    "path": "test",
                    "value": "https://storageaccurl.json",
                    "format": "openapi-link"
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多