Two potential naming issues with api key authentication within SwaggerHub UI
I’m admittedly new to Swagger, and I’m having a hard time getting api_key working the way I believe it should be within the SwaggerHub UI.
The documentation at https://swagger.io/docs/specification/2-0/authentication/api-keys/ says:
“Add an entry with type: apiKey in the global securityDefinitions section. The entry name can be arbitrary (such as APIKeyHeader in the example below) and is used to refer to this security definition from other parts of the spec.” (my b/i/u emphasis added)
And provides this example:
But if I use the following YAML in SwaggerHub, which has two identical securitySchemes with only an "x" added to the end of the "entry name" of one of them:
openapi: 3.0.0
info:
version: "0.0.1"
title: Test
servers:
- description: Test
url: https://virtserver.swaggerhub.com/test/test/1.0.0
paths:
/blah:
get:
summary: 'api blah test 2'
description: 'Something goes here'
operationId: apiBlahTest
security:
- api_keyx: []
responses:
200:
description: Success
components:
securitySchemes:
api_keyx:
type: apiKey
name: api_keyxx
in: header
api_key:
type: apiKey
name: api_keyxx
in: header
with the security for /blah set to 'api_keyx', if in SwaggerHub I click the `/blah` and then the lock icon, it shows nothing for available authorizations:
But if I remove the 'x' at the end and change the `/blah`'s security to:
security:
- api_key: []
And then click the /blah lock icon, I get content in the authorizations dialog:
The `name` displayed within the pop-up does not reflect the name defined in the YAML, which I assume it would show in the dialog as `Name: api_keyxx` to match the YAML.
So two notes:
- The “entry name” does not appear to be arbitrary, if it is not specifically named “api_key” it doesn’t seem to appear in the SwaggerHub UI
- The entry’s “name” attribute (not to be confused with the “entry name”) does not appear to be reflected in the UI. The "name" seems to always be "api_key" (perhaps because it is using the "entry name" instead of the attribute "name"?
Am I doing something wrong, am I misunderstanding something(s), is the SwaggerHub UI presenting some bugs, or is it some combination thereof?
Thank you for any guidance.
--James
Thanks for the additional details, I've passed them to the developers. To track the issue status you can open a support ticket and reference this thread and issue # STEAM-3967.
The workaround seems to be to Save & refresh the editor after any changes in security schemes.