Open sascha-andres opened 3 years ago
Within an ISchemaProcessor you must not mutate settings...
This setting needs to be set before the generation is run, ie with document => document.ExcludedTypeNames
...
You cannot really exclude types with this, it is only applicable with base types so that inheritance chains are not generated. This is the only place: https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Generation/JsonSchemaGenerator.cs#L1022
Just ignoring a type cannot work as they are needed in the public API... but you can map your type to eg "object" with a a new mapper in TypeMappers.
There is another setting for the code generators ExcludedTypeNames where you can exclude schemas from being generated at all (produces not compilable code) but this is not the thing you're looking for i suppose.
~@RicoSuter Is it possible to just hide the "Schemas" section from the UI entirely? If so, how? Thanks.~ Never mind. Found it here: https://github.com/RicoSuter/NSwag/blob/512eb654b1be5714c7923b74d22e2049d56b5622/src/NSwag.AspNetCore/SwaggerUiSettings.cs#L89C31-L89C31
app.UseSwaggerUi3(ui =>
{
ui.DefaultModelsExpandDepth = -1;
})
I want to exclude Models from the schema. I tried to do that with SchemaProcessor:
I registered it like this:
Unfortunately this does not work. And for some Models I do not own the code, so for those I can not use attributes.
Any help appreciated.