Search code examples
swaggerswagger-ui

How to get Swagger to send api_key in Header and in request URL?


I am able to either get the API key to be represented as a header or as a tag on the end of the URL, but I am needing it to be both. Is there any way for this to be possible? The picture is linked here


Solution

  • window.swaggerUi.api.clientAuthorizations.add(swashbuckleConfig.apiKeyName, new SwaggerClient.ApiKeyAuthorization(swashbuckleConfig.apiKeyName, key, "header"));
          window.swaggerUi.api.clientAuthorizations.add(swashbuckleConfig.apiKeyName + " query", new SwaggerClient.ApiKeyAuthorization(swashbuckleConfig.apiKeyName, key, "query"));