Exemplo n.º 1
0
        public void Apply(
            Operation operation,
            OperationFilterContext context
            )
        {
            if (!context.HasAuthorize())
            {
                return;
            }

            operation.Responses.Add("401", new Response {
                Description = "Unauthorized"
            });
            operation.Responses.Add("403", new Response {
                Description = "Forbidden"
            });

            operation.Security = new List <IDictionary <string, IEnumerable <string> > >
            {
                new Dictionary <string, IEnumerable <string> >
                {
                    { "oauth2", _apiInfo.Scopes.Keys.ToArray() }
                }
            };
        }
        public void Apply(
            OpenApiOperation operation,
            OperationFilterContext context
            )
        {
            if (!context.HasAuthorize())
            {
                return;
            }

            operation.Responses.Add("401", new OpenApiResponse()
            {
                Description = "未授权访问"
            });
            operation.Responses.Add("403", new OpenApiResponse {
                Description = "不允许访问"
            });

            operation.Security = new List <OpenApiSecurityRequirement>
            {
                new OpenApiSecurityRequirement
                {
                    //{"oauth2", _apiInfo.Scopes }
                }
            };
        }
Exemplo n.º 3
0
        public void Apply(OpenApiOperation operation, OperationFilterContext context)
        {
            if (!context.HasAuthorize())
            {
                return;
            }

            operation.Responses.Add("401", new OpenApiResponse {
                Description = "Unauthorized"
            });
            operation.Responses.Add("403", new OpenApiResponse {
                Description = "Forbidden"
            });

            operation.Security = new List <OpenApiSecurityRequirement>
            {
                new OpenApiSecurityRequirement()
                {
                    { new OpenApiSecurityScheme {
                          Name = "oauth2"
                      }, _apiInfo.Scopes.Keys.ToList() }
                }
            };
        }