Kyle Briggs
Kyle Briggs

Reputation: 103

Azure API Management Template parameters used in the UriTemplate must be defined in the Operation, and vice-versa

I have a number of Azure functions, that I would like to now put Azure API Management in front of.

I have imported all the functions from 2 or 3 of my other function apps in my account with no issues, but I am having issues with one of the function apps. This function app has 6 functions, 3 of which I can import fine if I select the specifically. Something within the other 3 functions is throwing an error:

All template parameters used in the UriTemplate must be defined in the Operation, and vice-versa.

Here the the relevant part of my Swagger api document created by the Azure Function itself:

    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: []

Looking through this, I have verified that all items in the parameters are in the paths. I am not sure if there is anything I am missing here, but looking around on the internet I did not see much regarding the issue.

Upvotes: 10

Views: 9626

Answers (2)

Matthias M
Matthias M

Reputation: 14950

There is an undefined parameter in your open api specifications.

Because Azure won't give you more details, you can use the swagger editor to validate your specifications. The editor will give you a detailed error message: enter image description here

See also 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/

Upvotes: 8

Vitaliy Kurokhtin
Vitaliy Kurokhtin

Reputation: 7840

Update (10/1/18): The issue is fixed. Clear browser cache if still reproducible.

Function App import at the moment does not use OpenAPI spec you've defined for Function App at all. Instead it consumes FunctionApp definition directly. The problem is caused by your functions having routes with parameters, like /route/{param}. This will be fixed shortly.

This should work now.

Upvotes: 0

Related Questions