-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Document Processors and Operation Processors
Rico Suter edited this page Aug 22, 2017
·
34 revisions
TBD.
TBD.
To implement a custom operation processor, just create a class which implements the interface IOperationProcessor
:
public class MyOperationProcessor : IOperationProcessor
{
public async Task<bool> ProcessAsync(OperationProcessorContext context)
{
// TODO: Process context.Document
return true; // return false to exclude the operation from the document
}
}
You can register the custom IOperationProcessor
to transform each operation:
app.UseSwagger(typeof(Startup).Assembly,
new SwaggerSettings
{
OperationProcessors =
{
new MyOperationProcessor()
}
}
);
You can also specify a operation processor for a single operation:
[SwaggerOperationProcessor(typeof(MyOperationProcessor))]
public void MyOperation()
{
}