-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Labels
Description
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"
}fairking