Skip to content

An idea for filtering request method #78

@Manweill

Description

@Manweill

An idea for filtering build methods, that filter requests by simply using app or web pages or other specific clients.
In .NET Server like this, add a new attribute

.NET

Controller

        [AttrName]
        public async Task Post(string url)
        {
              ...
        }

SwaggerFilter

public class SwaggerFilterHelper : IOperationFilter
    {
        public void Apply(OpenApiOperation operation, OperationFilterContext context)
        {
            var action = context.ApiDescription.ActionDescriptor as ControllerActionDescriptor;

            operation.OperationId = action.ActionName;
            var attr = context.ApiDescription.CustomAttributes()
                .OfType<YourAttrName>()
                .FirstOrDefault();
            if (attr != null)
            {
                operation.Extensions.Add("x-tag","YourAttrName");
            }
        }

Swagger Spec

"/api/abp/api-definition": {
      "Post": {
        "tags": [
          "api-definition"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationApiDescriptionModel"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationApiDescriptionModel"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationApiDescriptionModel"
                }
              }
            }
          }
        }
      },
     "x-tag":"YourAttrName"
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions