UriTemplate 中使用的 Azure API 管理模板参数必须在操作中定义,反之亦然

标签 azure swagger azure-functions azure-api-management

我有许多 Azure 功能,现在我想将 Azure API 管理放在前面。

我已从帐户中的 2 个或 3 个其他函数应用导入所有函数,没有出现任何问题,但其中一个函数应用出现问题。这个功能应用程序有 6 个功能,如果我专门选择其中 3 个功能,我可以很好地导入。其他 3 个函数中的某些内容抛出错误:

UriTemplate 中使用的所有模板参数都必须在操作中定义,反之亦然。

这是由 Azure Function 本身创建的 Swagger api 文档的相关部分:

    paths:
'/api/api-keys/{customerId}':
    delete:
    operationId: '/api/api-keys/{customerId}/delete'
    produces: []
    consumes: []
    parameters:
        - name: customerId
        in: path
        required: true
        type: string
    description: >-
        Replace with Operation Object
        #http://swagger.io/specification/#operationObject
    responses:
        '200':
        description: Success operation
    security:
        - apikeyQuery: []
'/api/api-keys/{customerId}/{apiKeyId}':
    delete:
    operationId: '/api/api-keys/{customerId}/{apiKeyId}/delete'
    produces: []
    consumes: []
    parameters:
        - name: customerId
        in: path
        required: true
        type: string
        - name: apiKeyId
        in: path
        required: true
        type: string
    description: >-
        Replace with Operation Object
        #http://swagger.io/specification/#operationObject
    responses:
        '200':
        description: Success operation
    security:
        - apikeyQuery: []
'/api/password-hashes/{customerId}/{prefix}':
    get:
    operationId: '/api/hashes/{customerId}/{prefix}/get'
    produces: []
    consumes: []
    parameters:
        - name: customerId
        in: path
        required: true
        type: string
        - name: prefix
        in: path
        required: true
        type: string
    description: >-
        Replace with Operation Object
        #http://swagger.io/specification/#operationObject
    responses:
        '200':
        description: Success operation
    security:
        - apikeyQuery: []

通过这个,我已经验证了参数中的所有项目都在路径中。我不确定这里是否有什么遗漏,但在互联网上环顾四周,我没有看到太多关于这个问题的信息。

最佳答案

您的开放 API 规范中存在未定义的参数。

由于 Azure 不会向您提供更多详细信息,因此您可以使用 swagger editor验证您的规范。 编辑器会给你详细的错误信息: enter image description here

另请参阅https://jamesradley.co.uk/2020/04/16/azure-api-management-template-parameters-used-in-the-uritemplate-must-be-defined-in-the-operation-and-vice-versa/

关于UriTemplate 中使用的 Azure API 管理模板参数必须在操作中定义,反之亦然,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52264027/

相关文章:

node.js - 在 MAC 上本地运行定时器触发的 azure 函数(在 docker 中)

powershell - 使用 Azure Powershell 函数列出我的所有 Azure 网站

sharepoint-2010 - 运行 Azure VM 的两个实例

c# - 如何获取Azure中容器中所有blob的列表?

具有单个端点的多个响应的 RESTful 设计

maven - 在 OpenAPI 规范定义中使用 Artifact 版本号

azure-functions - 从 API A、B、C 获取数据并将它们推送到 API X

Azure Devops 没有这样的文件或目录

msbuild - TeamCity 在幕后向 MSBuild 传递哪些参数?

c# - Byte[] 在 REST API 中作为 base64 返回