Keith
October 11, 2022, 5:56pm
1
I would like to hide the fields automatically added to swagger-ui when using AutoQuery.
For example, for a simple service that reads from a database table, such as
public class ReadPrice : QueryDb<Price>, IGet
{
}
The following fields are shown in the swagger endpoint
Is it possible to configure the OpenApiFeature plugin so the all of the AutoQuery fields are hidden for all services?
I do not want to add additional annotations to each model.
layoric
October 11, 2022, 11:32pm
2
@Keith you can use the SchemaPropertyFilter
option on the OpenApiFeature
to filter out properties. Example below of filtering out all properties from QueryBase
which is the class where those properties are from.
Plugins.Add(new OpenApiFeature
{
SchemaPropertyFilter = property =>
{
if (property.PropertyInfo.DeclaringType?.Name == "QueryBase")
{
property.PropertyInfo.AddAttributes(new IgnoreDataMemberAttribute());
}
}
});
More info on OpenApi filtering options in our docs .
Hope that helps!
Keith
October 12, 2022, 8:23am
3
Hello @layoric , as always, brilliant support that worked perfectly. Thank you.
1 Like