Skip to content
Rico Suter edited this page Jan 18, 2020 · 8 revisions

With a schema processor, you can modify each generated schema after it has been generated.

Apply a processor to all schemas

Just implement the ISchemaProcessor and add an instance of the processor to the SchemaProcessors list of the JsonSchemaGeneratorSettings.

public class MySchemaProcessor : ISchemaProcessor
{
    public void Process(SchemaProcessorContext context)
    {
        ...
    }
}

settings.SchemaProcessors.Add(new MySchemaProcessor());

Apply a processor to a specific type

[JsonSchemaProcessor(typeof(MySchemaProcessor))]
public class MyType
{
    ...
}

TODO: Add sample from here: https://github.com/RSuter/NSwag/wiki/Document-Processors-and-Operation-Processors#sample-add-additional-types-from-an-assembly