src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSecuritySchemeGenerator.cs
/// <summary>
/// Create the dictionary of <see cref="OpenApiSecurityScheme"/> object.
/// The name of each pair is the name of authorization. The value of each pair is a <see cref="OpenApiSecurityScheme"/>.
/// </summary>
/// <param name="context">The OData to Open API context.</param>
/// <returns>The string/security scheme dictionary.</returns>
Create the dictionary of  object.
The name of each pair is the name of authorization. The value of each pair is a .
Create the dictionary of object . The name of each pair is the name of authorization . The value of each pair is a .
public static IDictionary<string, OpenApiSecurityScheme> CreateSecuritySchemes(this ODataContext context)
        {
            Utils.CheckArgumentNull(context, nameof(context));
            if (context.Model == null || context.Model.EntityContainer == null)
            {
                return null;
            }
            IDictionary<string, OpenApiSecurityScheme> securitySchemes = new Dictionary<string, OpenApiSecurityScheme>();
            var authorizations = context.Model.GetAuthorizations(context.EntityContainer);
            if (authorizations == null)
            {
                return securitySchemes;
            }
            foreach (var authorization in authorizations)
            {
                OpenApiSecurityScheme scheme = new OpenApiSecurityScheme
                {
                    Type = authorization.SchemeType,
                    Description = authorization.Description
                };
                switch (authorization.SchemeType)
                {
                    case SecuritySchemeType.ApiKey: 
                        AppendApiKey(scheme, (ApiKey)authorization);
                        break;
                    case SecuritySchemeType.Http: 
                        AppendHttp(scheme, (Http)authorization);
                        break;
                    case SecuritySchemeType.OpenIdConnect: 
                        AppendOpenIdConnect(scheme, (OpenIDConnect)authorization);
                        break;
                    case SecuritySchemeType.OAuth2: 
                        AppendOAuth2(scheme, (OAuthAuthorization)authorization);
                        break;
                }
                securitySchemes[authorization.Name] = scheme;
            }
            return securitySchemes;
        }
public static IDictionary < string , OpenApiSecurityScheme > CreateSecuritySchemes ( this ODataContext context ) { Utils . CheckArgumentNull ( context , nameof ( context ) ) ; if ( context . Model == null || context . Model . EntityContainer == null ) { return null ; } IDictionary < string , OpenApiSecurityScheme > securitySchemes = new Dictionary < string , OpenApiSecurityScheme > ( ) ; var authorizations = context . Model . GetAuthorizations ( context . EntityContainer ) ; if ( authorizations == null ) { return securitySchemes ; } foreach ( var authorization in authorizations ) { OpenApiSecurityScheme scheme = new OpenApiSecurityScheme { Type = authorization . SchemeType , Description = authorization . Description } ; switch ( authorization . SchemeType ) { case SecuritySchemeType . ApiKey : AppendApiKey ( scheme , ( ApiKey ) authorization ) ; break ; case SecuritySchemeType . Http : AppendHttp ( scheme , ( Http ) authorization ) ; break ; case SecuritySchemeType . OpenIdConnect : AppendOpenIdConnect ( scheme , ( OpenIDConnect ) authorization ) ; break ; case SecuritySchemeType . OAuth2 : AppendOAuth2 ( scheme , ( OAuthAuthorization ) authorization ) ; break ; } securitySchemes [ authorization . Name ] = scheme ; } return securitySchemes ; }
Create the dictionary of  object.
Create the dictionary of object .
// ApiKey // Http // OpenIdConnect // OAuth2
The string/security scheme dictionary.
The string / security scheme dictionary .
ODataContext
this
context
The OData to Open API context.
The OData to Open API context .