Description
Describe the bug
This is applicable to V1.6.3.
When the securityScheme
item is a reference to another securityScheme
item in another file, then it cannot be resolved. I reported this bug previously but it seems to not be fixed entirely, we have 2 securityScheme items in the list and it resolves the first one but not the second. I tried to step through the code and found this:
In the class OpenApiDocument
and member function ResolveReference()
line 499 this:
return this.Components.SecuritySchemes[reference.Id];
then at this point if you look into the value of this.Components.SecuritySchemes
it has only the OAuth2
in the array and not also the PersonalAccessTokens
, it then throws a KeyNotFoundException
.
It is not entirely clear if the fact that the 2 items are references has anything to do with it or maybe there is another issue.
To Reproduce
In the main OpenApi contract document we have this
components:
securitySchemes:
OAuth2:
$ref: 'common-definitions_v4.yaml#/components/securitySchemes/OAuth2'
PersonalAccessTokens:
$ref: 'common-definitions_v4.yaml#/components/securitySchemes/PersonalAccessTokens'
and in the common-definitions_v4.yaml
we have defined
components:
securitySchemes:
OAuth2:
type: oauth2
description: OAuth2 based authentication using authorization code flow.
flows:
authorizationCode:
authorizationUrl: 'https://login.democompany.com/oauth/authorize'
tokenUrl: 'https://login.democompany.com/oauth/token'
scopes:
mx:datahub:services:write: Operations on resources that may create, delete or change resources.
mx:datahub:services:read: Read-only access to resources.
openid: Required to access user info, must have scope for every api
offline_access: Required to access user info, must have scope for every api
mx:user:profile:v1:read: Required to access user info, must have scope for every api
PersonalAccessTokens:
type: apiKey
in: header
name: Authorization
description: 'Personal access tokens for access to the Data Hub Catalog APIs; set in your [Democompany Developer Settings](https://user-settings.democompany.com/link/developersettings). Contents of the header should be ```MxToken <Your PAT>```.'
Expected behavior
When a securityScheme
item is a reference to a securityScheme
item in another file it should be resolved.