指定的Swagger版本未知.Azure APIM ARM模板



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

Swagger:

{
"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,它从模板和门户网站都获得了成功。

我已经让它工作了。问题是,对于开放的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"
}

最新更新