Why does Azure API Management OpenAPI 2.0 JSON Export of our API include a securityDefinitions object sometimes?

Jeff Hellman 5 Reputation points
2025-02-20T17:32:39.6033333+00:00

We have an API defined in APIM that when we do an OpenAPI 2.0 export of the JSON it sometimes returns a securityDefinitions object that includes the subscription keys (example below):

    "securityDefinitions": {
        "apiKeyHeader": {
            "type": "apiKey",
            "name": "Ocp-Apim-Subscription-Key",
            "in": "header"
        },
        "apiKeyQuery": {
            "type": "apiKey",
            "name": "subscription-key",
            "in": "query"
        }
    },
    "security": [
        {
            "apiKeyHeader": []
        },
        {
            "apiKeyQuery": []
        }
    ]


This isn't consistent and we can't seem to find a rhyme or reason as to why APIM is including that in the export sometimes. The Subscription section of the API settings does not have the Subscription required box checked, nor does it seem toggling that field makes a difference for the export behavior.

What drives the inclusion of those sections in the exported API swagger?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,303 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.