Skip to content

Document Processors and Operation Processors

Rico Suter edited this page Aug 22, 2017 · 34 revisions

TBD.

Document Processors

TBD.

Operation Processors

You can register a global custom IOperationProcessor to transform each operation and to dynamically exclude operations from the generated Swagger specification:

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
    }
}

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()
{

}