private static List GetSecurityOAuthScopes()

in src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/DocumentHelper.cs [337:389]


        private static List<string> GetSecurityOAuthScopes(OpenApiSecurityAttribute attr, OpenApiOAuthFlows flows)
        {
            var value = new List<string>();
            if (attr.SchemeType == SecuritySchemeType.ApiKey)
            {
                return value;
            }

            if (attr.SchemeType == SecuritySchemeType.Http)
            {
                return value;
            }

            if (attr.SchemeType == SecuritySchemeType.OAuth2)
            {
                if (flows.Implicit.IsNullOrDefault() && flows.Password.IsNullOrDefault() && flows.ClientCredentials.IsNullOrDefault() && flows.AuthorizationCode.IsNullOrDefault())
                {
                    throw new InvalidOperationException("Flow MUST be provided");
                }

                if (flows.Implicit?.Scopes?.Keys.Any() == true)
                {
                    value.AddRange(flows.Implicit?.Scopes?.Keys);
                }

                if (flows.Password?.Scopes?.Keys.Any() == true)
                {
                    value.AddRange(flows.Password?.Scopes?.Keys);
                }

                if (flows.ClientCredentials?.Scopes?.Keys.Any() == true)
                {
                    value.AddRange(flows.ClientCredentials?.Scopes?.Keys);
                }

                if (flows.AuthorizationCode?.Scopes?.Keys.Any() == true)
                {
                    value.AddRange(flows.AuthorizationCode?.Scopes?.Keys);
                }
            }

            if (attr.SchemeType == SecuritySchemeType.OpenIdConnect)
            {
                if (!attr.OpenIdConnectScopes.Any())
                {
                    throw new InvalidOperationException("Scope MUST be provided");
                }

                value.AddRange(attr.OpenIdConnectScopes.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()));
            }

            return value.Distinct().ToList();
        }