Azure / api-management-developer-portal

Developer portal provided by the Azure API Management service.
MIT License
478 stars 306 forks source link

ApiManagement API deployment: non required query parameters are wrongly added to the URL path #2446

Open alexanderameye opened 3 months ago

alexanderameye commented 3 months ago

Bicep version Bicep CLI version 0.26.54 (5e20b29b58)

Describe the bug I am using this code to deploy an API to APIM. I am using loadJsonContent to load in an OpenAPI spec (v3.0.1).

param openApiSpecContents = loadJsonContent('./open-api.json')

resource api 'Microsoft.ApiManagement/service/apis@2022-04-01-preview' = {
  name: name
  parent: service
  properties: {
    // other properties
    format: 'openapi+json'
    value: string(openApiSpecContents)
    translateRequiredQueryParameters: 'query'
  }
}

The API has an endpoint with 2 non-required parameters (iterationId and gln).

"parameters": [
    {
        "name": "iterationId",
        "in": "query",
        "schema": {
            "type": "string"
        }
    },
    {
        "name": "gln",
        "in": "query",
        "schema": {
            "type": "string"
        }
    }
]

I then deploy the API to APIM.

Expected The query parameters are set as being not required and as a result, they do not show up in the URL since they are not required.

Actual The query parameters show up as being not required which is correct image

But, they do show up in the URL path, and when I call the API without the query parameters, I get a 404, so the issue is that the parameters should not be added to the URL path since they are not required, but they are falsely added.

image

To Reproduce See steps above.